tf.keras.layers.CenterCrop
Stay organized with collections
Save and categorize content based on your preferences.
Crop the central portion of the images to target height and width.
Inherits From: Layer
, Module
tf.keras.layers.CenterCrop(
height, width, **kwargs
)
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.
Args |
height
|
Integer, the height of the output shape.
|
width
|
Integer, the width of the output shape.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2021-08-16 UTC.
[null,null,["Last updated 2021-08-16 UTC."],[],[],null,["# tf.keras.layers.CenterCrop\n\n\u003cbr /\u003e\n\n|--------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/keras-team/keras/tree/master/keras/layers/preprocessing/image_preprocessing.py#L124-L192) |\n\nCrop the central portion of the images to target height and width.\n\nInherits From: [`Layer`](../../../tf/keras/layers/Layer), [`Module`](../../../tf/Module)\n\n#### View aliases\n\n\n**Main aliases**\n\n[`tf.keras.layers.experimental.preprocessing.CenterCrop`](https://www.tensorflow.org/api_docs/python/tf/keras/layers/CenterCrop)\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`tf.compat.v1.keras.layers.CenterCrop`](https://www.tensorflow.org/api_docs/python/tf/keras/layers/CenterCrop), [`tf.compat.v1.keras.layers.experimental.preprocessing.CenterCrop`](https://www.tensorflow.org/api_docs/python/tf/keras/layers/CenterCrop)\n\n\u003cbr /\u003e\n\n tf.keras.layers.CenterCrop(\n height, width, **kwargs\n )\n\n#### Input shape:\n\n3D (unbatched) or 4D (batched) tensor with shape:\n`(..., height, width, channels)`, in `\"channels_last\"` format.\n\n#### Output shape:\n\n3D (unbatched) or 4D (batched) tensor with shape:\n`(..., target_height, target_width, channels)`.\n\nIf the input height/width is even and the target height/width is odd (or\ninversely), the input image is left-padded by 1 pixel.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|----------|------------------------------------------|\n| `height` | Integer, the height of the output shape. |\n| `width` | Integer, the width of the output shape. |\n\n\u003cbr /\u003e"]]