Skip to content

Commit 49e0faa

Browse files
authored
Merge pull request #662 from Labelbox/jtso/coco
[AL-3169] Update to shapely geoms
2 parents 5b4b4bf + 7841a34 commit 49e0faa

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

labelbox/data/serialization/coco/instance_dataset.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,14 @@ def mask_to_coco_object_annotation(
2828
xmin, ymin, xmax, ymax = shapely.bounds
2929
# Iterate over polygon once or multiple polygon for each item
3030
area = shapely.area
31-
if shapely.type == 'Polygon':
32-
shapely = [shapely]
3331

3432
return COCOObjectAnnotation(
3533
id=annot_idx,
3634
image_id=image_id,
3735
category_id=category_id,
3836
segmentation=[
39-
np.array(s.exterior.coords).ravel().tolist() for s in shapely
37+
np.array(s.exterior.coords).ravel().tolist()
38+
for s in ([shapely] if shapely.type == "Polygon" else shapely.geoms)
4039
],
4140
area=area,
4241
bbox=[xmin, ymin, xmax - xmin, ymax - ymin],

0 commit comments

Comments
 (0)