Shortcuts

TenCrop

class torchvision.transforms.v2.TenCrop(size: Union[int, Sequence[int]], vertical_flip: bool = False)[source]

[BETA] Crop the image or video into four corners and the central crop plus the flipped version of these (horizontal flipping is used by default).

Note

The TenCrop transform is in Beta stage, and while we do not expect disruptive breaking changes, some APIs may slightly change according to user feedback. Please submit any feedback you may have in this issue: https://github.com/pytorch/vision/issues/6753.

If the input is a torch.Tensor or a Image or a Video it can have arbitrary number of leading batch dimensions. For example, the image can have [..., C, H, W] shape.

See FiveCrop for an example.

Note

This transform returns a tuple of images and there may be a mismatch in the number of inputs and targets your Dataset returns. See below for an example of how to deal with this.

Parameters:
  • size (sequence or int) – Desired output size of the crop. If size is an int instead of sequence like (h, w), a square crop (size, size) is made. If provided a sequence of length 1, it will be interpreted as (size[0], size[0]).

  • vertical_flip (bool, optional) – Use vertical flipping instead of horizontal

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources