裁切¶ torchvision.transforms.functional.crop(img: Tensor, top: int, left: int, height: int, width: int) → Tensor[源代码]¶ 在指定位置和输出尺寸上裁切给定的图像。如果图像是 torch Tensor,则期望其形状为 […, H, W],其中 … 表示任意数量的前导维度。如果图像沿任何边缘的尺寸小于输出尺寸,图像将填充 0 然后进行裁切。 参数: img (PIL 图像或 Tensor) – 要裁切的图像。(0,0) 表示图像的左上角。 top (int) – 裁切框左上角的垂直分量。 left (int) – 裁切框左上角的水平分量。 height (int) – 裁切框的高度。 width (int) – 裁切框的宽度。 返回: 裁切后的图像。 返回类型: PIL 图像或 Tensor 使用 crop 的示例 变换示例 变换示例