From 379b731a6b95dcba4234366eb7f5ab170bda1070 Mon Sep 17 00:00:00 2001 From: Guanghua Yu <742925032@qq.com> Date: Thu, 31 Dec 2020 14:28:30 +0800 Subject: [PATCH] fix record empty error in coco reader (#1960) --- ppdet/data/source/coco.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ppdet/data/source/coco.py b/ppdet/data/source/coco.py index 67c561786..e393a4609 100644 --- a/ppdet/data/source/coco.py +++ b/ppdet/data/source/coco.py @@ -146,6 +146,8 @@ class COCODataSet(DataSet): 'x1: {}, y1: {}, x2: {}, y2: {}.'.format( img_id, x1, y1, x2, y2)) num_bbox = len(bboxes) + if num_bbox <= 0: + continue gt_bbox = np.zeros((num_bbox, 4), dtype=np.float32) gt_class = np.zeros((num_bbox, 1), dtype=np.int32) @@ -154,6 +156,7 @@ class COCODataSet(DataSet): difficult = np.zeros((num_bbox, 1), dtype=np.int32) gt_poly = [None] * num_bbox + has_segmentation = False for i, box in enumerate(bboxes): catid = box['category_id'] gt_class[i][0] = catid2clsid[catid] @@ -161,6 +164,10 @@ class COCODataSet(DataSet): is_crowd[i][0] = box['iscrowd'] if 'segmentation' in box: gt_poly[i] = box['segmentation'] + has_segmentation = True + + if has_segmentation and not any(gt_poly): + continue coco_rec.update({ 'is_crowd': is_crowd, -- GitLab