Skip to content

Commit

Permalink
converting unicode to str
Browse files Browse the repository at this point in the history
  • Loading branch information
gvanhorn38 committed Mar 28, 2017
1 parent 61f2efe commit e8fe2b9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions create_tfrecords.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,13 @@ def _bytes_feature(value):

def _validate_text(text):
"""If text is not str or unicode, then try to convert it to str."""
if not isinstance(text, str) or not isinstance(text, unicode):
return str(text)
return text

if isinstance(text, str):
return text
elif isinstance(text, unicode):
return text.encode('utf8', 'ignore')
else
return str(text)

def _convert_to_example(image_example, image_buffer, height, width, colorspace='RGB',
channels=3, image_format='JPEG'):
Expand Down

0 comments on commit e8fe2b9

Please sign in to comment.