The picture turned. Its label stayed put.
Draw a rectangle near the top left of a square sheet of paper. Give someone its position, then turn the sheet a quarter turn clockwise. The sheet is still square. Anyone looking for the rectangle at its old address will miss it.
That happened with one of our test images. An instruction stored in the file told our reader to turn the picture. The label that marked the rectangle’s edges still described the picture as it had been saved. Turning the label along with the picture made it fit again.
We made three PNG pictures. Each contained one rectangle and had a separate label recording its position and size as fractions of the picture’s original width and height. We used Pillow 12.2.0 to apply each file’s orientation instruction. Orientation 1 left the first picture alone. Orientation 6 turned the other two 90 degrees clockwise. Pillow’s orientation operation · How YOLO stores box coordinates
On the square picture, the rectangle moved from near the top left to near the top right. Measured from the top-left corner, its left, top, right and bottom edges went from (10, 8, 30, 20) to (40, 10, 52, 30) pixels. The picture still measured 60 × 60 pixels.
For the table we drew the original label using the displayed width and height. We measured the area the box and rectangle shared, divided by all the area they covered between them. This is intersection over union (IoU). A score of 1 means the box fits exactly. A score of 0 means it misses entirely.
| Fixture | Stored image size | Displayed image size | Box overlap with object, IoU |
|---|---|---|---|
| Orientation 1 control | 100 × 60 | 100 × 60 | 1 |
| Orientation 6, rectangle image | 100 × 60 | 60 × 100 | 0 |
| Orientation 6, square image | 60 × 60 | 60 × 60 | 0 |
The old box fit the unturned rectangle exactly. It missed both rectangles that had moved, including the one in the square picture. We then applied the same turn to the box coordinates and drew them again. Both gave a perfect fit.
If one tool labels your pictures and another reads them, open a few labeled images in the receiving tool and draw their boxes over the pixels it shows. Include a square image with a rotation instruction. Its width and height can both look right while the box sits on the wrong side.