Skip to content

tf silently rounding to integer when converting to PIL format #33089

Closed
@mvuyyuru

Description

@mvuyyuru

System information

  • Have I written custom code: not really, no.
  • OS Platform and Distribution: Linux Ubuntu 18.04.2 LTS (Bionic Beaver)
  • TensorFlow installed from (source or binary): pip install (binary?)
  • TensorFlow version (use command below): 1.14.0
  • Python version: 3.5.2
  • Bazel version (if compiling from source): -
  • GCC/Compiler version (if compiling from source): -
  • CUDA/cuDNN version: - (running on cpu only)
  • GPU model and memory: - (running on cpu only)

Describe the current behavior
When converting to PIL format from array and back, tf silently rounds values to integers. (see https://www.tensorflow.org/api_docs/python/tf/keras/preprocessing/image/array_to_img, https://www.tensorflow.org/api_docs/python/tf/keras/preprocessing/image/img_to_array)

Describe the expected behavior
Throw a warning when silently rounding. maybe convert to float instead of integer if input is a float dtype?

Code to reproduce the issue
please see the short example test case here: https://github.com/WildTangles/tf-issues/blob/master/tensorflow_bug_conversions/bug_demo.ipynb

In particular, see:
cell 4 (random noise image, 4800 unique values) vs.
cell 6 (image after conversion to PIL and back, 256 unique values)

Other info / logs
Happy to provide if necessary.

Metadata

Metadata

Assignees

Labels

TF 1.14for issues seen with TF 1.14comp:kerasKeras related issuestype:bugBug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions