This repository has been archived by the owner on Feb 29, 2024. It is now read-only.
Fix rounding issue that caused 1px box shift for YOLO format #730
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #729
Rounding issue caused box to shift by 1px from where it was placed.
Will be saved as
0 0.122596 0.184745 0.216346 0.294915
by this line:https://github.com/tzutalin/labelImg/blob/3425fefd8de8ce0a00cd589f5572190f80be52b0/libs/yolo_io.py#L72
After reading the file and converting back to box:
Because of truncation to 6 digits after the decimal point some accuracy loss happens.
x_min = (x_center - w / 2) * img_w = 5.999967999999996
The result get truncated by the following code:
https://github.com/tzutalin/labelImg/blob/3425fefd8de8ce0a00cd589f5572190f80be52b0/libs/yolo_io.py#L132
To fix the issue result should be rounded to the nearest integer.
https://github.com/Ledorub/labelImg/blob/76d4638aa87fc546925e4ebee037fefe744729f8/libs/yolo_io.py#L132-L135