import tensorflow as tf import keras from keras.src import ops
keras.backend.set_image_data_format('channels_first')
x = tf.zeros((3, 12, 224, 224))
output_upsampling_layer = keras.layers.UpSampling2D(size=(2, 2), interpolation="bilinear")(x) output_bilinear_resize_only = ops.image.resize(x, (448, 448), interpolation="bilinear")
results in: output_upsampling_layer shape: (3, 448, 224, 448) output_bilinear_resize_only shape (3, 12, 448, 448)
Comment From: tristandb8
To my understanding, the problem is that keras is still set to channels_first when x = ops.image.resize(x, new_shape, interpolation=interpolation) is called, but you transposed it to channels_last before calling that line
Comment From: dhantule
Hi @tristandb8, thanks for reporting this.
I have tested your code, it seems like we get inconsistent shapes when interpolation
is set to anything other than "nearest"
as you can see in this gist. We'll look into this and update you.
Comment From: tripathi-genius
Is it open for contribution? I would like to contribute.
Comment From: dhantule
Is it open for contribution? I would like to contribute.
@tripathi-genius, sure feel free to raise a PR with a fix
Comment From: tristandb8
I've created a PR for this issue https://github.com/keras-team/keras/pull/21439