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
18.38k stars 2.31k forks source link

Wrong rotation output of box annotations in exporting to YOLO format #5223

Open KingofLong opened 9 months ago

KingofLong commented 9 months ago

Wrong rotation output of box annotations in exporting to YOLO format The output of exporting rotated box from Label-Studio format json to YOLO format is wrong.

To Reproduce Steps to reproduce the behavior:

  1. Prepare an annotation with rect labels , at least one of the box annotations need to have 90 degree rotation.
  2. Export the annotation to YOLO format using botton on web page.
  3. Check the format annotation txt. I found out this error when I try to reformate the YOLO labels and import them into Label-Studio to recheck labels.

Expected behavior This is the original annotation.

          "original_width": 1280,
          "original_height": 720,
          "image_rotation": 0,
          "value": {
            "x": 43.11703266917582,
            "y": 84.45982849200068,
            "width": 2.306614434971254,
            "height": 2.5411620388151044,
            "rotation": 90.16978361018573,
            "rectanglelabels": [
              "jyz"
            ]
          }

I compared 2 annotations that have nearly 100% IoU in json format label and exported YOLO label, the data is calculated in Excel. The final 6 columns shows the different. Only the YOLO output of rotate box is wrong. <html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">

  | x_center | y_center | w_norm | h_norm | rotate angle | x1 | y1 | w | h | wpix | hpix | x1pix | y1pix | x2pix | y2pix | actual x1 | actual y1 | actual x2 | actual y2 | actual w | actual h -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- Label-Studio json label1 (X1 Y1 W H) |   |   |   |   | 90 | 43.11703267 | 84.45983 | 2.306614 | 2.541162 | 1280 | 720 | 551.898 | 608.1108 | 533.6017 | 637.6354 | 41.68763 | 84.45983 | 43.11703 | 88.56048 | 1.429404 | 4.100648 Label-Studio json label2 (X1 Y1 W H) |   |   |   |   | 0 | 41.68144192 | 84.43197 | 1.434949 | 4.081633 | 1280 | 720 | 533.5225 | 607.9102 | 551.8898 | 637.298 | 41.68144 | 84.43197 | 43.11639 | 88.51361 | 1.434949 | 4.081633 Label-Studio YOLO label1 (X_CENTER Y_CENTER W H) | 0.41843 | 0.856094 | 0.02548 | 0.023141 | 0 | 40.56904665 | 84.4523 | 2.547986 | 2.314134 | 1280 | 720 | 519.2838 | 608.0565 | 551.898 | 624.7183 | 40.56905 | 84.4523 | 43.11703 | 86.76643 | 2.547986 | 2.314134 Label-Studio YOLO label2 (X_CENTER Y_CENTER W H) | 0.423989 | 0.864728 | 0.014349 | 0.040816 | 0 | 41.68144192 | 84.43197 | 1.434949 | 4.081633 | 1280 | 720 | 533.5225 | 607.9102 | 551.8898 | 637.298 | 41.68144 | 84.43197 | 43.11639 | 88.51361 | 1.434949 | 4.081633 json Label1 transfromed to 0 degree (central rotation) |   |   |   |   | 0 | 41.68762902 | 84.45983 | 1.429404 | 4.100648 | 1280 | 720 | 533.6017 | 608.1108 | 551.898 | 637.6354 | 41.68763 | 84.45983 | 43.11703 | 88.56048 | 1.429404 | 4.100648

Environment (please complete the following information):

Additional context I see that 1.10.0.post0 didn't fix this.

I reproduced the wrong result by hand calculation, the reason is didn't take width and height into calculation.

hogepodge commented 8 months ago

Thanks for reporting this @KingofLong. I've created a ticket for the team to triage this, and we'll report back on the status.