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.34k stars 2.4k forks source link

Importing Pre-annotated data in done using yolov8 semantic segmentation (polygon) issue with JSON format compatibilty #6113

Open saifwael8 opened 3 months ago

saifwael8 commented 3 months ago

Describe the bug So I was trying to import data in Yolov8 text format to label studio. There was a tutorial that I followed explaining importing detection yolov8 format by converting it to label studio JSON format using LabelStudio-converter. That method worked fine when importing detection data containing the 4 coordinates. However, when I tried to import segmentation data containing multiple coordinates of the segmentation polygon the converter did not work. Thus, I wrote a script to convert the yolov8 seg format to label studio JSON format and the images were uploaded along with the coordinates in the columns, but for some reason the segmentations done would not appear on the image at all. I think it is a problem with the generated JSON format from my script so I would really appreciate the help from someone of the LS team. Attached below is snippets from LS, my python conversion script and an example of the generated JSON format.

To Reproduce Steps to reproduce the behavior:

  1. Run my py script on the images folder containing images, labels and classes
  2. Import to LS
  3. Open images to see annotations
  4. See error (No annotations are found)

Expected behavior The annotations should be present

Screenshots Screenshot 2024-07-21 152931 Screenshot 2024-07-21 152944

Environment (please complete the following information):

Additional context output_new.json Screenshot 2024-07-21 153214

makseq commented 3 months ago

I see that your code tries to reuse some parts of bbox import, but it's wrong. There shouldn't be any width/height/centers in polygon lines. You can check how it's done in COCO import.

Also it would be great if you could make a PR in label-studio-sdk with YOLO and the polygon import. This code should be placed here: https://github.com/HumanSignal/label-studio-sdk/blob/master/src/label_studio_sdk/converter/imports/yolo.py.

Then we will be able to review your code and point you to potential problems.