From 79d0eb3e02ad1bc4c660ddcfc8b4365b41d9ffb8 Mon Sep 17 00:00:00 2001 From: jerrywgz Date: Fri, 19 Jul 2019 17:39:48 +0800 Subject: [PATCH] optimize error message when result is none (#2862) * optimize error message when result is none --- ppdet/utils/coco_eval.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ppdet/utils/coco_eval.py b/ppdet/utils/coco_eval.py index 7a8a59745..c2c8597ba 100644 --- a/ppdet/utils/coco_eval.py +++ b/ppdet/utils/coco_eval.py @@ -56,6 +56,10 @@ def bbox_eval(results, anno_file, outfile, with_background=True): for i, catid in enumerate(cat_ids)}) xywh_results = bbox2out(results, clsid2catid) + assert len( + xywh_results) > 0, "The number of valid bbox detected is zero.\n \ + Please use reasonable model and check input data." + with open(outfile, 'w') as f: json.dump(xywh_results, f) @@ -77,6 +81,10 @@ def mask_eval(results, anno_file, outfile, resolution, thresh_binarize=0.5): clsid2catid = {i + 1: v for i, v in enumerate(coco_gt.getCatIds())} segm_results = mask2out(results, clsid2catid, resolution, thresh_binarize) + assert len( + segms_results) > 0, "The number of valid mask detected is zero.\n \ + Please use reasonable model and check input data." + with open(outfile, 'w') as f: json.dump(segm_results, f) -- GitLab