Closed getcontrol closed 3 years ago
Some objects in this image are indeed multipolygons because they include holes. Could you define the class ids that may be multipolygons in the "multipolygons_id" variable in the main notebook? And set also the black background, the outlier, to a multipolygon.
I figured it out: My masks weren't one uniform RGB color but instead a range of light grey & dark grey colors. I have it working on a dataset where masks RGB values are uniform
Hi, I am getting the same error.
The error shows up in the following type of image:
I've already tried to binarized it, but the error persists.
Could you please help me?
Hi everyone! Same error here for the following mask.
For me, the following code in src.create_annotation.create_sub_mask_annotation
solves the problem:
if (poly.geom_type == 'MultiPolygon'):
# if MultiPolygon, take the smallest convex Polygon containing all the points in the object
poly = poly.convex_hull
if (poly.geom_type == 'Polygon'): # Ignore if still not a Polygon (could be a line or point)
polygons.append(poly)
segmentation = np.array(poly.exterior.coords).ravel().tolist()
segmentations.append(segmentation)
@enrj97 I've tried your code but I'm getting this error:
Traceback (most recent call last):
File "/home/alan/mask2json/main.py", line 82, in <module>
coco_format["images"], coco_format["annotations"], annotation_cnt = images_annotations_info(mask_path)
File "/home/alan/mask2json/main.py", line 46, in images_annotations_info
polygons, segmentations = create_sub_mask_annotation(sub_mask)
TypeError: cannot unpack non-iterable NoneType object
@alancarlosml check this and try to cut off the small polygons.
Hi everyone! Same error here for the following mask.
For me, the following code in
src.create_annotation.create_sub_mask_annotation
solves the problem:if (poly.geom_type == 'MultiPolygon'): # if MultiPolygon, take the smallest convex Polygon containing all the points in the object poly = poly.convex_hull if (poly.geom_type == 'Polygon'): # Ignore if still not a Polygon (could be a line or point) polygons.append(poly) segmentation = np.array(poly.exterior.coords).ravel().tolist() segmentations.append(segmentation)
Hi everyone! Same error here for the following mask.
For me, the following code in
src.create_annotation.create_sub_mask_annotation
solves the problem:if (poly.geom_type == 'MultiPolygon'): # if MultiPolygon, take the smallest convex Polygon containing all the points in the object poly = poly.convex_hull if (poly.geom_type == 'Polygon'): # Ignore if still not a Polygon (could be a line or point) polygons.append(poly) segmentation = np.array(poly.exterior.coords).ravel().tolist() segmentations.append(segmentation)
This solution works in my case. Thank you so much for your solution.
Get this error when trying to convert these types of masks to json . I assume its because of the weird polygons:
mask_sample
Similar issue reported here https://github.com/akTwelve/cocosynth/issues/9 and maybe fixed here https://github.com/akTwelve/cocosynth/blob/3909837290ab3511ff03ffe57ae870c929bd40a0/python/coco_json_utils.py