From 6bfb0620fd412eddff82c576d37bd8e7b618cebb Mon Sep 17 00:00:00 2001 From: SixK Date: Wed, 25 Oct 2023 12:53:18 +0200 Subject: [PATCH 1/7] Fix color orders RGB vs BRG to keep same order than previous versions --- imantics/image.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/imantics/image.py b/imantics/image.py index 3f4bb3d..4977501 100644 --- a/imantics/image.py +++ b/imantics/image.py @@ -184,6 +184,8 @@ def draw(self, bbox=True, outline=True, mask=True, text=True, thickness=3, \ temp_image = cv2.imread(self.path) + temp_image = cv2.cvtColor(temp_image, cv2.COLOR_BGR2RGB) + if temp_image is None: temp_image = np.zeros((self.height,self.width,3)).astype(np.uint8) temp_image.setflags(write=True) From 04765cef1abb0f289d5a6fa60ced6e24a214b9e5 Mon Sep 17 00:00:00 2001 From: SixK Date: Wed, 25 Oct 2023 21:56:13 +0200 Subject: [PATCH 2/7] Add informations about imantics vresions --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index 345ce6b..eac953f 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,22 @@ Currently Support Formats: - YOLO - VOC +This version fix color order changes from BGR to RGB introduced in version 0.1.12 (or at least after 0.1.9). +Also note that v0.1.12 is actually the official imantics pip version, but this version is buggous. +Stay on master branch to benefit from unreleased v0.1.13 vresion that fix problems (except color order change) + +so instead of +``` +pip install imantics +``` +prefer +``` +pip install imantics==0.1.9 + +or better +pip install git+https://github.com/SixK/imantics.git +``` +

Join our growing discord community of ML practitioner

From 97025afa5819909974067ea72799f891e79a7a87 Mon Sep 17 00:00:00 2001 From: SixK Date: Wed, 25 Oct 2023 22:00:36 +0200 Subject: [PATCH 3/7] Update README.md fix typos --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index eac953f..7f57e89 100644 --- a/README.md +++ b/README.md @@ -35,9 +35,9 @@ Currently Support Formats: - YOLO - VOC -This version fix color order changes from BGR to RGB introduced in version 0.1.12 (or at least after 0.1.9). -Also note that v0.1.12 is actually the official imantics pip version, but this version is buggous. -Stay on master branch to benefit from unreleased v0.1.13 vresion that fix problems (except color order change) +This version fix color order changes from BGR to RGB introduced in version 0.1.12 (or at least after 0.1.9). +Also note that v0.1.12 is actually the official imantics pip version, but this version is buggous. +Stay on master branch to benefit from unreleased 0.1.13 version that fix problems (except color order change) so instead of ``` From 683833d215852d670284f756222d83aa5007c089 Mon Sep 17 00:00:00 2001 From: George Correa de Araujo Date: Sun, 27 Feb 2022 01:23:44 -0300 Subject: [PATCH 4/7] 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 38369bd..e9db8c7 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 @@ -304,7 +305,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 = {} From ca99686dfe3f1ad65be3d9737c31ecc6c048b06a Mon Sep 17 00:00:00 2001 From: SixK Date: Sun, 19 Nov 2023 00:51:03 +0100 Subject: [PATCH 5/7] Test category and avoid Traceback if category is none in Annotation --- README.md | 5 +++-- imantics/annotation.py | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7f57e89..1b21e0a 100644 --- a/README.md +++ b/README.md @@ -36,8 +36,9 @@ Currently Support Formats: - VOC This version fix color order changes from BGR to RGB introduced in version 0.1.12 (or at least after 0.1.9). +This version also fix infinite loop in Annotation.coco() thank's to george-gca work. (cherry-pick george-gca fix). Also note that v0.1.12 is actually the official imantics pip version, but this version is buggous. -Stay on master branch to benefit from unreleased 0.1.13 version that fix problems (except color order change) +Stay on master branch to benefit from unreleased 0.1.13 version that fix problems (except color order change and infinite loop) so instead of ``` @@ -47,7 +48,7 @@ prefer ``` pip install imantics==0.1.9 -or better +or better, get version with my fixes pip install git+https://github.com/SixK/imantics.git ``` diff --git a/imantics/annotation.py b/imantics/annotation.py index e9db8c7..a4ed6fc 100644 --- a/imantics/annotation.py +++ b/imantics/annotation.py @@ -204,6 +204,9 @@ def index(self, image, dataset=None): annotation_index[self.id] = self # Category indexing should be case insenstive + if self.category == None: + print('WARNING - Category is None for Annotation', flush=True) + return category_name = self.category.name.lower() # Check if category exists From d5d916bdefbc8918ba35117556716db592800091 Mon Sep 17 00:00:00 2001 From: SixK Date: Sun, 19 Nov 2023 01:28:36 +0100 Subject: [PATCH 6/7] Avoid Traceback if Category is None in Image --- imantics/image.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/imantics/image.py b/imantics/image.py index 4977501..53b8a01 100644 --- a/imantics/image.py +++ b/imantics/image.py @@ -193,6 +193,10 @@ def draw(self, bbox=True, outline=True, mask=True, text=True, thickness=3, \ for annotation in self.iter_annotations(): category = annotation.category if (categories is None) or (category in categories): + if category == None : + print('WARNING - Category is None for Image', flush=True) + return + color = category.color if color_by_category else annotation.color if mask: From bdbf5dfc465e1160ff40f1097fe940f8ea801ef5 Mon Sep 17 00:00:00 2001 From: SixK Date: Sun, 19 Nov 2023 23:51:16 +0100 Subject: [PATCH 7/7] Avoid trying to try to use category.color when catagory is None and color_by_category is set to True. This should happen in coco-annotator when category is marked as deleted --- imantics/image.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/imantics/image.py b/imantics/image.py index 53b8a01..5009ceb 100644 --- a/imantics/image.py +++ b/imantics/image.py @@ -191,6 +191,8 @@ def draw(self, bbox=True, outline=True, mask=True, text=True, thickness=3, \ temp_image.setflags(write=True) for annotation in self.iter_annotations(): + if color_by_category and annotation.category is None: + continue category = annotation.category if (categories is None) or (category in categories): if category == None :