Change keras.layers.Upsampling2D to use new image resizing function (resize_images_v2). The old resizing function has various bugs (for instance, it was not reflection or translation invariant).
Fixes #29856. PiperOrigin-RevId: 255296104
This commit is contained in:
parent
bb2a1d3ee8
commit
15f6c30d79
@ -2610,9 +2610,11 @@ def resize_images(x, height_factor, width_factor, data_format,
|
|||||||
if data_format == 'channels_first':
|
if data_format == 'channels_first':
|
||||||
x = permute_dimensions(x, [0, 2, 3, 1])
|
x = permute_dimensions(x, [0, 2, 3, 1])
|
||||||
if interpolation == 'nearest':
|
if interpolation == 'nearest':
|
||||||
x = image_ops.resize_nearest_neighbor(x, new_shape)
|
x = image_ops.resize_images_v2(
|
||||||
|
x, new_shape, method=image_ops.ResizeMethod.NEAREST_NEIGHBOR)
|
||||||
elif interpolation == 'bilinear':
|
elif interpolation == 'bilinear':
|
||||||
x = image_ops.resize_bilinear(x, new_shape)
|
x = image_ops.resize_images_v2(x, new_shape,
|
||||||
|
method=image_ops.ResizeMethod.BILINEAR)
|
||||||
else:
|
else:
|
||||||
raise ValueError('interpolation should be one '
|
raise ValueError('interpolation should be one '
|
||||||
'of "nearest" or "bilinear".')
|
'of "nearest" or "bilinear".')
|
||||||
|
@ -1209,7 +1209,7 @@ def resize_images_v2(images,
|
|||||||
`tf.image.resize_with_pad`.
|
`tf.image.resize_with_pad`.
|
||||||
|
|
||||||
When 'antialias' is true, the sampling filter will anti-alias the input image
|
When 'antialias' is true, the sampling filter will anti-alias the input image
|
||||||
as well as interpolate. When downsampling an image with [anti-aliasing](
|
as well as interpolate. When downsampling an image with [anti-aliasing](
|
||||||
https://en.wikipedia.org/wiki/Spatial_anti-aliasing) the sampling filter
|
https://en.wikipedia.org/wiki/Spatial_anti-aliasing) the sampling filter
|
||||||
kernel is scaled in order to properly anti-alias the input image signal.
|
kernel is scaled in order to properly anti-alias the input image signal.
|
||||||
'antialias' has no effect when upsampling an image.
|
'antialias' has no effect when upsampling an image.
|
||||||
|
Loading…
Reference in New Issue
Block a user