Pad — Torchvision 0.22 documentation (original) (raw)

class torchvision.transforms.Pad(padding, fill=0, padding_mode='constant')[source]

Pad the given image on all sides with the given “pad” value. If the image is torch Tensor, it is expected to have […, H, W] shape, where … means at most 2 leading dimensions for mode reflect and symmetric, at most 3 leading dimensions for mode edge, and an arbitrary number of leading dimensions for mode constant

Parameters:

Examples using Pad:

forward(img)[source]

Parameters:

img (PIL Image or Tensor) – Image to be padded.

Returns:

Padded image.

Return type:

PIL Image or Tensor