4

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: enter image description here

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?

TAN
  • 41
  • 3

2 Answers2

0

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.

Roy Lee
  • 329
  • 1
  • 2
  • 12
-1

Check your annotations, there must be few XML files in which width or height attribute would be 0. Rectify those.

Vinit
  • 1