From 6417474551a695da872d4b272a356ca405a1d316 Mon Sep 17 00:00:00 2001 From: wangguanzhong Date: Thu, 29 Oct 2020 21:27:14 +0800 Subject: [PATCH] filter invalid segmentation in data source (#1630) --- ppdet/data/source/coco.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ppdet/data/source/coco.py b/ppdet/data/source/coco.py index 67c561786..d2d16f1f4 100644 --- a/ppdet/data/source/coco.py +++ b/ppdet/data/source/coco.py @@ -137,7 +137,12 @@ class COCODataSet(DataSet): y1 = max(0, y) x2 = min(im_w - 1, x1 + max(0, box_w - 1)) y2 = min(im_h - 1, y1 + max(0, box_h - 1)) - if x2 >= x1 and y2 >= y1: + if 'segmentation' in inst and len(inst[ + 'segmentation']) == 0: + logger.warn( + 'Found an empty segmentation in annotations: im_id: {}.'. + format(img_id)) + elif x2 >= x1 and y2 >= y1: inst['clean_bbox'] = [x1, y1, x2, y2] bboxes.append(inst) else: -- GitLab