update test.py
This commit is contained in:
parent
f2843481a9
commit
6bd9218922
7
test.py
7
test.py
|
|
@ -196,14 +196,12 @@ def test(data,
|
||||||
with open(f, 'w') as file:
|
with open(f, 'w') as file:
|
||||||
json.dump(jdict, file)
|
json.dump(jdict, file)
|
||||||
|
|
||||||
try:
|
try: # https://github.com/cocodataset/cocoapi/blob/master/PythonAPI/pycocoEvalDemo.ipynb
|
||||||
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
|
cocoGt = COCO(glob.glob('../coco/annotations/instances_val*.json')[0]) # initialize COCO ground truth api
|
||||||
cocoDt = cocoGt.loadRes(f) # initialize COCO pred api
|
cocoDt = cocoGt.loadRes(f) # initialize COCO pred api
|
||||||
|
|
||||||
cocoEval = COCOeval(cocoGt, cocoDt, 'bbox')
|
cocoEval = COCOeval(cocoGt, cocoDt, 'bbox')
|
||||||
cocoEval.params.imgIds = imgIds # image IDs to evaluate
|
cocoEval.params.imgIds = imgIds # image IDs to evaluate
|
||||||
cocoEval.evaluate()
|
cocoEval.evaluate()
|
||||||
|
|
@ -242,8 +240,7 @@ if __name__ == '__main__':
|
||||||
opt.data = check_file(opt.data) # check file
|
opt.data = check_file(opt.data) # check file
|
||||||
print(opt)
|
print(opt)
|
||||||
|
|
||||||
# task = 'val', 'test', 'study'
|
if opt.task in ['val', 'test']: # run normally
|
||||||
if opt.task in ['val', 'test']: # (default) run normally
|
|
||||||
test(opt.data,
|
test(opt.data,
|
||||||
opt.weights,
|
opt.weights,
|
||||||
opt.batch_size,
|
opt.batch_size,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue