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

Created on 30 Aug 2018  路  7Comments  路  Source: tensorflow/models

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

Most helpful comment

All 7 comments

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

anyone solute the problem? i am not

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

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

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

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

Was this page helpful?
0 / 5 - 0 ratings