Skip to content

Commit

Permalink
import multiple polygons
Browse files Browse the repository at this point in the history
  • Loading branch information
Ljung323 committed Jun 19, 2024
1 parent a67c59c commit d5287ad
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/label_studio_sdk/converter/imports/coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,9 @@ def create_bbox(annotation, categories, from_name, image_height, image_width, to


def create_segmentation(
annotation, categories, from_name, image_height, image_width, to_name
category_id, segmentation, categories, from_name, image_height, image_width, to_name
):
label = categories[int(annotation["category_id"])]
segmentation = annotation["segmentation"][0]
label = categories[int(category_id)]
points = [list(x) for x in zip(*[iter(segmentation)] * 2)]

for i in range(len(points)):
Expand Down Expand Up @@ -216,15 +215,17 @@ def convert_coco_to_ls(
task[out_type][0]["result"].append(item)

if "segmentation" in annotation and len(annotation["segmentation"]):
item = create_segmentation(
annotation,
categories,
segmentation_from_name,
image_height,
image_width,
to_name,
)
task[out_type][0]["result"].append(item)
for single_segmentation in annotation["segmentation"]:
item = create_segmentation(
annotation["category_id"],
single_segmentation,
categories,
segmentation_from_name,
image_height,
image_width,
to_name,
)
task[out_type][0]["result"].append(item)

if "keypoints" in annotation:
items = create_keypoints(
Expand Down

0 comments on commit d5287ad

Please sign in to comment.