The YOLO export has incorrect label names and an altered category order compared to the original setup in Label Studio

Hi Label studio Support Team,

  1. Issue: After exporting, I noticed two significant issues:

(a)Label Name Mismatch: The label names in the YOLO file do not correspond to the expected class names. The labels in the YOLO file are incorrect for all classes.

(b)Category Order Change: The order of categories in the YOLO file has also changed compared to how they were set up in Label Studio.

The YOLO export has incorrect label names and altered category order compared to Label Studio, so please resolve this issue soon to ensure the file is correct.

Has anyone encountered similar issues or have any suggestions for troubleshooting? Your assistance would be greatly appreciated.
Thank you!

Hi,

try using category field on Label tags:

Hi,

I am experiencing the same issues. Adding category tag does not work. I remember it does work in some previous version, but I forget which one is it.

Example:

{
  "categories": [
    {
      "id": "2",
      "name": "safe_b"
    },
    {
      "id": "0",
      "name": "safe_h"
    },
    {
      "id": "3",
      "name": "n_safe_b"
    },
    {
      "id": "1",
      "name": "n_safe_h"
    }
  ],
  "info": {
    "year": 2024,
    "version": "1.0",
    "contributor": "Label Studio"
  }
}
safe_b
safe_h
n_safe_b
n_safe_h

The correct order:

  1. safe_h
  2. n_safe_h
  3. safe_b
  4. n_safe_b

Could you please share your labeling config? And some sample of tasks in JSON format?

I’ve just checked it, everything works as expected:

If I use this simple labeling config:

<View>
  <Image name="image" value="$image"/>
  <RectangleLabels name="label" toName="image">
    <Label value="Airplane" background="green"/>
    <Label value="Car" background="blue"/>
  </RectangleLabels>
</View>

=>

{
    "categories": [
        {
            "id": 0,
            "name": "Airplane"
        },
        {
            "id": 1,
            "name": "Car"
        }
    ],
    "info": {
        "year": 2024,
        "version": "1.0",
        "contributor": "Label Studio"
    }
}

If I use categories in the labeling config:

<View>
  <Image name="image" value="$image"/>
  <RectangleLabels name="label" toName="image">
    <Label value="Airplane" category="1" background="green"/>
    <Label value="Car" category="0" background="blue"/>
  </RectangleLabels>
</View>

=>

{
    "categories": [
        {
            "id": "0",
            "name": "Car"
        },
        {
            "id": "1",
            "name": "Airplane"
        }
    ],
    "info": {
        "year": 2024,
        "version": "1.0",
        "contributor": "Label Studio"
    }
}

The labeling config:

<View>
  <Image name="image" value="$image" zoom="true" zoomControl="true"/>
  <RectangleLabels name="label" toName="image">
  	<Label value="safe_h" category="0" background="#8ae234"/>
    <Label value="n_safe_h" category="1" background="#D4380D"/>
    <Label value="safe_b" category="2" background="#729fcf"/>
    <Label value="n_safe_b" category="3" background="#fcaf3e"/>
  </RectangleLabels>
</View>

Sample tasks

{
  "id": 697,
  "data": {
    "image": "http://192.168.51.22:9000/test_bucket/809c136a-0b0a-4721-9921-c96457dba180.jpg"
  },
  "annotations": [
    {
      "id": 593,
      "result": [],
      "created_username": " , 1",
      "created_ago": "5 days, 18 hours",
      "completed_by": {
        "id": 1,
        "first_name": "",
        "last_name": "",
        "avatar": null,
        "email": "",
        "initials": "yf"
      },
      "was_cancelled": false,
      "ground_truth": false,
      "created_at": "2024-09-17T06:35:00.546917Z",
      "updated_at": "2024-09-17T07:05:14.718511Z",
      "draft_created_at": null,
      "lead_time": 15.008,
      "import_id": null,
      "last_action": null,
      "task": 697,
      "project": 2,
      "updated_by": 4,
      "parent_prediction": null,
      "parent_annotation": null,
      "last_created_by": null
    }
  ],
  "predictions": []
}{
  "id": 697,
  "data": {
    "image": "http://192.168.51.22:9000/test_bucket/809c136a-0b0a-4721-9921-c96457dba180.jpg"
  },
  "annotations": [
    {
      "id": 593,
      "result": [],
      "created_username": ", 1",
      "created_ago": "5 days, 18 hours",
      "completed_by": {
        "id": 1,
        "first_name": "",
        "last_name": "",
        "avatar": null,
        "email": "",
        "initials": "yf"
      },
      "was_cancelled": false,
      "ground_truth": false,
      "created_at": "2024-09-17T06:35:00.546917Z",
      "updated_at": "2024-09-17T07:05:14.718511Z",
      "draft_created_at": null,
      "lead_time": 15.008,
      "import_id": null,
      "last_action": null,
      "task": 697,
      "project": 2,
      "updated_by": 4,
      "parent_prediction": null,
      "parent_annotation": null,
      "last_created_by": null
    }
  ],
  "predictions": []
}

I suspect it is because I added the category tag after I label the project.

I have double check the exported label in yolo format. The class id does not match the original order, nor the exported order.

what LS version you are using?

also you sent annotations without any regions in incorrect json format.

I am using heartexlabs/label-studio:latest.
label-studio version

{
    "release": "1.13.1",
    "label-studio-os-package": {
        "version": "1.13.1",
        "short_version": "1.13",
        "latest_version_from_pypi": "1.13.1",
        "latest_version_upload_time": "2024-08-20T17:38:07",
        "current_version_is_outdated": false
    },
    "label-studio-os-backend": {
        "message": "ci: Build frontend",
        "commit": "d9b816a3781ee806bba50c8c5589fcdb8555a277",
        "date": "2024/08/19 19:14:23",
        "branch": "",
        "version": "1.13.1+0.gd9b816a"
    },
    "label-studio-frontend": {
        "message": "fix: LEAP-762: Fix offsets in domManager for emojis (#6135)",
        "commit": "8d8a7fce72b808d00f94cc10b49669121d186c1f",
        "date": "2024-08-01T03:08:02.000Z",
        "branch": "develop"
    },
    "dm2": {
        "message": "chore: OPTIC-866: Stylus to Sass conversion LS web/libs/datamanager/sr ...",
        "commit": "8fbedaa6fdd00338da19c258a798b8799f0cd935",
        "date": "2024-07-26T15:12:41.000Z",
        "branch": "develop"
    },
    "label-studio-converter": {
        "version": "1.0.5"
    }
}

For the annotations, please kindly check the following one:

{
  "id": 728,
  "data": {
    "image": "http://192.168.51.22:9000/test_bucket/40dfdea-c7dd-4ae8-9776-b9efc1c28a2e.jpg"
  },
  "annotations": [
    {
      "id": 383,
      "result": [
        {
          "type": "rectanglelabels",
          "value": {
            "x": 75.87505,
            "y": 9.589049999999999,
            "width": 21.4375,
            "height": 76.3387,
            "rectanglelabels": [
              "n_safe_b"
            ]
          },
          "origin": "manual",
          "to_name": "image",
          "from_name": "label",
          "original_width": 1280,
          "original_height": 720
        }
      ],
      "created_username": "",
      "created_ago": "6 days, 21 hours",
      "completed_by": null,
      "was_cancelled": false,
      "ground_truth": false,
      "created_at": "2024-09-17T05:34:51.721259Z",
      "updated_at": "2024-09-17T05:34:51.721268Z",
      "draft_created_at": null,
      "lead_time": null,
      "import_id": null,
      "last_action": null,
      "task": 728,
      "project": 2,
      "updated_by": 1,
      "parent_prediction": null,
      "parent_annotation": null,
      "last_created_by": null
    }
  ],
  "predictions": []
}```