torchvision.transforms.functional.resized_crop(img: Tensor, top: int, left: int, height: int, width: int, size: List[int], interpolation: InterpolationMode = InterpolationMode.BILINEAR, antialias: Optional[bool] = None) Tensor[source]

Crop the given image and resize it to desired size. If the image is torch Tensor, it is expected to have […, H, W] shape, where … means an arbitrary number of leading dimensions

Notably used in RandomResizedCrop.

  • img (PIL Image or Tensor) – Image to be cropped. (0,0) denotes the top left corner of the image.

  • top (int) – Vertical component of the top left corner of the crop box.

  • left (int) – Horizontal component of the top left corner of the crop box.

  • height (int) – Height of the crop box.

  • width (int) – Width of the crop box.

  • size (sequence or int) – Desired output size. Same semantics as resize.

  • interpolation (InterpolationMode) – Desired interpolation enum defined by torchvision.transforms.InterpolationMode. Default is InterpolationMode.BILINEAR. If input is Tensor, only InterpolationMode.NEAREST, InterpolationMode.BILINEAR and InterpolationMode.BICUBIC are supported. For backward compatibility integer values (e.g. PIL.Image[.Resampling].NEAREST) are still accepted, but deprecated since 0.13 and will be removed in 0.15. Please use InterpolationMode enum.

  • antialias (bool, optional) – antialias flag. If img is PIL Image, the flag is ignored and anti-alias is always used. If img is Tensor, the flag is False by default and can be set to True for InterpolationMode.BILINEAR and InterpolationMode.BICUBIC modes. This can help making the output for PIL images and tensors closer.


Cropped image.

Return type:

PIL Image or Tensor

Examples using resized_crop:

Illustration of transforms

Illustration of transforms

Illustration of transforms


Access comprehensive developer documentation for PyTorch

View Docs


Get in-depth tutorials for beginners and advanced developers

View Tutorials


Find development resources and get your questions answered

View Resources