-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEvaluation_official.py
executable file
·37 lines (28 loc) · 1.19 KB
/
Evaluation_official.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
### Evaluation
import os
import matplotlib.pyplot as plt
from torchcv.evaluations.coco import COCO
from torchcv.evaluations.eval_MR_multisetup import COCOeval
annType = 'bbox'
JSON_GT_FILE = os.path.join( '/content/drive/MyDrive/kaist_annotations_test20.json' )
cocoGt = COCO(JSON_GT_FILE)
def evaluate_coco(test_json_path):
fig_test, ax_test = plt.subplots(figsize=(18,15))
rstFile = os.path.join(test_json_path)
try:
cocoDt = cocoGt.loadRes(rstFile)
imgIds = sorted(cocoGt.getImgIds())
cocoEval = COCOeval(cocoGt,cocoDt,annType)
cocoEval.params.imgIds = imgIds
cocoEval.params.catIds = [1]
cocoEval.evaluate(0)
cocoEval.accumulate()
curPerf = cocoEval.summarize(0)
cocoEval.draw_figure(ax_test, rstFile.replace('json', 'jpg'))
print('Recall: {:}'.format( 1-cocoEval.eval['yy'][0][-1] ) )
except:
import torchcv.utils.trace_error
print('[Error] cannot evaluate by cocoEval. ')
if __name__ == '__main__':
test_json_path = '/content/drive/MyDrive/kaist_output/thermal_prediction_0725.json'
evaluate_coco(test_json_path)