[BUG] Float coordinate cause error (ValueError: invalid literal for int() with base 10)
Closed this issue · 3 comments
chAwater commented
Float in the coordinate will cause error:
Traceback (most recent call last):
File "voc2coco.py", line 154, in <module>
convert(xml_files, args.json_file)
File "voc2coco.py", line 109, in convert
ymin = int(get_and_check(bndbox, "ymin", 1).text) - 1
ValueError: invalid literal for int() with base 10: '281.70000076293945'
Code:
Lines 108 to 111 in 207f265
Not sure:
- it is a general problem or not
- why there are float in my VOC2012 dataset
Check float in xml files:
grep '<ymin>[0-9].*\.' $VOC_PATH/Annotations/*.xml | head
# In general
grep '<[xy]m[ia][nx]>[0-9]\{0,4\}\.' $VOC_PATH/Annotations/*.xml | head
Result:
$VOC_PATH/Annotations/2011_003353.xml: <ymin>45.70000076293945</ymin>
$VOC_PATH/Annotations/2011_006777.xml: <ymin>281.70000076293945</ymin>
BTW: Great code and blogs! It helps me a lot!
Mattis95 commented
I got the same issue. Generally speaking there shouldn't be floats in VOC files. I got floats, because i got my VOC files from converting yolo annotations to VOC. So I went back and rounded to a whole number while converting from yolo to VOC. That fixed it for me
Pluto1314 commented