GETTINGSTRTED.md says I can evaluate the model with pretrained weights by
python tools/test.py configs/pascal_voc/faster_rcnn_r50_fpn_1x_voc.py \
checkpoints/SOME_CHECKPOINT.pth \
--eval mAP
but when I did so, the output is
……
Evaluating bbox...
Loading and preparing results...
DONE (t=1.98s)
creating index...
index created!
Traceback (most recent call last):
File "/home/whh/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/numpy/core/function_base.py", line 117, in linspace
num = operator.index(num)
TypeError: 'numpy.float64' object cannot be interpreted as an integer
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "tools/test.py", line 175, in
main()
File "tools/test.py", line 171, in main
dataset.evaluate(outputs, args.eval, **kwargs)
File "/home/whh/projects/mmdetection/mmdet/datasets/coco.py", line 359, in evaluate
cocoEval = COCOeval(cocoGt, cocoDt, iou_type)
File "/home/whh/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/pycocotools/cocoeval.py", line 76, in __init__
self.params = Params(iouType=iouType) # parameters
File "/home/whh/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/pycocotools/cocoeval.py", line 521, in __init__
self.setDetParams()
File "/home/whh/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/pycocotools/cocoeval.py", line 501, in setDetParams
self.iouThrs = np.linspace(.5, 0.95, np.round((0.95 - .5) / .05) + 1, endpoint=True)
File "<__array_function__ internals>", line 6, in linspace
File "/home/whh/anaconda3/envs/open-mmlab/lib/python3.7/site-packages/numpy/core/function_base.py", line 121, in linspace
.format(type(num)))
TypeError: object of type
so what should I do
Hi @Whileherham ,
How did you install the pycocotools
?
You first can try to reinstall it by the following command and then try to evaluate your model again.
pip install "git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI"
Hi @Whileherham ,
How did you install thepycocotools
?
You first can try to reinstall it by the following command and then try to evaluate your model again.pip install "git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI"
Thank you. I installed pycocotools by downloading the code and 'make install' under PythonAPI since the command in your install.md cannot work in my computer.
I finally solved the problem by modifying the source code 'cocoeval.py'. I replaced the
self.iouThrs = np.linspace(.5, 0.95, np.round((0.95 - .5) / .05) + 1, endpoint=True)
self.recThrs = np.linspace(.0, 1.00, np.round((1.00 - .0) / .01) + 1, endpoint=True)
with
self.iouThrs = np.linspace(.5, 0.95, 10, endpoint=True)
self.recThrs = np.linspace(.0, 1.00, 101, endpoint=True)
and it worked.
Some people say it is because the version of my numpy is too high, and the same problem has occured in other repo and is solved by lower version numpy. So I guess maybe we can restrict the version of numpy in install.md
OK, thanks for your kind suggestion. We will consider that in the future release.
Yes, it's a problem of numpy. When I used numpy==1.18.2, the problem occurred, then I downgraded it to 1.16.0, everything is fine.
Most helpful comment
Thank you. I installed pycocotools by downloading the code and 'make install' under PythonAPI since the command in your install.md cannot work in my computer.
I finally solved the problem by modifying the source code 'cocoeval.py'. I replaced the
self.iouThrs = np.linspace(.5, 0.95, np.round((0.95 - .5) / .05) + 1, endpoint=True)
self.recThrs = np.linspace(.0, 1.00, np.round((1.00 - .0) / .01) + 1, endpoint=True)
with
self.iouThrs = np.linspace(.5, 0.95, 10, endpoint=True)
self.recThrs = np.linspace(.0, 1.00, 101, endpoint=True)
and it worked.
Some people say it is because the version of my numpy is too high, and the same problem has occured in other repo and is solved by lower version numpy. So I guess maybe we can restrict the version of numpy in install.md