models icon indicating copy to clipboard operation
models copied to clipboard

NameError: name 'unicode' is not defined in object_detection/utils/object_detection_evaluation.py

Open schen119 opened this issue 8 years ago • 7 comments

@pkulzc I ran the legacy/eval.py and the error shows up NameError: name 'unicode' is not defined in object_detection/utils/object_detection_evaluation.py, line 332

try:
    category_name = unicode(category_name, 'utf-8')
except TypeError:
    pass

The Python3 doesn't have the type unicode anymore and it has been renamed to str. Is there any better way to avoid this error? Most people work in Python 3, it's great to be compatible with python 3.

schen119 avatar Aug 29 '18 23:08 schen119

https://github.com/tensorflow/models/issues/4982#issuecomment-410062174

pkulzc avatar Aug 29 '18 23:08 pkulzc

@jillelajitta It's better to ask this question on StackOverflow. Adding more class increase the conv nodes in detection head, so it should be slower.

pkulzc avatar Aug 29 '18 23:08 pkulzc

anyone solute the problem? i am not

kunerer avatar Nov 09 '18 02:11 kunerer

@kunerer As mentioned by pkulzc, You need to replace the unicode by string in the particular line of code mentioned in the error.

Manish-rai21bit avatar Jan 02 '19 19:01 Manish-rai21bit

Python 3 renamed the unicode type to str, the old str type has been replaced by bytes renaming unicode occurrences to str worked for me

omkarvijay5 avatar Feb 06 '19 17:02 omkarvijay5

Write for Python3 item = str(item.encode('utf-8'))

rhimanshu909 avatar Apr 30 '19 23:04 rhimanshu909

just replace unicode(category_name, 'utf-8') to str(category_name.encode('utf-8')) everywhere in the document.

Subodhrai898 avatar Jun 04 '19 05:06 Subodhrai898