labelImg
labelImg copied to clipboard
AttributeError: 'NoneType' object has no attribute 'encode'
There is a problem with the automatic saving of this software, which results in that occasionally a label does not save the label name after marking the label, but only saves the label coordinates. Opening the image again will crash because there is no tag name.
xml:
<object>
<name>No_SafeHat</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>397</xmin>
<ymin>67</ymin>
<xmax>444</xmax>
<ymax>121</ymax>
</bndbox>
</object>
<object>
<name/>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>163</xmin>
<ymin>80</ymin>
<xmax>206</xmax>
<ymax>134</ymax>
</bndbox>
</object>
Traceback:
Traceback (most recent call last):
File "labelImg.py", line 1397, in open_prev_image
self.load_file(filename)
File "labelImg.py", line 1159, in load_file
self.show_bounding_box_from_annotation_file(file_path)
File "labelImg.py", line 1190, in show_bounding_box_from_annotation_file
self.load_pascal_xml_by_filename(xml_path)
File "labelImg.py", line 1606, in load_pascal_xml_by_filename
self.load_labels(shapes)
File "labelImg.py", line 857, in load_labels
shape.line_color = generate_color_by_text(label)
File "/Users/~/labelImg-master/libs/utils.py", line 84, in generate_color_by_text
hash_code = int(hashlib.sha256(s.encode('utf-8')).hexdigest(), 16)
AttributeError: 'NoneType' object has no attribute 'encode'
zsh: abort python labelImg.py
- Mac OS
- PyQt 5.15