Skip to content

Commit 76e025b

Browse files
authored
[Enhancement]: Support empty val. (#310)
1 parent bd1fa26 commit 76e025b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

nanodet/evaluator/coco_detection.py

+12
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import copy
1616
import json
1717
import os
18+
import warnings
1819

1920
from pycocotools.cocoeval import COCOeval
2021

@@ -65,6 +66,17 @@ def results2json(self, results):
6566

6667
def evaluate(self, results, save_dir, rank=-1):
6768
results_json = self.results2json(results)
69+
if len(results_json) == 0:
70+
warnings.warn(
71+
"Detection result is empty! Please check whether "
72+
"training set is too small (need to increase val_interval "
73+
"in config and train more epochs). Or check annotation "
74+
"correctness."
75+
)
76+
empty_eval_results = {}
77+
for key in self.metric_names:
78+
empty_eval_results[key] = 0
79+
return empty_eval_results
6880
json_path = os.path.join(save_dir, "results{}.json".format(rank))
6981
json.dump(results_json, open(json_path, "w"))
7082
coco_dets = self.coco_api.loadRes(json_path)

0 commit comments

Comments
 (0)