-1

Code

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, :]

Data

The data shown by the debugger is:

Debugger steppper

Debugger data

Error

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

Tried 1

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_'

Tried 2

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'

Question

What else I can try to resolve the error?

9
  • 1
    Please show your complete traceback Commented Sep 10, 2024 at 13:59
  • Just in case it might be helpful, the line of code throwing the errors is this: github.com/jhb86253817/PIPNet/blob/… Commented Sep 10, 2024 at 13:59
  • 2
    No. It's this line github.com/jhb86253817/PIPNet/blob/… Commented Sep 10, 2024 at 14:02
  • 1
    @OneCricketeer Thanks. For some reason, my debugger doesn't go through that line at all. Commented Sep 10, 2024 at 14:03
  • 2
    You'll need to downgrade Numpy to a version that was used 4 years ago when this repo was last updated Commented Sep 10, 2024 at 14:04

1 Answer 1

1

Numpy version mismatch

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:

Suggested Numpy version

Conda not using Numpy from activated env

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

Solution

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'

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.