I'm running a Python code which has the following statements:
# do NMS
dets = np.hstack((boxes, scores[:, np.newaxis])).astype(np.float32, copy=False)
keep = nms(dets, 0.3) # -> *** Error is thrown here :(
dets = dets[keep, :]
The data shown by the debugger is:
Eventually, the code throws this error:
AttributeError: module 'numpy' has no attribute 'int'.
At this line of code:
from .nms.cpu_nms import cpu_nms, cpu_soft_nms
def nms(dets, thresh):
"""Dispatch to either CPU or GPU NMS implementations."""
if dets.shape[0] == 0:
return []
return cpu_nms(dets, thresh) # -> *** Error is thrown here :(
I don't see any usage of np.int
but I see that np.float32
is used as can be seen above. As suggested here, I replaced np.float32
with np.float32_
. Then I get another error:
AttributeError: module 'numpy' has no attribute 'float32_'
I replaced np.float32
with np.float_
, then this error is received:
File "nms/cpu_nms.pyx", line 17, in nms.cpu_nms.cpu_nms
ValueError: Buffer dtype mismatch, expected 'float32_t' but got 'double'
What else I can try to resolve the error?
I doublechecked the Numpy version on my activated Conda environment, it was 1.26.4
:
python -c "import numpy; print(numpy.version.version)"
1.26.4
It was strange since I had installed version 1.23
as suggested by the repository:
So, I figured out that for some reason, the Conda environment is using Numpy from:
/home/arisa/.local/bin/pip3
Rather than from the activated env:
/home/arisa/.conda/envs/mononphm/bin/pip3
So, I removed all the Numpy versions from the system altogether:
pip3 uninstall numpy
And re-installed the version suggested by the repository inside the Conda env:
/home/arisa/.conda/envs/mononphm/bin/pip3 install numpy==1.23
Now the error is resolved :)
Note that I had previously run into a similar problem before: ModuleNotFoundError: No module named 'mononphm'