Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
cdpath committed Mar 28, 2023
1 parent 1f9a30c commit 9bd9d0f
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions label_studio_converter/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,12 @@ def add_image(images, width, height, image_id, image_path):

for label in labels:
category_name = None
for key in ['rectanglelabels', 'polygonlabels', 'brushlabels', 'labels']:
for key in [
'rectanglelabels',
'polygonlabels',
'brushlabels',
'labels',
]:
if key in label and len(label[key]) > 0:
category_name = label[key][0]
break
Expand Down Expand Up @@ -718,14 +723,16 @@ def add_image(images, width, height, image_id, image_path):
)
elif 'brushlabels' in label and brush.pycocotools_imported:
segmentation = brush.ls_rle_to_coco_rle(label["rle"], height, width)
annotations.append({
"image_id": image_id,
"segmentation": segmentation,
"area": brush.get_cocomask_area(segmentation),
"bbox": brush.get_cocomask_bounding_box(segmentation),
"iscrowd": 1,
"category_id": category_id,
})
annotations.append(
{
"image_id": image_id,
"segmentation": segmentation,
"area": brush.get_cocomask_area(segmentation),
"bbox": brush.get_cocomask_bounding_box(segmentation),
"iscrowd": 1,
"category_id": category_id,
}
)
else:
raise ValueError("Unknown label type")

Expand Down

0 comments on commit 9bd9d0f

Please sign in to comment.