Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Marryli opened this issue May 18, 2017 · 10 comments
Open

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

Marryli opened this issue May 18, 2017 · 10 comments

Comments

@Marryli
Copy link

Marryli commented May 18, 2017

No description provided.

@riadhayachi
Copy link

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

@djdam
Copy link

djdam commented May 20, 2017

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

@jcyl
Copy link

jcyl commented Aug 11, 2017

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
Copy link

jcyl commented Aug 11, 2017

can anyone help me?thanks in advance

@riadhayachi
Copy link

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

@wuyuzaizai
Copy link

@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
Copy link

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

@jzyztzn
Copy link

jzyztzn commented Mar 3, 2018

@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
Copy link

imranfateh commented May 7, 2018

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
Copy link

Hello,
To resolve this problem you have to either:

  • add a difficult score in your XML files,
  • or and the simplest is to comment out in the code from voc_eval.py the line where obj_struct['X'] (Whatever X is, in your case it is 'difficult') appears, so the program won't consider this label when reading the xml files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants