Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,23 @@ 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).
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 and infinite loop)

so instead of
```
pip install imantics
```
prefer
```
pip install imantics==0.1.9

or better, get version with my fixes
pip install git+https://github.com/SixK/imantics.git
```


<p align="center">Join our growing <a href="https://discord.gg/4zP5Qkj">discord community</a> of ML practitioner</p>
<p align="center">
Expand Down
7 changes: 6 additions & 1 deletion imantics/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -284,6 +287,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
Expand All @@ -304,7 +308,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 = {}
Expand Down
8 changes: 8 additions & 0 deletions imantics/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,21 @@ 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)

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 :
print('WARNING - Category is None for Image', flush=True)
return

color = category.color if color_by_category else annotation.color

if mask:
Expand Down