Closed tobiapoppi closed 2 years ago
@tobi1modna
Hi, Tobia.
First of all, I'm glad my repository was helpful.
Also, Thanks for your PR. You discovered something I hadn't been able to find.
I think your PR can fix the bug.
After a while, I will merge this PR.
Thanks,
Hi, i'm Tobia. I am a master computer engineering student based in Italy. Thanks for this Yolo/COCO conversion project, it helped me througth my bachelor thesis, and now on my researches.
I wanted to make this pull request after being struggled with a warning coming from a bug, i would call it...
I incurred in the problem during the training of the NN EfficientDet. During the training a Keras UserWarning compared saying that the values of some bounding-boxes were invalid. I run the train with a COCO format dataset obtained by the conversion from a Yolo format dataset, thanks to your python code.
I bring you an example of a bounding box causing these kind of errors: Yolo (original format) -->
[0 0.6775701 0.113559 0.19845 0.2271]
COCO (converted format) -->[369.5 -0.5 496.5 108.5]
In facts, I tried to manually apply formulas of your "main.py" code, and the result is the same.
Here the problem is clear: I have as a result a negative value on the
y_min
value. This will cause an invalid bbox because it would mean which the bbox stands partially outside from the image, which is not possible and it doesn't really match with the Yolo bb format.I think that this problem mainly comes from the way you are computing
x_min, y_min
.Your code:
The values coming from coco bboxes are all explicitly casted to floats and that is ok. The problem comes with the
int
cast in the following 4 formulas.I'll make an example with the above Yolo values. Mi image shape is 480x640.
Here's why the result is -0.5, the previous values are explicitly casted to int, and in python the operator
/
makes an implicit cast to float, so 109 / 2 will result > than 54.In my code i basically removed the int() eplicit cast, and I casted to int after all the conversions. This solved all Keras userWarnings that I've got before! :)