Help protect the Great Barrier Reef with TensorFlow on Kaggle Join Challenge

tf.keras.layers.CenterCrop

A preprocessing layer which crops images.

Inherits From: Layer, Module

This layers crops the central portion of the images to a target size. If an image is smaller than the target size, it will be resized and cropped so as to return the largest possible window in the image that matches the target aspect ratio.

For an overview and full list of preprocessing layers, see the preprocessing guide.

Input shape:

3D (unbatched) or 4D (batched) tensor with shape: (..., height, width, channels), in "channels_last" format.

Output shape:

3D (unbatched) or 4D (batched) tensor with shape: (..., target_height, target_width, channels).

If the input height/width is even and the target height/width is odd (or inversely), the input image is left-padded by 1 pixel.

height Integer, the height of the output shape.
width Integer, the width of the output shape.