five_crop¶
- torchvision.transforms.functional.five_crop(img: Tensor, size: List[int]) Tuple[Tensor, Tensor, Tensor, Tensor, Tensor] [source]¶
将给定图像裁剪为四个角和中心区域。如果图像是 PyTorch Tensor,则其形状应为 […, H, W],其中 … 表示任意数量的前导维度
注意
此转换返回一个图像元组,并且您的
Dataset
返回的输入和目标数量可能不匹配。- 参数:
img (PIL Image 或 Tensor) – 要裁剪的图像。
size (sequence 或 int) – 期望的裁剪输出尺寸。如果 size 是一个 int 而非像 (h, w) 这样的序列,则会进行方形裁剪 (size, size)。如果提供的序列长度为 1,则将被解释为 (size[0], size[0])。
- 返回值:
元组 (tl, tr, bl, br, center) 对应的左上角、右上角、左下角、右下角和中心裁剪区域。
- 返回值类型:
使用
five_crop
的示例