PILToTensor¶ class torchvision.transforms.v2.PILToTensor[source]¶ 将 PIL Image 转换为相同类型的张量 - 此转换不缩放数值。 此转换不支持 torchscript。 将 PIL Image (H x W x C) 转换为形状为 (C x H x W) 的张量。 使用 PILToTensor 的示例 如何使用 CutMix 和 MixUp 如何使用 CutMix 和 MixUp transform(inpt: Image, params: Dict[str, Any]) → Tensor[source]¶ 自定义转换需要覆盖的方法。 参见 如何编写自己的 v2 转换