JonathonLuiten / TrackEval

HOTA (and other) evaluation metrics for Multi-Object Tracking (MOT).
MIT License
963 stars 239 forks source link

Replace deprecated NumPy aliases with builtin types #117

Open piotlinski opened 1 year ago

piotlinski commented 1 year ago

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 commented 1 year ago

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 :cry:. Last update was 3 years ago.

piotlinski commented 1 year ago

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 commented 1 year ago

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 :disappointed:. But at some point I guess it has to be done as pycocotools will become unusable otherwise

wilderrodrigues commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 :laughing:

dzambrano commented 7 months ago

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