HumanSignal / labelImg

LabelImg is now part of the Label Studio community. The popular image annotation tool created by Tzutalin is no longer actively being developed, but you can check out Label Studio, the open source data labeling tool for images, text, hypertext, audio, video and time-series data.
https://youtu.be/p0nR2YsCY_U
MIT License
22.62k stars 6.29k forks source link

Cannot save xml file on Ubuntu 16.04 #391

Closed JasonLiu-TJU closed 5 years ago

JasonLiu-TJU commented 5 years ago

I am trying to save the annotation files into xml file. But each time the following error code occurs:

Traceback (most recent call last): File "labelImg.py", line 1291, in saveFile self._saveFile(savedPath) File "labelImg.py", line 1320, in _saveFile if annotationFilePath and self.saveLabels(annotationFilePath): File "labelImg.py", line 802, in saveLabels self.lineColor.getRgb(), self.fillColor.getRgb()) File "/home/lj/workspace/Tools/labelImg/libs/labelFile.py", line 56, in savePascalVocFormat writer.save(targetFile=filename) File "/home/lj/workspace/Tools/labelImg/libs/pascal_voc_io.py", line 121, in save prettifyResult = self.prettify(root) File "/home/lj/workspace/Tools/labelImg/libs/pascal_voc_io.py", line 28, in prettify rough_string = ElementTree.tostring(elem, 'utf8') File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1126, in tostring ElementTree(element).write(file, encoding, method=method) File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 820, in write serialize(write, self._root, encoding, qnames, namespaces) File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 939, in _serialize_xml _serialize_xml(write, e, encoding, qnames, None) File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 939, in _serialize_xml _serialize_xml(write, e, encoding, qnames, None) File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 937, in _serialize_xml write(_escape_cdata(text, encoding)) File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1075, in _escape_cdata _raise_serialization_error(text) File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1052, in _raise_serialization_error "cannot serialize %r (type %s)" % (text, type(text).__name__) TypeError: cannot serialize PyQt4.QtCore.QString(u'Hardshell crabs') (type QString)

Thanks and best regars

zhengyuezhi commented 5 years ago

I also encountered the same problem

philips commented 5 years ago

me too on debian stretch :(

tzutalin commented 5 years ago

Thanks for reporting. I will check this

tzutalin commented 5 years ago

Sorry for the inconvenience. Fixed already https://github.com/tzutalin/labelImg/commit/2df7b6e402d1b4dd4a6481afaf0ad7961609c8f1