new to darkflow and python. i am trying to train my own datasets by using https://github.com/thtrieu/darkflow and yolo weights. I'm currently having errors:
AttributeError: 'NoneType' object has no attribute 'find'
when executing pascal_voc_clean_xml.py line 41: 'w = (imsize.find('width').text) '
This is part of the code from https://github.com/thtrieu/darkflow/blob/master/darkflow/utils/pascal_voc_clean_xml.py :
in_file = open(file)
tree=ET.parse(in_file)
root = tree.getroot()
jpg = str(root.find('filename').text)
imsize = root.find('size')
w = int(imsize.find('width').text)
h = int(imsize.find('height').text)
all = list()
for obj in root.iter('object'):
current = list()
name = obj.find('name').text
if name not in pick:
continue
xmlbox = obj.find('bndbox')
xn = int(float(xmlbox.find('xmin').text))
xx = int(float(xmlbox.find('xmax').text))
yn = int(float(xmlbox.find('ymin').text))
yx = int(float(xmlbox.find('ymax').text))
current = [name,xn,yn,xx,yx]
all += [current]
add = [[jpg, [w, h, all]]]
dumps += add
in_file.close()
and this is my xml file:
I know that the 'find' is a function from ElementTree.py in python but why it the 'find' function does not work as it should be?
check your data in annotations(images folder)
for i, file in enumerate(annotations):
Maybe image00001.jpg 's xml file is no matter with your error code.
Some other xml file would not have attribute size
or width
.
检查您的注释,必须有几个 XML 文件的宽度或高度属性为 0。纠正这些。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.