torchvision.transforms.functional中的pad函数的使用 您所在的位置:网站首页 left-pad torchvision.transforms.functional中的pad函数的使用

torchvision.transforms.functional中的pad函数的使用

2023-06-03 21:54| 来源: 网络整理| 查看: 265

from torchvision.transforms import functional as F image = F.pad(image, (pad_left, pad_top, pad_right, pad_bottom), fill=self.pad_value)

该函数四个参数: def pad(img: Tensor, padding: List[int], fill: int = 0, padding_mode: str = “constant”) -> Tensor: img:输入图像 padding:填充数量----If a single int is provided this is used to pad all borders. If sequence of length 2 is provided this is the padding on left/right and top/bottom respectively. If a sequence of length 4 is provided this is the padding for the left, top, right and bottom borders respectively. fill: 填充值-----Pixel fill value for constant fill. Default is 0. If a tuple of length 3, it is used to fill R, G, B channels respectively. This value is only used when the padding_mode is constant. Only number is supported for torch Tensor. Only int or str or tuple value is supported for PIL Image. padding_mode:填充模式----

constant: pads with a constant value, this value is specified with fill

- edge: pads with the last value at the edge of the image. If input a 5D torch Tensor, the last 3 dimensions will be padded instead of the last 2 - reflect: pads with reflection of image without repeating the last value on the edge. For example, padding [1, 2, 3, 4] with 2 elements on both sides in reflect mode will result in [3, 2, 1, 2, 3, 4, 3, 2] - symmetric: pads with reflection of image repeating the last value on the edge. For example, padding [1, 2, 3, 4] with 2 elements on both sides in symmetric mode will result in [2, 1, 1, 2, 3, 4, 4, 3]


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有