tf.keras.layers.UpSampling2D(interpolation='bilinear') has a smearing defect on the right & bottom edges #29856
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
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
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
The text was updated successfully, but these errors were encountered: