Shortcuts

write_png

torchvision.io.write_png(input: Tensor, filename: str, compression_level: int = 6)[source]

Takes an input tensor in CHW layout (or HW in the case of grayscale images) and saves it in a PNG file.

Parameters:
  • input (Tensor[channels, image_height, image_width]) – int8 image tensor of c channels, where c must be 1 or 3.

  • filename (str or pathlib.Path) – Path to save the image.

  • compression_level (int) – Compression factor for the resulting file, it must be a number between 0 and 9. Default: 6

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