Pytorch_Retinaface icon indicating copy to clipboard operation
Pytorch_Retinaface copied to clipboard

evaluation.py error

Open wanglaotou opened this issue 6 years ago • 6 comments
trafficstars

hi, thanks for you share. First i run this command: python setup.py build_ext --inplace and then i run: python evaluation.py -p widerface_txt/ -g ground_truth/ i get error like this: ImportError: dynamic module does not define module export function (PyInit_bbox) , it seems that i have not succeed in compile box_overlaps.pyx. but what should i do. my env is python3.5 and pytorch1.2.0.

wanglaotou avatar Nov 07 '19 11:11 wanglaotou

Sorry, I didn't come across this problem. My env is python3.7 and pytorch1.2.0 ,ubuntu18.04 You can refer to https://github.com/wondervictor/WiderFace-Evaluation.

biubug6 avatar Nov 08 '19 09:11 biubug6

@wanglaotou Hi, I met the same question, have you solved this problem?

BlueCCircles avatar Feb 21 '20 07:02 BlueCCircles

Hello, I think I found the answer.
The problem occurred due to name mismatch. You need to change the output so file name in setup.py: change package = Extension('bbox', ['box_overlaps.pyx'], include_dirs=[numpy.get_include()]) to package = Extension('box_overlaps', ['box_overlaps.pyx'], include_dirs=[numpy.get_include()]) and change module name in evaluation.py to match the names: from box_overlaps import bbox_overlaps

yechanp avatar Mar 03 '20 04:03 yechanp

@yechanp Thanks for your answer, I had finished this issues. I just replaced cpython version bbox.pyx with python version bbox.py.

BlueCCircles avatar Mar 09 '20 03:03 BlueCCircles

@BlueCCircles Hello, Thanks for your answer. Could you share your python version bbox.py, please?

aixin200005 avatar Sep 13 '20 02:09 aixin200005

使用如下的代码去替代 evaluation.py中的 bbox_overlaps,并注释掉from box_overlaps import bbox_overlaps,并且可以不使用 python setup.py build_ext --inplace这行命令; python代码如下: def bbox_overlaps_(bboxes1, bboxes2): N = bboxes1.shape[0] M = bboxes2.shape[0] overlaps = np.zeros((N, M))

for i in range(N):
    bbox1 = bboxes1[i]
    area1 = (bbox1[2] - bbox1[0]) * (bbox1[3] - bbox1[1])

    for j in range(M):
        bbox2 = bboxes2[j]
        area2 = (bbox2[2] - bbox2[0]) * (bbox2[3] - bbox2[1])

        x_min = max(bbox1[0], bbox2[0])
        y_min = max(bbox1[1], bbox2[1])
        x_max = min(bbox1[2], bbox2[2])
        y_max = min(bbox1[3], bbox2[3])

        intersection_area = max(0, x_max - x_min) * max(0, y_max - y_min)
        union_area = area1 + area2 - intersection_area
        overlaps[i, j] = intersection_area / union_area

return overlaps

liujialong2019 avatar Jul 18 '23 11:07 liujialong2019