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

fix: Only export bboxes and polygon segmentations to YOLO

Open frederik-ai opened this issue 2 years ago • 2 comments

Fix issue heartexlabs/label-studio#3556

Only allow specific types of annotations to be added to YOLO. Otherwise metadata classes are added to classes.txt.

Both RectangleLabels and PolygonLabels are added, as YOLO export now also supports segmentation. Additionally, it would break COCO exports to only allow RectangleLabels.

frederik-ai avatar Feb 02 '23 09:02 frederik-ai

Sorry for the late response, seems like I have the notifications disabled.

To your question: When exporting empty annotations, the images are still exported. So I assume that an empty return value of _get_labes still leads to an export.

I now changed it such that the label types are only filtered by 'rectangleLabels' and 'polygonLabels' for YOLO exports.

frederik-ai avatar Apr 23 '23 08:04 frederik-ai

Seems like all threads are solved. Can we merge?

luuzk avatar Aug 08 '23 09:08 luuzk

Unfortunately, this fix doesn't work for this case:

<View>
  <Image name="image" value="$image"/>
  <Polygon name="poly" toName="image" />
  <Rectangle name="rect" toName="image" />
  <Labels name="label" toName="image">
    <Label value="Airplane" background="green"/>
    <Label value="Car" background="blue"/>
  </Labels>
</View>

Check out this annotations: for each rectangle and polygon we will have a region with labels, but without type:

{
  "id": 112360554,
  "data": {
    "image": "https://app.heartex.com/storage-data/uploaded/?filepath=upload/71582/013686d8-9-add-group.png"
  },
  "annotations": [
    {
      "id": 38247361,
      "created_username": " [email protected], 9",
      "created_ago": "2 minutes",
      "completed_by": {
        "id": 9,
        "first_name": "",
        "last_name": "",
        "avatar": "https://app.heartex.com/storage-data/uploaded/?filepath=avatars/ff6c719c-430d1d9e-b209-4c54-b1e5-56c73229588c_clipped_rev_1.png",
        "email": "[email protected]",
        "initials": "ma"
      },
      "last_annotation_history": 40544406,
      "reviews": null,
      "result": [
        {
          "id": "26qBD9fhiy",
          "type": "rectangle",
          "value": {
            "x": 19.158878504672895,
            "y": 48.214285714285715,
            "width": 12.92834890965732,
            "height": 28.571428571428577,
            "rotation": 0
          },
          "origin": "manual",
          "to_name": "image",
          "from_name": "rect",
          "image_rotation": 0,
          "original_width": 1407,
          "original_height": 490
        },
        {
          "id": "26qBD9fhiy",
          "type": "labels",
          "value": {
            "x": 19.158878504672895,
            "y": 48.214285714285715,
            "width": 12.92834890965732,
            "height": 28.571428571428577,
            "labels": [
              "Airplane"
            ],
            "rotation": 0
          },
          "origin": "manual",
          "to_name": "image",
          "from_name": "label",
          "image_rotation": 0,
          "original_width": 1407,
          "original_height": 490
        },
        {
          "id": "trv0izsa9n",
          "type": "polygon",
          "value": {
            "closed": true,
            "points": [
              [
                47.50778816199377,
                72.32142857142857
              ],
              [
                61.37071651090342,
                62.94642857142857
              ],
              [
                58.09968847352025,
                36.607142857142854
              ],
              [
                49.22118380062305,
                43.30357142857143
              ]
            ]
          },
          "origin": "manual",
          "to_name": "image",
          "from_name": "poly",
          "image_rotation": 0,
          "original_width": 1407,
          "original_height": 490
        },
        {
          "id": "trv0izsa9n",
          "type": "labels",
          "value": {
            "closed": true,
            "labels": [
              "Car"
            ],
            "points": [
              [
                47.50778816199377,
                72.32142857142857
              ],
              [
                61.37071651090342,
                62.94642857142857
              ],
              [
                58.09968847352025,
                36.607142857142854
              ],
              [
                49.22118380062305,
                43.30357142857143
              ]
            ]
          },
          "origin": "manual",
          "to_name": "image",
          "from_name": "label",
          "image_rotation": 0,
          "original_width": 1407,
          "original_height": 490
        }
      ],
      "was_cancelled": false,
      "ground_truth": false,
      "created_at": "2024-06-04T14:57:03.805164Z",
      "updated_at": "2024-06-04T14:59:25.112811Z",
      "draft_created_at": "2024-06-04T14:56:59.142594Z",
      "lead_time": 151.28400000000002,
      "import_id": null,
      "last_action": "updated",
      "task": 112360554,
      "project": 71582,
      "updated_by": 9,
      "parent_prediction": null,
      "parent_annotation": null,
      "last_created_by": 9,
      "comment_count": 0,
      "unresolved_comment_count": 0
    }
  ],
  "predictions": []
}

makseq avatar Jun 04 '24 15:06 makseq

After careful consideration, we’ve determined that this is more of an improvement than a critical bug. Additionally, it seems to be an outdated request and hasn’t garnered much interest from the community. For these reasons, we will be closing this issue. We will continue developing the converter library as a part of Label Studio SDK.

We appreciate your understanding and encourage you to submit your feedback, questions and suggestions here: https://github.com/HumanSignal/label-studio-sdk/issues

makseq avatar Jun 04 '24 15:06 makseq