pil_to_tensor — Torchvision 0.22 documentation (original) (raw)

torchvision.transforms.functional.pil_to_tensor(pic: Any) → Tensor[source]

Convert a PIL Image to a tensor of the same type. This function does not support torchscript.

See PILToTensor for more details.

Note

A deep copy of the underlying array is performed.

Parameters:

pic (PIL Image) – Image to be converted to tensor.

Returns:

Converted image.

Return type:

Tensor