diff --git a/nanodet/evaluator/coco_detection.py b/nanodet/evaluator/coco_detection.py index 27251ecae..97bb4db0b 100644 --- a/nanodet/evaluator/coco_detection.py +++ b/nanodet/evaluator/coco_detection.py @@ -15,6 +15,7 @@ import copy import json import os +import warnings from pycocotools.cocoeval import COCOeval @@ -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)