Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace deprecated NumPy aliases with builtin types #117

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

piotlinski
Copy link

NumPy 1.20 deprecates some of the aliases of the builtin types: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

With version 1.24 the aliases were removed; the change is necessary to keep TrackEval working with newer versions of NumPy.

I replaced np.int, np.float and np.bool aliases with builtin types according to the table in the deprecation note.

@mikel-brostrom
Copy link

mikel-brostrom commented Feb 16, 2023

The problem here is that pycocotools, which is used by this repo for MOTS stuff, also has this issue. While it isn't updated on both sides the numpy version cannot be upgraded so I see no way of merging this. And pycocotools doesn't seem to be mantained anymore 😢. Last update was 3 years ago.

@piotlinski
Copy link
Author

I see. However the use of these aliases is not consistent throughout TrackEval and this PR addresses this issue, unifying the approach (there are multiple places in which Python types were already used). What is more, for those who use TrackEval without the functionalities of pycocotools (myself included), this allows to use newer versions of NumPy as well.

One way would be to create a fork of pycocotools, fix the issues and switch to the fork here. This seems to be a bit of a fuss though :/

@mikel-brostrom
Copy link

mikel-brostrom commented Feb 17, 2023

One way would be to create a fork of pycocotools, fix the issues and switch to the fork here. This seems to be a bit of a fuss though :/

Yup 😞. But at some point I guess it has to be done as pycocotools will become unusable otherwise

@wilderrodrigues
Copy link

Came here looking to fix it myself because we need to update to Numpy 1.14, but then found this MR.

It's not preferable to stay tied to pycocotools if they are so far behind with Numpy. Perhaps creating a fork and updating it should be the way to go.

@wilderrodrigues
Copy link

Also, pycocotools uses np.float in 2 lines only.

https://github.com/cocodataset/cocoapi/blob/master/PythonAPI/pycocotools/cocoeval.py#L378

I fixed it for me with this hack:

import numpy as np
from packaging import version

if version.parse(np.__version__) >= version.parse("1.24.0"):
    np.float = np.float32
    np.int = np.int32
    np.bool = bool

Added it just before the import to trackeval. But it would be awesome to see someone taking pycocotools over and updating it.

@Dorozhko-Anton
Copy link

these commands to patch from CLI worked for me

grep -rl np.int . | xargs sed -i 's/np.int/int/g'
grep -rl np.bool . | xargs sed -i 's/np.bool/bool/g'
grep -rl np.float . | xargs sed -i 's/np.float/float/g'

@mikel-brostrom
Copy link

mikel-brostrom commented Oct 16, 2023

these commands to patch from CLI worked for me

grep -rl np.int . | xargs sed -i 's/np.int/int/g'
grep -rl np.bool . | xargs sed -i 's/np.bool/bool/g'
grep -rl np.float . | xargs sed -i 's/np.float/float/g'

I went for exact this same solution @Dorozhko-Anton. It is the best option right now IMO, rather than waiting for all eternity for this to get merged 😆

@dzambrano
Copy link

dzambrano commented Mar 21, 2024

I have edited the comment.
This repo uses
pycocotools

and not the original coco:
cocodataset

Therefore, we would just need to update the requirements to the latest pycocotools version.
pycocotools==2.0.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants