question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ValueError: Buffer dtype mismatch, expected 'int_t' but got 'long long'

See original GitHub issue

In the line xx1 = np.maximum(x1[i], x1[order[1:]]) below it throws this error in FaceBoxes\utils\nms\py_cpu_nms.py

def py_cpu_nms(dets, thresh):
    """Pure Python NMS baseline."""
    x1 = dets[:, 0]
    y1 = dets[:, 1]
    x2 = dets[:, 2]
    y2 = dets[:, 3]
    scores = dets[:, 4]

    areas = (x2 - x1 + 1) * (y2 - y1 + 1)
    order = scores.argsort()[::-1]

    keep = []
    while order.size > 0:
        i = order[0]
        keep.append(i)
        xx1 = np.maximum(x1[i], x1[order[1:]])
        yy1 = np.maximum(y1[i], y1[order[1:]])
        xx2 = np.minimum(x2[i], x2[order[1:]])
        yy2 = np.minimum(y2[i], y2[order[1:]])

        w = np.maximum(0.0, xx2 - xx1 + 1)
        h = np.maximum(0.0, yy2 - yy1 + 1)
        inter = w * h
        ovr = inter / (areas[i] + areas[order[1:]] - inter)

        inds = np.where(ovr <= thresh)[0]
        order = order[inds + 1]

    return keep

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:16 (3 by maintainers)

github_iconTop GitHub Comments

15reactions
zubair-ahmed-aicommented, Sep 23, 2020

I changed to the following in FaceBoxes/utils/nms/cpu_nms.pyx after lots of tries and it seems to be working (in progress)

def cpu_nms(np.ndarray[np.float32_t, ndim=2] dets, np.float thresh):
    cdef np.ndarray[np.float32_t, ndim=1] x1 = dets[:, 0]
    cdef np.ndarray[np.float32_t, ndim=1] y1 = dets[:, 1]
    cdef np.ndarray[np.float32_t, ndim=1] x2 = dets[:, 2]
    cdef np.ndarray[np.float32_t, ndim=1] y2 = dets[:, 3]
    cdef np.ndarray[np.float32_t, ndim=1] scores = dets[:, 4]

    cdef np.ndarray[np.float32_t, ndim=1] areas = (x2 - x1 + 1) * (y2 - y1 + 1)
    cdef np.ndarray[np.int64_t, ndim=1] order = scores.argsort()[::-1]

    cdef int ndets = dets.shape[0]
    cdef np.ndarray[np.int64_t, ndim=1] suppressed = \
            np.zeros((ndets), dtype=np.int64)
1reaction
JacksonL1commented, Nov 20, 2020

if you got “cl : Command line error D8021 : invalid numeric argument ‘/Wno-cpp’” error modify 47 line of build.py to extra_compile_args=[‘std=c99’],

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cython: Buffer type mismatch, expected 'int' but got 'long'
You are using Cython's int type, which is just C int . I think on Mac (or most architectures) it is int 32-bit....
Read more >
ValueError: Buffer dtype mismatch, expected 'int' but got 'long'
I'm trying to fit a logistic regression on a sparse matrix, but I'm failing due to some ValueError: model = LogisticRegression( C=1, ...
Read more >
ValueError: Buffer dtype mismatch, expected 'long' but got ...
I am trying to run test diagnostics on a trained model. The model throws an issue ValueError: Buffer dtype mismatch, expected 'long' but...
Read more >
DigitalSlideArchive/HistomicsTK - Gitter
I think this is caused by a mismatch in the 'int' size between numpy and the compiler on your system. We should go...
Read more >
ValueError: Buffer dtype mismatch, expected 'long_t' but got ...
This error comes from cnp.long_t being different than the C Cython type identifier long. (with cimport numpy as cnp). Strangely, this error does ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found