I wanted to assign unicode strings to my bounding boxes. I can enter my strings to the text box in UI and is being rendered correctly. But upon save it throws an error.
Traceback (most recent call last):
File "./labelImg.py", line 945, in saveFile
else self.saveFileDialog())
File "./labelImg.py", line 968, in _saveFile
if filename and self.saveLabels(filename):
File "./labelImg.py", line 589, in saveLabels
self.lineColor.getRgb(), self.fillColor.getRgb())
File "libs/labelFile.py", line 46, in savePascalVocFormat
writer.save(targetFile = filename)
File "libs/pascal_voc_io.py", line 96, in save
self.appendObjects(root)
File "libs/pascal_voc_io.py", line 77, in appendObjects
name.text = str(each_object['name'])
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-10: ordinal not in range(128)
I tried to fix it by the way the string is encoded before being written to xml. But the best I could get was a sequence of unicode points like this written to the xml in place of the actual unicode string.
<name>വിക്കിപീഡിയ</name>
An enhancement to support unicode strings would of great help for all who want to assign labels in languages other than English
@mineshmathew try the latest version
thank you. it works now
@rflynn sorry to tag you again. The issue with unicode is still there.
LIke I pointed out in the first post, though the label is rendered correctly in the tool, the xml saves shows the label as a string of unicode points.
For example, for the Chinese word 中华人民共和国,
what I see in xml is this
<name>中华人民共和国</name>
@mineshmathew ,
Can you share us with the filename and the file? We can put the file to https://github.com/tzutalin/labelImg/tree/master/tests, we can test it whenever there are new changes.
the image i used is one of the icons that comes with the code - /icons/delete.png
I am attaching the xml generated upon assigning the label 中华人民共和国 to some bounding box I drew
delete.txt
Hello, @rflynn, @mineshmathew forwarded this to me. I took a look at your branch corresponding to this issue. The last bit was failing, due to python2 open's ascii codec issues. Since this is python2, I've worked up a solution using codecs, where it was failing.
@jerinphilip thanks a lot. it works now
@jerinphilip ,
Thanks. I applied your patch to master branch.
https://github.com/tzutalin/labelImg/commit/1fb28d81a7bcfcf3fbeeb6f7ecd1fa629dfe4243
@tzutalin: My patch alone wouldn't be enough, I'm guessing. I believe the changes @rflynn was trying to implement are also necessary. My patch is on top of @rflynn's branch corresponding to the repo.
Most helpful comment
@mineshmathew try the latest version