pycocotools and numpy 1.17 fix for #1182
This commit is contained in:
parent
f6a19d5b32
commit
3f27ef1253
|
@ -1,5 +1,6 @@
|
||||||
# pip install -U -r requirements.txt
|
# pip install -U -r requirements.txt
|
||||||
numpy
|
# pycocotools requires numpy 1.17 https://github.com/cocodataset/cocoapi/issues/356
|
||||||
|
numpy == 1.17
|
||||||
opencv-python >= 4.1
|
opencv-python >= 4.1
|
||||||
torch >= 1.5
|
torch >= 1.5
|
||||||
matplotlib
|
matplotlib
|
||||||
|
|
25
test.py
25
test.py
|
@ -204,19 +204,20 @@ def test(cfg,
|
||||||
try:
|
try:
|
||||||
from pycocotools.coco import COCO
|
from pycocotools.coco import COCO
|
||||||
from pycocotools.cocoeval import COCOeval
|
from pycocotools.cocoeval import COCOeval
|
||||||
|
|
||||||
|
# https://github.com/cocodataset/cocoapi/blob/master/PythonAPI/pycocoEvalDemo.ipynb
|
||||||
|
cocoGt = COCO(glob.glob('../coco/annotations/instances_val*.json')[0]) # initialize COCO ground truth api
|
||||||
|
cocoDt = cocoGt.loadRes('results.json') # initialize COCO pred api
|
||||||
|
|
||||||
|
cocoEval = COCOeval(cocoGt, cocoDt, 'bbox')
|
||||||
|
cocoEval.params.imgIds = imgIds # [:32] # only evaluate these images
|
||||||
|
cocoEval.evaluate()
|
||||||
|
cocoEval.accumulate()
|
||||||
|
cocoEval.summarize()
|
||||||
|
# mf1, map = cocoEval.stats[:2] # update to pycocotools results (mAP@0.5:0.95, mAP@0.5)
|
||||||
except:
|
except:
|
||||||
print('WARNING: missing pycocotools package, can not compute official COCO mAP. See requirements.txt.')
|
print('WARNING: pycocotools must be installed with numpy==1.17 to run correctly. '
|
||||||
|
'See https://github.com/cocodataset/cocoapi/issues/356')
|
||||||
# https://github.com/cocodataset/cocoapi/blob/master/PythonAPI/pycocoEvalDemo.ipynb
|
|
||||||
cocoGt = COCO(glob.glob('../coco/annotations/instances_val*.json')[0]) # initialize COCO ground truth api
|
|
||||||
cocoDt = cocoGt.loadRes('results.json') # initialize COCO pred api
|
|
||||||
|
|
||||||
cocoEval = COCOeval(cocoGt, cocoDt, 'bbox')
|
|
||||||
cocoEval.params.imgIds = imgIds # [:32] # only evaluate these images
|
|
||||||
cocoEval.evaluate()
|
|
||||||
cocoEval.accumulate()
|
|
||||||
cocoEval.summarize()
|
|
||||||
# mf1, map = cocoEval.stats[:2] # update to pycocotools results (mAP@0.5:0.95, mAP@0.5)
|
|
||||||
|
|
||||||
# Return results
|
# Return results
|
||||||
maps = np.zeros(nc) + map
|
maps = np.zeros(nc) + map
|
||||||
|
|
Loading…
Reference in New Issue