Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Enhancement Request- Support for Unicode labels #31

Closed
mineshmathew opened this issue Dec 14, 2016 · 10 comments
Closed

Enhancement Request- Support for Unicode labels #31

mineshmathew opened this issue Dec 14, 2016 · 10 comments

Comments

@mineshmathew
Copy link

mineshmathew commented Dec 14, 2016

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>&#3381;&#3391;&#3349;&#3405;&#3349;&#3391;&#3370;&#3392;&#3361;&#3391;&#3375;</name>

An enhancement to support unicode strings would of great help for all who want to assign labels in languages other than English

rflynn added a commit to rflynn/labelImg that referenced this issue Dec 22, 2016
tzutalin added a commit that referenced this issue Dec 22, 2016
@rflynn
Copy link
Contributor

rflynn commented Dec 23, 2016

@mineshmathew try the latest version

@mineshmathew
Copy link
Author

thank you. it works now

@mineshmathew
Copy link
Author

@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>&#20013;&#21326;&#20154;&#27665;&#20849;&#21644;&#22269;</name>

@tzutalin
Copy link
Contributor

tzutalin commented Jan 4, 2017

@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.

@mineshmathew
Copy link
Author

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

rflynn added a commit to rflynn/labelImg that referenced this issue Jan 16, 2017
rflynn added a commit to rflynn/labelImg that referenced this issue Jan 16, 2017
rflynn added a commit to rflynn/labelImg that referenced this issue Jan 16, 2017
rflynn added a commit to rflynn/labelImg that referenced this issue Jan 16, 2017
rflynn added a commit to rflynn/labelImg that referenced this issue Jan 16, 2017
@jerinphilip
Copy link

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.

unicode-solution.patch

@mineshmathew
Copy link
Author

@jerinphilip thanks a lot. it works now

@tzutalin
Copy link
Contributor

tzutalin commented Jan 29, 2017

@jerinphilip ,
Thanks. I applied your patch to master branch.
1fb28d8

@jerinphilip
Copy link

@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.

@tzutalin
Copy link
Contributor

Fix 70721ad

arnavkohli added a commit to arnavkohli/labelImg that referenced this issue Apr 16, 2021
arnavkohli added a commit to arnavkohli/labelImg that referenced this issue Apr 16, 2021
phanthanhdat1902 pushed a commit to phanthanhdat1902/labelimgtool that referenced this issue Feb 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants