Unverified Commit dcfe009a authored by Nick Johnston's avatar Nick Johnston Committed by GitHub
Browse files

Merge pull request #3712 from rzumer/fix-compression

Image encoder: fix binary files parsed as UTF-8
parents a7aa25d3 a305455e
...@@ -71,7 +71,7 @@ def main(_): ...@@ -71,7 +71,7 @@ def main(_):
return return
contents = '' contents = ''
with tf.gfile.FastGFile(FLAGS.input_codes, 'r') as code_file: with tf.gfile.FastGFile(FLAGS.input_codes, 'rb') as code_file:
contents = code_file.read() contents = code_file.read()
loaded_codes = np.load(io.BytesIO(contents)) loaded_codes = np.load(io.BytesIO(contents))
assert ['codes', 'shape'] not in loaded_codes.files assert ['codes', 'shape'] not in loaded_codes.files
......
...@@ -59,7 +59,7 @@ def main(_): ...@@ -59,7 +59,7 @@ def main(_):
print('\n--iteration must be between 0 and 15 inclusive.\n') print('\n--iteration must be between 0 and 15 inclusive.\n')
return return
with tf.gfile.FastGFile(FLAGS.input_image) as input_image: with tf.gfile.FastGFile(FLAGS.input_image, 'rb') as input_image:
input_image_str = input_image.read() input_image_str = input_image.read()
with tf.Graph().as_default() as graph: with tf.Graph().as_default() as graph:
......
...@@ -199,9 +199,9 @@ def main(_): ...@@ -199,9 +199,9 @@ def main(_):
return return
with tf.gfile.FastGFile(FLAGS.original_image) as image_file: with tf.gfile.FastGFile(FLAGS.original_image) as image_file:
img1_str = image_file.read() img1_str = image_file.read('rb')
with tf.gfile.FastGFile(FLAGS.compared_image) as image_file: with tf.gfile.FastGFile(FLAGS.compared_image) as image_file:
img2_str = image_file.read() img2_str = image_file.read('rb')
input_img = tf.placeholder(tf.string) input_img = tf.placeholder(tf.string)
decoded_image = tf.expand_dims(tf.image.decode_png(input_img, channels=3), 0) decoded_image = tf.expand_dims(tf.image.decode_png(input_img, channels=3), 0)
......
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