Encoding images are slightly different than encoding format for other files

Open
#1,663 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
30/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
python

Research direction

Start with the linked Colab reproduction and compare the bytes produced by the image encoding operation with those written through tf.io.write_file. Check the REST API path described in the issue and establish whether the returned bytes can be written as png, jpeg, bmp, or gif files. Done means the discrepancy is explained and a reproducible correction or documented limitation is identified.

Written by the indexing model from the issue text.

Description

I am trying to write a tensor to a png, jpeg, bmp, or gif. As seen in colab in bottom, when I take the encoded bytes and write it a file using python, it doesn't work. Trying opening the image it gets corrupted
When I use tf.io.write_file it works. I also tried taking a png and using tf.io_decode_png and than tf.io.encoding_png and the image string bytes differ from the original png. I am using tensorflow serving and using this png result through the rest api, where I don't have access to tf.io.write_file so I was wondering what encode_png does differently, than traditional png encodings.

https://www.loom.com/share/4b32b330a0e742cab2ea3a1a9af11b22
https://colab.research.google.com/drive/13Y4ET8jAHZDq7qwUYgg8nuBkxqniUqGu#scrollTo=IcXVZepnhkW4

Dominant language
C++
Stars
739
Forks
311
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from tensorflow/io

All issues in tensorflow/io

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.