From 2b9807cdc1a1505ec44356592e764477fa21422e Mon Sep 17 00:00:00 2001 From: will-jl944 Date: Tue, 31 Aug 2021 13:48:57 +0800 Subject: [PATCH] fix bug that pop item while traversing image list in coco dataset (#4056) --- ppdet/data/source/coco.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ppdet/data/source/coco.py b/ppdet/data/source/coco.py index a3cc3e0c4..c4fbcfc40 100644 --- a/ppdet/data/source/coco.py +++ b/ppdet/data/source/coco.py @@ -179,7 +179,7 @@ class COCODataSet(DetDataset): gt_poly = [None] * num_bbox has_segmentation = False - for i, box in enumerate(bboxes): + for i, box in reversed(list(enumerate(bboxes))): catid = box['category_id'] gt_class[i][0] = self.catid2clsid[catid] gt_bbox[i, :] = box['clean_bbox'] @@ -193,11 +193,10 @@ class COCODataSet(DetDataset): elif 'segmentation' in box and box['segmentation']: if not np.array(box['segmentation'] ).size > 0 and not self.allow_empty: - bboxes.pop(i) gt_poly.pop(i) - np.delete(is_crowd, i) - np.delete(gt_class, i) - np.delete(gt_bbox, i) + is_crowd = np.delete(is_crowd, i) + gt_class = np.delete(gt_class, i) + gt_bbox = np.delete(gt_bbox, i) else: gt_poly[i] = box['segmentation'] has_segmentation = True -- GitLab