Commit 6ab25864 authored by Yuxin Wu's avatar Yuxin Wu Committed by Karmel Allison
Browse files

Update build_imagenet_data.py (#3112)

parent 331e1372
...@@ -170,6 +170,8 @@ def _float_feature(value): ...@@ -170,6 +170,8 @@ def _float_feature(value):
def _bytes_feature(value): def _bytes_feature(value):
"""Wrapper for inserting bytes features into Example proto.""" """Wrapper for inserting bytes features into Example proto."""
if isinstance(value, six.string_types):
value = six.binary_type(value, encoding='utf-8')
return tf.train.Feature(bytes_list=tf.train.BytesList(value=[value])) return tf.train.Feature(bytes_list=tf.train.BytesList(value=[value]))
...@@ -312,7 +314,7 @@ def _process_image(filename, coder): ...@@ -312,7 +314,7 @@ def _process_image(filename, coder):
width: integer, image width in pixels. width: integer, image width in pixels.
""" """
# Read the image file. # Read the image file.
with tf.gfile.FastGFile(filename, 'r') as f: with tf.gfile.FastGFile(filename, 'rb') as f:
image_data = f.read() image_data = f.read()
# Clean the dirty data. # Clean the dirty data.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment