to_grayscale — Torchvision 0.22 documentation (original) (raw)

torchvision.transforms.functional.to_grayscale(img, num_output_channels=1)[source]

Convert PIL image of any mode (RGB, HSV, LAB, etc) to grayscale version of image. This transform does not support torch Tensor.

Parameters:

Returns:

Grayscale version of the image.

Return type:

PIL Image

Examples using to_grayscale: