Skip to content
This repository has been archived by the owner on Jul 7, 2023. It is now read-only.

Commit

Permalink
Merge pull request #116 from schani/encoding-fixes
Browse files Browse the repository at this point in the history
Encoding fixes
  • Loading branch information
lukaszkaiser authored Jul 7, 2017
2 parents d877e69 + 1d73633 commit fbb6f9a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions tensor2tensor/data_generators/generator_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,13 @@ def to_example(dictionary):
elif isinstance(v[0], float):
features[k] = tf.train.Feature(float_list=tf.train.FloatList(value=v))
elif isinstance(v[0], six.string_types):
v = [bytes(x, 'utf-8') for x in v]
features[k] = tf.train.Feature(bytes_list=tf.train.BytesList(value=v))
elif isinstance(v[0], bytes):
features[k] = tf.train.Feature(bytes_list=tf.train.BytesList(value=v))
else:
raise ValueError("Value is neither an int nor a float; v: %s type: %s" %
(str(v[0]), str(type(v[0]))))
raise ValueError("Value for %s is neither an int nor a float; v: %s type: %s" %
(k, str(v[0]), str(type(v[0]))))
return tf.train.Example(features=tf.train.Features(feature=features))


Expand Down
2 changes: 1 addition & 1 deletion tensor2tensor/data_generators/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def image_generator(images, labels):
yield {
"image/encoded": [enc_string],
"image/format": ["png"],
"image/class/label": [label],
"image/class/label": [int(label)],
"image/height": [height],
"image/width": [width]
}
Expand Down

0 comments on commit fbb6f9a

Please sign in to comment.