【问题标题】:darkflow - AttributeError: 'NoneType' object has no attribute 'find'darkflow - AttributeError:“NoneType”对象没有属性“find”
【发布时间】:2019-02-04 00:53:44
【问题描述】:

darkflow 和 python 的新手。我正在尝试使用https://github.com/thtrieu/darkflow 和 yolo 权重来训练我自己的数据集。我目前遇到错误:

AttributeError: 'NoneType' object has no attribute 'find'

执行pascal_voc_clean_xml.py时第41行:'w = (imsize.find('width').text)'

这是来自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()

这是我的 xml 文件:

我知道'find'是python中ElementTree.py中的一个函数,但为什么'find'函数不能正常工作?

【问题讨论】:

    标签: python image-processing machine-learning yolo darkflow


    【解决方案1】:

    检查您的注释,必须有少数 XML 文件的宽度或高度属性为 0。纠正这些。

    【讨论】:

    • 另一个答案提出了相同的问题解决方案。
    【解决方案2】:

    检查注释中的数据(图像文件夹)

    for i, file in enumerate(annotations):

    也许 image00001.jpg 的 xml 文件与您的错误代码无关。

    其他一些 xml 文件没有属性 sizewidth

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-06
      • 2019-03-07
      • 2022-01-12
      • 1970-01-01
      • 1970-01-01
      • 2021-12-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多