Skip to content

feat: LEAP-1937: Add brush_to_coco format #429

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Apr 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 36 additions & 9 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jsonschema = ">=4.23.0"
lxml = ">=4.2.5"
nltk = "^3.9.1"
numpy = ">=1.26.4,<2.0.0"
opencv-python = "^4.9.0" #add openCV
pandas = ">=0.24.0"
pydantic = ">= 1.9.2"
pydantic-core = "^2.18.2"
Expand Down
21 changes: 21 additions & 0 deletions src/label_studio_sdk/converter/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class Format(Enum):
YOLO_WITH_IMAGES = 14
COCO_WITH_IMAGES = 15
YOLO_OBB_WITH_IMAGES = 16
BRUSH_TO_COCO = 17

def __str__(self):
return self.name
Expand Down Expand Up @@ -167,6 +168,12 @@ class Converter(object):
"format expected by NVIDIA NeMo models.",
"link": "https://labelstud.io/guide/export.html#ASR-MANIFEST",
"tags": ["speech recognition"],
},
Format.BRUSH_TO_COCO: {
"title": "Brush labels to COCO",
"description": "Export your brush labels as COCO format for segmentation tasks. Converts RLE encoded masks to COCO polygons.",
"link": "https://labelstud.io/guide/export.html#COCO",
"tags": ["image segmentation", "brush annotations"],
},
}

Expand Down Expand Up @@ -293,6 +300,19 @@ def convert(self, input_data, output_data, format, is_dir=True, **kwargs):
upload_dir=self.upload_dir,
download_resources=self.download_resources,
)
elif format == Format.BRUSH_TO_COCO:
items = (
self.iter_from_dir(input_data)
if is_dir
else self.iter_from_json_file(input_data)
)
from label_studio_sdk.converter.exports.brush_to_coco import convert_to_coco
image_dir = kwargs.get("image_dir")
convert_to_coco(
items,
output_data,
output_image_dir=image_dir
)

def _get_data_keys_and_output_tags(self, output_tags=None):
data_keys = set()
Expand Down Expand Up @@ -376,6 +396,7 @@ def _get_supported_formats(self):
):
all_formats.remove(Format.BRUSH_TO_NUMPY.name)
all_formats.remove(Format.BRUSH_TO_PNG.name)
all_formats.remove(Format.BRUSH_TO_COCO.name)
if not (
("Audio" in input_tag_types or "AudioPlus" in input_tag_types)
and "TextArea" in output_tag_types
Expand Down
Loading
Loading