1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15- import warnings
1615from collections .abc import Collection , Iterable
1716from math import ceil
1817from typing import Optional , Union
@@ -453,7 +452,6 @@ def center_crop(
453452 size : tuple [int , int ],
454453 data_format : Optional [Union [str , ChannelDimension ]] = None ,
455454 input_data_format : Optional [Union [str , ChannelDimension ]] = None ,
456- return_numpy : Optional [bool ] = None ,
457455) -> np .ndarray :
458456 """
459457 Crops the `image` to the specified `size` using a center crop. Note that if the image is too small to be cropped to
@@ -474,22 +472,11 @@ def center_crop(
474472 - `"channels_first"` or `ChannelDimension.FIRST`: image in (num_channels, height, width) format.
475473 - `"channels_last"` or `ChannelDimension.LAST`: image in (height, width, num_channels) format.
476474 If unset, will use the inferred format of the input image.
477- return_numpy (`bool`, *optional*):
478- Whether or not to return the cropped image as a numpy array. Used for backwards compatibility with the
479- previous ImageFeatureExtractionMixin method.
480- - Unset: will return the same type as the input image.
481- - `True`: will return a numpy array.
482- - `False`: will return a `PIL.Image.Image` object.
483475 Returns:
484476 `np.ndarray`: The cropped image.
485477 """
486478 requires_backends (center_crop , ["vision" ])
487479
488- if return_numpy is not None :
489- warnings .warn ("return_numpy is deprecated and will be removed in v.4.33" , FutureWarning )
490-
491- return_numpy = True if return_numpy is None else return_numpy
492-
493480 if not isinstance (image , np .ndarray ):
494481 raise TypeError (f"Input image must be of type np.ndarray, got { type (image )} " )
495482
@@ -541,9 +528,6 @@ def center_crop(
541528 new_image = new_image [..., max (0 , top ) : min (new_height , bottom ), max (0 , left ) : min (new_width , right )]
542529 new_image = to_channel_dimension_format (new_image , output_data_format , ChannelDimension .FIRST )
543530
544- if not return_numpy :
545- new_image = to_pil_image (new_image )
546-
547531 return new_image
548532
549533
0 commit comments