glenn-jocher
commited on
Commit
•
6bd9218
1
Parent(s):
f284348
update test.py
Browse files
test.py
CHANGED
@@ -196,14 +196,12 @@ def test(data,
|
|
196 |
with open(f, 'w') as file:
|
197 |
json.dump(jdict, file)
|
198 |
|
199 |
-
try:
|
200 |
from pycocotools.coco import COCO
|
201 |
from pycocotools.cocoeval import COCOeval
|
202 |
|
203 |
-
# https://github.com/cocodataset/cocoapi/blob/master/PythonAPI/pycocoEvalDemo.ipynb
|
204 |
cocoGt = COCO(glob.glob('../coco/annotations/instances_val*.json')[0]) # initialize COCO ground truth api
|
205 |
cocoDt = cocoGt.loadRes(f) # initialize COCO pred api
|
206 |
-
|
207 |
cocoEval = COCOeval(cocoGt, cocoDt, 'bbox')
|
208 |
cocoEval.params.imgIds = imgIds # image IDs to evaluate
|
209 |
cocoEval.evaluate()
|
@@ -242,8 +240,7 @@ if __name__ == '__main__':
|
|
242 |
opt.data = check_file(opt.data) # check file
|
243 |
print(opt)
|
244 |
|
245 |
-
|
246 |
-
if opt.task in ['val', 'test']: # (default) run normally
|
247 |
test(opt.data,
|
248 |
opt.weights,
|
249 |
opt.batch_size,
|
|
|
196 |
with open(f, 'w') as file:
|
197 |
json.dump(jdict, file)
|
198 |
|
199 |
+
try: # https://github.com/cocodataset/cocoapi/blob/master/PythonAPI/pycocoEvalDemo.ipynb
|
200 |
from pycocotools.coco import COCO
|
201 |
from pycocotools.cocoeval import COCOeval
|
202 |
|
|
|
203 |
cocoGt = COCO(glob.glob('../coco/annotations/instances_val*.json')[0]) # initialize COCO ground truth api
|
204 |
cocoDt = cocoGt.loadRes(f) # initialize COCO pred api
|
|
|
205 |
cocoEval = COCOeval(cocoGt, cocoDt, 'bbox')
|
206 |
cocoEval.params.imgIds = imgIds # image IDs to evaluate
|
207 |
cocoEval.evaluate()
|
|
|
240 |
opt.data = check_file(opt.data) # check file
|
241 |
print(opt)
|
242 |
|
243 |
+
if opt.task in ['val', 'test']: # run normally
|
|
|
244 |
test(opt.data,
|
245 |
opt.weights,
|
246 |
opt.batch_size,
|