label-studio-sdk icon indicating copy to clipboard operation
label-studio-sdk copied to clipboard

import multiple segmentations from coco format json

Open Ljung323 opened this issue 1 year ago • 4 comments

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)

Ljung323 avatar Jun 17 '24 03:06 Ljung323

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

makseq avatar Jun 18 '24 14:06 makseq

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

Ljung323 avatar Jun 19 '24 02:06 Ljung323

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

sajarin avatar Jun 19 '24 18:06 sajarin

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

Ljung323 avatar Jun 20 '24 00:06 Ljung323