HumanSignal / label-studio

Label Studio is a multi-type data labeling and annotation tool with standardized output format
https://labelstud.io
Apache License 2.0
19.25k stars 2.39k forks source link

Create Masks Using RectangleLabels and Export to COCO Format #2069

Open Cazual opened 2 years ago

Cazual commented 2 years ago

Is your feature request related to a problem? Please describe. I am unable to train my Mask-RCNN using bounding box annotations created in Label Studio. This is because there are no masks created when using the RectangleLabels to annotate. There is also no mask export happening when using COCO export.

Describe the solution you'd like I previously used a different tool called COCO Annotator that allowed me to annotate using bounding boxes and export annotations that had both bboxes and segmentation components of the COCO data format. Label studio exports do not have segmentation components when exporting in COCO format.

Describe alternatives you've considered My alternative is at this point to switch to a Faster-RCNN that doesnt utilize masking. It should be fine but I would like to be able to do either.

Additional context Annotation produced using label-studio: image

Annotation produced using COCO Annotator: image

p4tr1ckc4rs0n commented 2 years ago

This feature would be very helpful for work I am trying to do too (training a Mask-RCNN model). Are there any alternatives to generating both bounding boxes and segmentation masks for training?

Edit: this is a viable solution https://github.com/facebookresearch/detectron2/issues/485#issuecomment-1107898221

makseq commented 2 years ago

What should it be in segmentation in case of bboxes? LS can export PolygonLabels to COCO as segmentation.

kodecreer commented 1 year ago

You can calculate the bounding boxes by having the min and max of the coordinates from the masks.

makseq commented 1 year ago

@kodecreer do you have examples with similar coco exports?

kodecreer commented 1 year ago

The same process from the PyTorch object detection tutorials if you are able to extract just each mask from the image into a black and white photo like traditional Mask-R CNN

pos = np.where(mask)
xmin = np.min(pos[1])
xmax = np.max(pos[1])
ymin = np.min(pos[0])
ymax = np.max(pos[0])
boxes.append([xmin, ymin, xmax, ymax])
makseq commented 1 year ago

@kodecreer Maybe you could contribute this?