HumanSignal / label-studio-converter

Tools for converting Label Studio annotations into common dataset formats
https://labelstud.io/
262 stars 130 forks source link

fix: Only export bboxes and polygon segmentations to YOLO #196

Closed frederik-ai closed 5 months ago

frederik-ai commented 1 year ago

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 commented 1 year ago

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.

luuzk commented 1 year ago

Seems like all threads are solved. Can we merge?

makseq commented 5 months ago

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": " makseq@gmail.com, 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": "makseq@gmail.com",
        "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 commented 5 months ago

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