HumanSignal / label-studio-sdk

Label Studio SDK
https://api.labelstud.io
77 stars 50 forks source link

import multiple segmentations from coco format json #246

Open Ljung323 opened 1 week ago

Ljung323 commented 1 week ago

Problem

when converting coco annotation to label studio format, only the first item is used as a segmentation.

https://github.com/HumanSignal/label-studio-sdk/blob/5fceb54cc74766f5666db8a835c8301e3d5b4c32/src/label_studio_sdk/converter/imports/coco.py#L54

for example

expected

actual

Suggestion

can we use all segmentations instead? or am I misunderstanding something?

from

https://github.com/HumanSignal/label-studio-sdk/blob/5fceb54cc74766f5666db8a835c8301e3d5b4c32/src/label_studio_sdk/converter/imports/coco.py#L218-L227

to

something like this

        if "segmentation" in annotation and len(annotation["segmentation"]):
            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)
makseq commented 1 week ago

It seems it's just not implemented. Could you submit a PR with this?

Ljung323 commented 1 week ago

@makseq thank you very much for the comment. I opened a PR: https://github.com/HumanSignal/label-studio-sdk/pull/251

sajarin commented 1 week ago

Thanks for reporting this and for opening a PR @Ljung323, our team will take a look at get back to you with comments in the PR

Ljung323 commented 1 week ago

thank you for acknowledging the report and the PR, look forward to a feedback.