From 0559c9aa45aa76b1f2e4cd0840f390b013971bbd Mon Sep 17 00:00:00 2001 From: George Correa de Araujo Date: Fri, 25 Feb 2022 18:00:14 -0300 Subject: [PATCH 1/2] Fixed the pycocotools workaround Signed-off-by: George Correa de Araujo --- imantics/annotation.py | 1 + 1 file changed, 1 insertion(+) diff --git a/imantics/annotation.py b/imantics/annotation.py index 38369bd..7a9393c 100644 --- a/imantics/annotation.py +++ b/imantics/annotation.py @@ -290,6 +290,7 @@ def coco(self, include=True): # 4 value segmentation mask is a bounding box polygon = annotation['segmentation'][i] x1, y1, x2, y2 = polygon + if x2 == x1: x = x1 y = (y2 + y1) // 2 From f5a52ec73c8c6344435aa0d2fd683a512dfa2568 Mon Sep 17 00:00:00 2001 From: George Correa de Araujo Date: Sun, 27 Feb 2022 01:23:44 -0300 Subject: [PATCH 2/2] Fixed infinite loop bug Signed-off-by: George Correa de Araujo --- imantics/annotation.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/imantics/annotation.py b/imantics/annotation.py index 7a9393c..7e301cc 100644 --- a/imantics/annotation.py +++ b/imantics/annotation.py @@ -284,6 +284,7 @@ def coco(self, include=True): if len(annotation['segmentation'][i]) == 2: # discard segmentation that is only a point annotation['segmentation'].pop(i) + i -= 1 elif len(annotation['segmentation'][i]) == 4: # create another point in the middle of segmentation to # avoid bug when using pycocotools, which thinks that a @@ -305,7 +306,8 @@ def coco(self, include=True): new_segmentation = polygon[:2] + [x, y] + polygon[2:] annotation['segmentation'][i] = new_segmentation - i += 1 + + i += 1 if include: image = category = {}