rbgirshick / py-faster-rcnn

Faster R-CNN (Python implementation) -- see https://github.com/ShaoqingRen/faster_rcnn for the official MATLAB version
Other
8.12k stars 4.11k forks source link

AttributeError:“NoneType ” object has no attribute 'text' #580

Open Marryli opened 7 years ago

riadhayachi commented 7 years ago

i get the same error but i do not have any idea what it means

djdam commented 7 years ago

Do you have a line number where the error occurs in the code?

jcyl commented 7 years ago

File "/home/jwh/project/py-faster-rcnn/tools/../lib/datasets/pascal_voc.py", line 193, in _load_pascal_annotation obj for obj in objs if int(obj.find('difficult').text) == 0] AttributeError: 'NoneType' object has no attribute 'text'

jcyl commented 7 years ago

can anyone help me?thanks in advance

riadhayachi commented 7 years ago

i think you need to add import this "import google.protobuf.text_format" it may fix the problem

wuyuzaizai commented 7 years ago

@jcyl is your problem solved? i met the same problem, i fix the problem by delete the codes in voc_eval.py. the reason is your xml file, i guess your xml were generated by yourself, and there was no 'difficult' node

Marcus208 commented 7 years ago

@wuyuzaizai What codes did you delete in voc_eval.py? Thanks in advance.

jzyztzn commented 6 years ago

@Marcus208 i get the same error as below

    obj_struct['pose'] = obj.find('pose').text
    AttributeError: 'NoneType' object has no attribute 'text'

And i fix the problem by comment out two lines in the function parse_rec() of voc_eval.py

def parse_rec(filename):
    """ Parse a PASCAL VOC xml file """
    tree = ET.parse(filename)
    objects = []
    for obj in tree.findall('object'):
        obj_struct = {}
        obj_struct['name'] = obj.find('name').text
        # obj_struct['pose'] = obj.find('pose').text
        # obj_struct['truncated'] = int(obj.find('truncated').text)
        obj_struct['difficult'] = int(obj.find('difficult').text)
        bbox = obj.find('bndbox')
        obj_struct['bbox'] = [int(bbox.find('xmin').text),
                              int(bbox.find('ymin').text),
                              int(bbox.find('xmax').text),
                              int(bbox.find('ymax').text)]
        objects.append(obj_struct)
    return objects
imranfateh commented 6 years ago

I have same error ./lib/datasets/icdar_str.py", line 170, in _load_pascal_annotation obj for obj in objs if int(obj.find('difficult').text) == 0] AttributeError: 'NoneType' object has no attribute 'text'

still not resolved tried all the above options.

Thanks in advance

UndecidedBoy commented 6 years ago

Hello, To resolve this problem you have to either: