lundi 29 mai 2017

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

I'm trying to run a python file, but I get this error:

  File "/home/hadi/Software/tensorflow/TEST_FRCN_ROOT/tools/../lib/datasets/pascal_voc.py", line 212, in _load_pascal_annotation
    cls = self._class_to_ind[obj.find('name').text.lower().strip()]
AttributeError: 'NoneType' object has no attribute 'lower'

This is the part of the code which makes the error:

%%  Load object bounding boxes into a data frame.
        for ix, obj in enumerate(objs):
            bbox = obj.find('bndbox')
            # Make pixel indexes 0-based
            x1 = float(bbox.find('xmin').text) - 1
            y1 = float(bbox.find('ymin').text) - 1
            x2 = float(bbox.find('xmax').text) - 1
            y2 = float(bbox.find('ymax').text) - 1
            cls = self._class_to_ind[obj.find('name').text.lower().strip()]
            boxes[ix, :] = [x1, y1, x2, y2]
            gt_classes[ix] = cls
            overlaps[ix, cls] = 1.0
            seg_areas[ix] = (x2 - x1 + 1) * (y2 - y1 + 1)

Can I add a condition to deal with any none object here?

Aucun commentaire:

Enregistrer un commentaire