PILToTensor¶
- class torchvision.transforms.PILToTensor[source]¶
Convert a PIL Image to a tensor of the same type - this does not scale values.
This transform does not support torchscript.
Convert a PIL Image with H height, W width, and C channels to a Tensor of shape (C x H x W).
Example
>>> from PIL import Image >>> import torchvision.transforms as T >>> img = Image.new("RGB", (320, 240)) # size (W=320, H=240) >>> tensor = T.PILToTensor()(img) >>> print(tensor.shape) torch.Size([3, 240, 320])
Examples using
PILToTensor: