Skip to content

Commit dcfe009

Browse files
authored
Merge pull request tensorflow#3712 from rzumer/fix-compression
Image encoder: fix binary files parsed as UTF-8
2 parents a7aa25d + a305455 commit dcfe009

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

research/compression/image_encoder/decoder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def main(_):
7171
return
7272

7373
contents = ''
74-
with tf.gfile.FastGFile(FLAGS.input_codes, 'r') as code_file:
74+
with tf.gfile.FastGFile(FLAGS.input_codes, 'rb') as code_file:
7575
contents = code_file.read()
7676
loaded_codes = np.load(io.BytesIO(contents))
7777
assert ['codes', 'shape'] not in loaded_codes.files

research/compression/image_encoder/encoder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def main(_):
5959
print('\n--iteration must be between 0 and 15 inclusive.\n')
6060
return
6161

62-
with tf.gfile.FastGFile(FLAGS.input_image) as input_image:
62+
with tf.gfile.FastGFile(FLAGS.input_image, 'rb') as input_image:
6363
input_image_str = input_image.read()
6464

6565
with tf.Graph().as_default() as graph:

research/compression/image_encoder/msssim.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,9 @@ def main(_):
199199
return
200200

201201
with tf.gfile.FastGFile(FLAGS.original_image) as image_file:
202-
img1_str = image_file.read()
202+
img1_str = image_file.read('rb')
203203
with tf.gfile.FastGFile(FLAGS.compared_image) as image_file:
204-
img2_str = image_file.read()
204+
img2_str = image_file.read('rb')
205205

206206
input_img = tf.placeholder(tf.string)
207207
decoded_image = tf.expand_dims(tf.image.decode_png(input_img, channels=3), 0)

0 commit comments

Comments
 (0)