write_png¶
- torchvision.io.write_png(input: Tensor, filename: str, compression_level: int = 6)[source]¶
将 CHW 布局(或灰度图像的 HW 布局)的输入张量保存为 PNG 文件。
- 参数:
input (Tensor[channels, image_height, image_width]) – int8 图像张量,具有
c
个通道,其中c
必须是 1 或 3。filename (str 或
pathlib.Path
) – 要保存图像的路径。compression_level (int) – 输出文件的压缩系数,必须是 0 到 9 之间的数字。默认为:6