ssaru / convert2Yolo

This project purpose is convert voc annotation xml file to yolo-darknet training file format
458 stars 182 forks source link

Error in VOC Parsing #16

Open ilyasmg opened 5 years ago

ilyasmg commented 5 years ago

I'm converting this dataset (https://www.di.ens.fr/willow/research/headdetection/) from xml to txt to use it in YOLO but I'm getting this error. VOC Parsing Result : False, msg : ERROR : 'NoneType' object has no attribute 'text', moreInfo : <class 'AttributeError'> Format.py 258

this is line 258 in Format.py tmp = { "name": _object.find("name").text }

Do you know how to solve it?

7thstorm commented 5 years ago

I think one or more of your XML files is missing the tag...

fakturk commented 5 years ago

you have to check your xml file and tags in that xml file. For example I got my xml files from labelbox.com (as a voc format) and every object has instead of bndbox and x1,y1,x2,y2 instead of xmin,ymin,xmax,ymax. So I chaged code from line 261 on Format.py as

                xml_bndbox = _object.find("polygon")
                bndbox = {
                    "xmin": float(xml_bndbox.find("x1").text), 
                    "ymin": float(xml_bndbox.find("y1").text), 
                    "xmax": float(xml_bndbox.find("x2").text),
                    "ymax": float(xml_bndbox.find("y2").text)
                }
Alzheimancer commented 5 years ago

I also got my xml file from labelbox as voc format but I have both bndbox and polygon. Moreover, some xml files have x1 x2 x3 x4 y1 y2 y3 y4. I dont know how todeal with it.