Skip to content

Commit

Permalink
[Enhancement]: Support empty val. (#310)
Browse files Browse the repository at this point in the history
  • Loading branch information
RangiLyu authored Aug 22, 2021
1 parent bd1fa26 commit 76e025b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions nanodet/evaluator/coco_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import copy
import json
import os
import warnings

from pycocotools.cocoeval import COCOeval

Expand Down Expand Up @@ -65,6 +66,17 @@ def results2json(self, results):

def evaluate(self, results, save_dir, rank=-1):
results_json = self.results2json(results)
if len(results_json) == 0:
warnings.warn(
"Detection result is empty! Please check whether "
"training set is too small (need to increase val_interval "
"in config and train more epochs). Or check annotation "
"correctness."
)
empty_eval_results = {}
for key in self.metric_names:
empty_eval_results[key] = 0
return empty_eval_results
json_path = os.path.join(save_dir, "results{}.json".format(rank))
json.dump(results_json, open(json_path, "w"))
coco_dets = self.coco_api.loadRes(json_path)
Expand Down

0 comments on commit 76e025b

Please sign in to comment.