From 3f27ef1253bf83429350cbaeb8e1d01aff9de7ae Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Fri, 15 May 2020 20:50:58 -0700 Subject: [PATCH] pycocotools and numpy 1.17 fix for #1182 --- requirements.txt | 3 ++- test.py | 25 +++++++++++++------------ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/requirements.txt b/requirements.txt index c82ddd8d..08c696bb 100755 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,6 @@ # 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 torch >= 1.5 matplotlib diff --git a/test.py b/test.py index 0f968811..a4b2ab6b 100644 --- a/test.py +++ b/test.py @@ -204,19 +204,20 @@ def test(cfg, try: from pycocotools.coco import COCO 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: - print('WARNING: missing pycocotools package, can not compute official COCO mAP. See requirements.txt.') - - # 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) + print('WARNING: pycocotools must be installed with numpy==1.17 to run correctly. ' + 'See https://github.com/cocodataset/cocoapi/issues/356') # Return results maps = np.zeros(nc) + map