Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tf.keras.layers.UpSampling2D(interpolation='bilinear') has a smearing defect on the right & bottom edges #29856

Closed
mindlapse opened this issue Jun 17, 2019 · 3 comments
Assignees
Labels
comp:keras Keras related issues stat:awaiting tensorflower Status - Awaiting response from tensorflower TF 2.0 Issues relating to TensorFlow 2.0 type:bug Bug

Comments

@mindlapse
Copy link

Please make sure that this is a bug. As per our GitHub Policy, we only address code/doc bugs, performance issues, feature requests and build/installation issues on GitHub. tag:bug_template

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): I've provided a link to a Colab notebook demonstrating the issue below, comparing keras upsampling to what it should look like with a correct implementation as seen in tf.image.resize.
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Google Colab
  • Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device:
  • TensorFlow installed from (source or binary): binary
  • TensorFlow version (use command below): v2.0.0-beta0-16-g1d91213fe7
  • Python version: 3
  • Bazel version (if compiling from source): n/a
  • GCC/Compiler version (if compiling from source): n/a
  • CUDA/cuDNN version: n/a
  • GPU model and memory: n/a

You can collect some of this information using our environment capture
script
You can also obtain the TensorFlow version with: 1. TF 1.0: python -c "import tensorflow as tf; print(tf.GIT_VERSION, tf.VERSION)" 2. TF 2.0: python -c "import tensorflow as tf; print(tf.version.GIT_VERSION, tf.version.VERSION)"

Describe the current behavior
Upsampling using tf.keras.layers.UpSampling2D() results in unnatural smearing of the right and bottom edges of the image. This problem is amplified when the upsampling is repeated.

Describe the expected behavior
Keras layers should use sensible default behaviour and not have this smearing issue. This causes serious problems for autoencoders, GANs, and cost months of time. Correct behaviour is seen with tf.image.resize(o, size=size, method=tf.image.ResizeMethod.BILINEAR). Keras upsampling should use this as the default instead of the current defective behaviour. Note: In TensorFlow 1.x, the tf.image.resize method had an 'align_corners' parameter that toggled between defective and proper behaviour and was set to False (defective behaviour) by default. In TensorFlow 2, this parameter has been removed and the correct behaviour (align_corners=True behaviour) is now the default. The keras layer should follow the same path.

Code to reproduce the issue
Here is a Colab notebook that demonstrates the issue:
https://colab.research.google.com/drive/1rgCzJcMo4DN_9_hutr9l2vSrTRPfcd6K

Other info / logs

@veqtor
Copy link

veqtor commented Jun 17, 2019

Actually, I think it's even worse than that, it seems bilinear doesn't work
https://colab.research.google.com/drive/1BG1gRC86Hj9CqyLTD9quyW0vtNJWZK3j

@achandraa achandraa self-assigned this Jun 18, 2019
@achandraa achandraa added 2.0.0-beta0 comp:keras Keras related issues type:bug Bug labels Jun 18, 2019
@achandraa
Copy link

Have tried with code snippet provided and was able to reproduce the issue on Colab with TensorFlow version 2.0beta.

@jvishnuvardhan jvishnuvardhan added the stat:awaiting tensorflower Status - Awaiting response from tensorflower label Jun 24, 2019
@tensorflow-bot
Copy link

Are you satisfied with the resolution of your issue?
Yes
No

@lvenugopalan lvenugopalan added the TF 2.0 Issues relating to TensorFlow 2.0 label Apr 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:keras Keras related issues stat:awaiting tensorflower Status - Awaiting response from tensorflower TF 2.0 Issues relating to TensorFlow 2.0 type:bug Bug
Projects
None yet
Development

No branches or pull requests

6 participants