Image Rotation COCO Export for Object Detection

Hi Label Studio experts,

I am new to the field of AI-based software development.
I currently want to train a model for object detection and want to use Lable Studio for this.

My problem is the following:

I have different images in portrait and landscape. These can be easily imported and labeled. The rotation of the images in Label Studio looks good.

The following problem now relates to the export in COCO format.

It seems that the images are either rotated incorrectly or not at all when they are exported. This means that the coordinates of the bounding boxes do not match the image.

I have checked this by inspecting the COCO files. The portrait images seem to be the main problem here, they are also displayed in landscape after the export. However, the coordinates of the bounding boxes were saved in portrait format.

This was caused by the conversion to the TFRecord format. About 30% of the data records were discarded. I then carried out the checks.

Is there a solution for this? Or can only landscape images be labeled in general?

I would prefer a solution as I have already invested a lot of time in labeling the images.

Many thanks in advance !

Best regards
Andreas

Hi, could you share an image and its task + annotation in json format?

Hi makseq, sure here first picture of the annotation.

But it seems that its not possible to upload a JSON File. Any Idea ?

I copy the first lines after the first annotation. It is the picture from above.

{
  "images": [
    {
      "width": 4032,
      "height": 3024,
      "id": 0,
      "file_name": "images\/3fda31ae-IMG_0497.JPG"
    },
    {
      "width": 4032,
      "height": 3024,
      "id": 1,
      "file_name": "images\/7db4a71e-IMG_0500.JPG"
    },
    {
      "width": 4032,
      "height": 3024,
      "id": 2,
      "file_name": "images\/6409f9a3-IMG_0501.JPG"
    },
    {
      "width": 4032,
      "height": 3024,
      "id": 3,
      "file_name": "images\/44599e25-IMG_0503.JPG"
    },
    {
      "width": 4032,
      "height": 3024,
      "id": 4,
      "file_name": "images\/56787320-IMG_0506.JPG"
    },
    {
      "width": 4032,
      "height": 3024,
      "id": 5,
      "file_name": "images\/701db279-IMG_0509.JPG"
    },
    {
      "width": 4032,
      "height": 3024,
      "id": 6,
      "file_name": "images\/7572c077-IMG_0512.JPG"
    },
    {
      "width": 4032,
      "height": 3024,
      "id": 7,
      "file_name": "images\/c2259ef9-IMG_0515.JPG"
    },
    {
      "width": 4032,
      "height": 3024,
      "id": 8,
      "file_name": "images\/508b1a08-IMG_0518.JPG"
    },
    {
      "width": 4032,
      "height": 3024,
      "id": 9,
      "file_name": "images\/da7d087c-IMG_0521.JPG"
    },
    {
      "width": 4032,
      "height": 3024,
      "id": 10,
      "file_name": "images\/1c70db9b-IMG_0629.JPG"
    },
    {
      "width": 4032,
      "height": 3024,
      "id": 11,
      "file_name": "images\/1e12f91c-IMG_0640.JPG"
    },
    {
      "width": 4032,
      "height": 3024,
      "id": 12,
      "file_name": "images\/af3ac0c9-IMG_0670.JPG"
    },
    {
      "width": 4032,
      "height": 3024,
      "id": 13,
      "file_name": "images\/666cb693-IMG_0723.JPG"
    },
    {
      "width": 4032,
      "height": 3024,
      "id": 14,
      "file_name": "images\/60d33a50-IMG_0846.JPG"
    },
    {
      "width": 4032,
      "height": 3024,
      "id": 15,
      "file_name": "images\/0fa99197-IMG_0879.JPG"
    },
    {
      "width": 4032,
      "height": 3024,
      "id": 16,
      "file_name": "images\/e4e408ce-IMG_0997.JPG"
    }
  ],
  "categories": [
    {
      "id": 0,
      "name": "24VDC_Sicherung"
    },
    {
      "id": 1,
      "name": "Beleuchtung"
    },
    {
      "id": 2,
      "name": "Bremschopper"
    },
    {
      "id": 3,
      "name": "Bremsrelais"
    },
    {
      "id": 4,
      "name": "Energiezaehler"
    },
    {
      "id": 5,
      "name": "Frequenzumrichter"
    },
    {
      "id": 6,
      "name": "Hauptschalter"
    },
    {
      "id": 7,
      "name": "Kabelkanal"
    },
    {
      "id": 8,
      "name": "Klemme"
    },
    {
      "id": 9,
      "name": "Leitung"
    },
    {
      "id": 10,
      "name": "Leitungschutzschalter"
    },
    {
      "id": 11,
      "name": "Messwandler"
    },
    {
      "id": 12,
      "name": "Motorschutzschalter"
    },
    {
      "id": 13,
      "name": "NH_Sicherung"
    },
    {
      "id": 14,
      "name": "Netzfilter"
    },
    {
      "id": 15,
      "name": "Netzteil"
    },
    {
      "id": 16,
      "name": "OT_Komponenten"
    },
    {
      "id": 17,
      "name": "PLC"
    },
    {
      "id": 18,
      "name": "RCD_Schutzschalter"
    },
    {
      "id": 19,
      "name": "Relais"
    },
    {
      "id": 20,
      "name": "Safety_Elektronik"
    },
    {
      "id": 21,
      "name": "Schmelzsicherung"
    },
    {
      "id": 22,
      "name": "Schuetz"
    },
    {
      "id": 23,
      "name": "Solid_State_Relais"
    },
    {
      "id": 24,
      "name": "Sonstige_Elektronik"
    },
    {
      "id": 25,
      "name": "Steckdose"
    },
    {
      "id": 26,
      "name": "Stromschiene"
    },
    {
      "id": 27,
      "name": "Trafo"
    }
  ],
  "annotations": [
    {
      "id": 0,
      "image_id": 0,
      "category_id": 17,
      "segmentation": [],
      "bbox": [
        0.0,
        1342.5279299014237,
        2309.6779846659365,
        821.4151150054767
      ],
      "ignore": 0,
      "iscrowd": 0,
      "area": 1897204.4073999878
    },
    {
      "id": 1,
      "image_id": 0,
      "category_id": 8,
      "segmentation": [],
      "bbox": [
        1704.65717415115,
        353.29682365826943,
        189.89704271631993,
        406.29134720700995
      ],
      "ignore": 0,
      "iscrowd": 0,
      "area": 77153.52531584074
    },
    {
      "id": 2,
      "image_id": 0,
      "category_id": 8,
      "segmentation": [],
      "bbox": [
        1293.9496166484118,
        340.04819277108436,
        415.12376779846664,
        437.20481927710847
      ],
      "ignore": 0,
      "iscrowd": 0,
      "area": 181494.11187796094
    },
    {
      "id": 3,
      "image_id": 0,
      "category_id": 8,
      "segmentation": [],
      "bbox": [
        821.4151150054764,
        304.71851040525735,
        503.4479737130338,
        485.7831325301205
      ],
      "ignore": 0,
      "iscrowd": 0,
      "area": 244566.5337362593
    },
    {
      "id": 4,
      "image_id": 0,
      "category_id": 10,
      "segmentation": [],
      "bbox": [
        547.6100766703175,
        203.14567360350495,
        247.3077765607887,
        596.1883899233297
      ],
      "ignore": 0,
      "iscrowd": 0,
      "area": 147442.0251232952
    },
    {
      "id": 5,
      "image_id": 0,
      "category_id": 10,
      "segmentation": [],
      "bbox": [
        170.6012730197394,
        244.87030203950656,
        267.47302518432207,
        561.6933528870763
      ],
      "ignore": 0,
      "iscrowd": 0,
      "area": 150237.82032263128
    },
    {
      "id": 6,
      "image_id": 0,
      "category_id": 10,
      "segmentation": [],
      "bbox": [
        61.286210553103366,
        228.58933528915657,
        159.32088891413966,
        503.5470430643976
      ],
      "ignore": 0,
      "iscrowd": 0,
      "area": 80225.56251110639
    },
    {
      "id": 7,
      "image_id": 0,
      "category_id": 7,
      "segmentation": [],
      "bbox": [
        4.120389391030982,
        859.1011880299598,
        3019.8796106089694,
        496.5069216192334
      ],
      "ignore": 0,
      "iscrowd": 0,
      "area": 1499391.1291241487
    },
    {
      "id": 8,
      "image_id": 0,
      "category_id": 20,
      "segmentation": [],
      "bbox": [
        473.33398789529485,
        3283.7622745572635,
        263.90923785529026,
        675.9481769583879
      ],
      "ignore": 0,
      "iscrowd": 0,
      "area": 178388.96821076103
    },
    {
      "id": 9,
      "image_id": 0,
      "category_id": 20,
      "segmentation": [],
      "bbox": [
        337.12276835708076,
        3334.8414818840915,
        165.15610369008485,
        684.4613781795266
      ],
      "ignore": 0,
      "iscrowd": 0,
      "area": 113042.97434647627
    },
    {
      "id": 10,
      "image_id": 0,
      "category_id": 20,
      "segmentation": [],
      "bbox": [
        223.04587199382627,
        3360.381085547508,
        160.0481829574018,
        641.8953720738341
      ],
      "ignore": 0,
      "iscrowd": 0,
      "area": 102734.1879491825
    },
    {
      "id": 11,
      "image_id": 0,
      "category_id": 20,
      "segmentation": [],
      "bbox": [
        2.4928355815737446,
        3291.6278322725975,
        246.79072257580074,
        740.3721677274024
      ],
      "ignore": 0,
      "iscrowd": 0,
      "area": 182716.98224845759
    },
    {
      "id": 12,
      "image_id": 0,
      "category_id": 22,
      "segmentation": [],
      "bbox": [
        1307.627707566858,
        3284.242800477285,
        248.5854756572411,
        403.5257378819596
      ],
      "ignore": 0,
      "iscrowd": 0,
      "area": 100310.63749132612
    },
    {
      "id": 13,
      "image_id": 0,
      "category_id": 22,
      "segmentation": [],
      "bbox": [
        1535.7815002933667,
        3285.945440721513,
        255.39603663415176,
        412.03893910309836
      ],
      "ignore": 0,
      "iscrowd": 0,
      "area": 105233.11198587193
    },
    {
      "id": 14,
      "image_id": 0,
      "category_id": 22,
      "segmentation": [],
      "bbox": [
        1789.4748966832908,
        3294.4586419426514,
        240.07227443610273,
        401.8230976377317
      ],
      "ignore": 0,
      "iscrowd": 0,
      "area": 96466.58497085042
    },
    {
      "id": 15,
      "image_id": 0,
      "category_id": 22,
      "segmentation": [],
      "bbox": [
        2015.926049165572,
        3263.8111175465533,
        263.9092378552907,
        466.523426918384
      ],
      "ignore": 0,
      "iscrowd": 0,
      "area": 123119.84203966914
    },
    {
      "id": 16,
      "image_id": 0,
      "category_id": 22,
      "segmentation": [],
      "bbox": [
        2252.5930431132197,
        3285.945440721513,
        248.5854756572411,
        403.52573788195906
      ],
      "ignore": 0,
      "iscrowd": 0,
      "area": 100310.63749132598
    },
    {
      "id": 17,
      "image_id": 0,
      "category_id": 22,
      "segmentation": [],
      "bbox": [
        2477.341555351273,
        3291.053361454195,
        270.71979883220075,
        401.8230976377323
      ],
      "ignore": 0,
      "iscrowd": 0,
      "area": 108781.46815861865
    },
    {
      "id": 18,
      "image_id": 0,
      "category_id": 7,
      "segmentation": [],
      "bbox": [
        29.46078414587153,
        2565.7594352016245,
        2994.5392158541285,
        623.2088953934361
      ],
      "ignore": 0,
      "iscrowd": 0,
      "area": 1866223.476924778
    },
    {
      "id": 19,
      "image_id": 0,
      "category_id": 9,
      "segmentation": [],
      "bbox": [
        713.5765263558202,
        2238.605064965328,
        161.0697671039383,
        337.1227683570809
      ],
      "ignore": 0,
      "iscrowd": 0,
      "area": 54300.28578470995
    },
    {
      "id": 20,
      "image_id": 0,
      "category_id": 9,
      "segmentation": [],
      "bbox": [
        2850.5602968859794,
        2204.8927881296204,
        123.61168173092936,
        361.47052384953616
      ],
      "ignore": 0,
      "iscrowd": 0,
      "area": 44681.979349201174
    },
    {
      "id": 21,
      "image_id": 0,
      "category_id": 9,
      "segmentation": [],
      "bbox": [
        1239.8626258465956,
        2300.410905830793,
        185.41752259639424,
        294.04597017812006
      ],
      "ignore": 0,
      "iscrowd": 0,
      "area": 54521.27531988024
    },
    {
      "id": 22,
      "image_id": 0,
      "category_id": 24,
      "segmentation": [],
      "bbox": [
        787.4086994566134,
        3335.1081753059952,
        165.7702525171816,
        551.186089619629
      ],
      "ignore": 0,
      "iscrowd": 0,
      "area": 91370.25726020378
    },
    {
      "id": 23,
      "image_id": 0,
      "category_id": 24,
      "segmentation": [],
      "bbox": [
        1089.9394103004697,
        3321.2939875962306,
        161.6259962042521,
        570.5259524132997
      ],
      "ignore": 0,
      "iscrowd": 0,
      "area": 92211.82541917928
    },
    {
      "id": 24,
      "image_id": 0,
      "category_id": 24,
      "segmentation": [],
      "bbox": [
        954.5603707447714,
        3306.098381115488,
        129.85336447179236,
        589.8658152069715
      ],
      "ignore": 0,
      "iscrowd": 0,
      "area": 76596.0606915218
    },

Thanks !

I am sorry, I meant JSON in native LS format.

[
  {
    "id": 525,
    "annotations": [
      {
        "id": 533,
        "completed_by": 1,
        "result": [
          {
            "original_width": 3024,
            "original_height": 4032,
            "image_rotation": 0,
            "value": {
              "x": 0.2606712284131639,
              "y": 33.49232707957931,
              "width": 76.37824023366193,
              "height": 20.372398685651703,
              "rotation": 0,
              "rectanglelabels": [
                "PLC"
              ]
            },
            "id": "wMmj_feV4v",
            "from_name": "label",
            "to_name": "image",
            "type": "rectanglelabels",
            "origin": "manual"
          },
          {
            "original_width": 3024,
            "original_height": 4032,
            "image_rotation": 0,
            "value": {
              "x": 57.126009995584134,
              "y": 8.762322015334064,
              "width": 5.524592414054469,
              "height": 10.076670317634177,
              "rotation": 0,
              "rectanglelabels": [
                "Klemme"
              ]
            },
            "id": "rqI9aXo7F7",
            "from_name": "label",
            "to_name": "image",
            "type": "rectanglelabels",
            "origin": "manual"
          },
          {
            "original_width": 3024,
            "original_height": 4032,
            "image_rotation": 0,
            "value": {
              "x": 44.22397539905784,
              "y": 8.433734939759034,
              "width": 12.293001599846926,
              "height": 10.843373493975902,
              "rotation": 0,
              "rectanglelabels": [
                "Klemme"
              ]
            },
            "id": "suYotT_tRM",
            "from_name": "label",
            "to_name": "image",
            "type": "rectanglelabels",
            "origin": "manual"
          }
        ]
      }
    ]
  }
]
1 Like

It’s weird.

In coco json I see:

  "width": 4032,
  "height": 3024,

in LS JSON:

  "original_width": 3024,
  "original_height": 4032,

if I download your image, I see that it has

width = 1920
height = 2560

So, could you send this image again? but please zip it to avoid any compressions made by this forum engine.

Hi makseq,

i want to upload the compressed picture. But the forum engine says it is not possible to upload a attachment because i´m a new user …

is there a other way to upload the picture ?
for quick review i made a snapshot from the properties of the picture.

Hi Max,

are there any news on this ?

Andreas