Skip to content

Commit

Permalink
add input and output docs for vision transform (#3836)
Browse files Browse the repository at this point in the history
* add input and output docs for vision transform

* add input and output docs for vision transform
  • Loading branch information
wangna11BD authored Sep 1, 2021
1 parent f7fa867 commit 3b40fe3
Show file tree
Hide file tree
Showing 18 changed files with 122 additions and 22 deletions.
9 changes: 8 additions & 1 deletion docs/api/paddle/vision/transforms/BrightnessTransform_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,17 @@ BrightnessTransform

- value (float) - 亮度调整范围大小,会从给定参数后的均匀分布[max(0,1 - brightness), 1 + brightness]中随机选择进行实际调整,可以是任何非负数。参数等于0时输出原始图像。
- keys (list[str]|tuple[str], optional) - 与 ``BaseTransform`` 定义一致。默认值: None。

形状
:::::::::

- img (PIL.Image|np.ndarray|Paddle.Tensor) - 输入的图像数据,数据格式为'HWC'。
- output (PIL.Image|np.ndarray|Paddle.Tensor) - 返回调整亮度后的图像数据。

返回
:::::::::

``PIL.Image 或 numpy ndarray``,调整亮度后的图像
计算 ``BrightnessTransform`` 的可调用对象

代码示例
:::::::::
Expand Down
8 changes: 7 additions & 1 deletion docs/api/paddle/vision/transforms/CenterCrop_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@ CenterCrop
- size (int|tuple) - 输出图像的形状大小。
- keys (list[str]|tuple[str], optional) - 与 ``BaseTransform`` 定义一致。默认值: None。

形状
:::::::::

- img (PIL.Image|np.ndarray|Paddle.Tensor) - 输入的图像数据,数据格式为'HWC'。
- output (PIL.Image|np.ndarray|Paddle.Tensor) - 返回裁剪后的图像数据。

返回
:::::::::

``PIL.Image, numpy ndarray``,裁剪后的图像
计算 ``CenterCrop`` 的可调用对象

代码示例
:::::::::
Expand Down
8 changes: 7 additions & 1 deletion docs/api/paddle/vision/transforms/ColorJitter_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,16 @@ ColorJitter
- hue(float) - 色调调整范围大小,,会从给定参数后的均匀分布[-hue, hue]中随机选择进行实际调整,参数值需要在0到0.5之间。
- keys (list[str]|tuple[str], optional) - 与 ``BaseTransform`` 定义一致。默认值: None。

形状
:::::::::

- img (PIL.Image|np.ndarray|Paddle.Tensor) - 输入的图像数据,数据格式为'HWC'。
- output (PIL.Image|np.ndarray|Paddle.Tensor) - 返回调整亮度、对比度、饱和度和色调后的图像数据。

返回
:::::::::

``numpy ndarray``,调整亮度、对比度、饱和度和色调后的图像
计算 ``ColorJitter`` 的可调用对象

代码示例
:::::::::
Expand Down
8 changes: 7 additions & 1 deletion docs/api/paddle/vision/transforms/ContrastTransform_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@ ContrastTransform
- value (float) - 对比度调整范围大小,会从给定参数后的均匀分布[max(0,1 - contrast), 1 + contrast]中随机选择进行实际调整,不能是负数。参数值为0时返回原图像。
- keys (list[str]|tuple[str], optional) - 与 ``BaseTransform`` 定义一致。默认值: None。

形状
:::::::::

- img (PIL.Image|np.ndarray|Paddle.Tensor) - 输入的图像数据,数据格式为'HWC'。
- output (PIL.Image|np.ndarray|Paddle.Tensor) - 返回调整对比度后的图像数据。

返回
:::::::::

``numpy ndarray``,调整对比度后的图像
计算 ``ContrastTransform`` 的可调用对象

代码示例
:::::::::
Expand Down
11 changes: 7 additions & 4 deletions docs/api/paddle/vision/transforms/Grayscale_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ Grayscale
- num_output_channels (int,可选) - 输出图像的通道数,参数值为1或3。默认值:1。
- keys (list[str]|tuple[str], optional) - 与 ``BaseTransform`` 定义一致。默认值: None。

返回
形状
:::::::::

``PIL.Image 或 numpy.ndarray``,输入图像的灰度版本。
- img (PIL.Image|np.ndarray|Paddle.Tensor) - 输入的图像数据,数据格式为'HWC'。
- output (PIL.Image|np.ndarray|Paddle.Tensor) - 返回输入图像的灰度版本。如果 output_channels == 1,返回一个单通道图像。如果 output_channels == 3,返回一个3通道图像,其中RGB三个通道值一样。

返回
:::::::::

- 如果 output_channels == 1 : 返回一个单通道图像。
- 如果 output_channels == 3 : 返回一个3通道图像,其中RGB三个通道值一样。
计算 ``Grayscale`` 的可调用对象。

代码示例
:::::::::
Expand Down
8 changes: 7 additions & 1 deletion docs/api/paddle/vision/transforms/HueTransform_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@ HueTransform
- value (float) - 色调调整范围大小,,会从给定参数后的均匀分布[-hue, hue]中随机选择进行实际调整,参数值需要在0到0.5之间, 参数值为0时返回原始图像。
- keys (list[str]|tuple[str], optional) - 与 ``BaseTransform`` 定义一致。默认值: None。

形状
:::::::::

- img (PIL.Image|np.ndarray|Paddle.Tensor) - 输入的图像数据,数据格式为'HWC'。
- output (PIL.Image|np.ndarray|Paddle.Tensor) - 返回调整色调后的图像数据。

返回
:::::::::

``PIL.Image 或 numpy ndarray``,调整色调后的图像
计算 ``HueTransform`` 的可调用对象

代码示例
:::::::::
Expand Down
8 changes: 7 additions & 1 deletion docs/api/paddle/vision/transforms/Normalize_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,16 @@ Normalize
- to_rgb (bool, optional) - 是否转换为 ``rgb`` 的格式。默认值:False。
- keys (list[str]|tuple[str], optional) - 与 ``BaseTransform``. 默认值: None。

形状
:::::::::

- img (PIL.Image|np.ndarray|Paddle.Tensor) - 输入的图像数据,数据格式为'HWC'。
- output (PIL.Image|np.ndarray|Paddle.Tensor) - 返回归一化后的图像数据。

返回
:::::::::

``numpy ndarray``,归一化后的图像
计算 ``Normalize`` 的可调用对象

代码示例
:::::::::
Expand Down
8 changes: 7 additions & 1 deletion docs/api/paddle/vision/transforms/Pad_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,16 @@ Pad
- padding_mode (string) - 填充模式。支持: constant, edge, reflect 或 symmetric。 默认值:constant。 ``constant`` 表示使用常量值进行填充,该值由fill参数指定。``edge`` 表示使用图像边缘像素值进行填充。``reflect`` 表示使用原图像的镜像值进行填充(不使用边缘上的值);比如:使用该模式对 ``[1, 2, 3, 4]`` 的两端分别填充2个值,结果是 ``[3, 2, 1, 2, 3, 4, 3, 2]``。``symmetric`` 表示使用原图像的镜像值进行填充(使用边缘上的值);比如:使用该模式对 ``[1, 2, 3, 4]`` 的两端分别填充2个值,结果是 ``[2, 1, 1, 2, 3, 4, 4, 3]``。
- keys (list[str]|tuple[str], optional) - 与 ``BaseTransform`` 定义一致。默认值: None。

形状
:::::::::

- img (PIL.Image|np.ndarray|Paddle.Tensor) - 输入的图像数据,数据格式为'HWC'。
- output (PIL.Image|np.ndarray|Paddle.Tensor) - 返回填充后的图像数据。

返回
:::::::::

``PIL.Image 或 numpy ndarray``,填充后的图像
计算 ``Pad`` 的可调用对象

代码示例
:::::::::
Expand Down
8 changes: 7 additions & 1 deletion docs/api/paddle/vision/transforms/RandomCrop_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,16 @@ RandomCrop
- pad_if_needed (boolean,可选) - 如果裁剪后的图像小于期望的大小时,是否对裁剪后的图像进行填充,以避免引发异常,默认值:False,保持初次裁剪后的大小,不填充。
- keys (list[str]|tuple[str], optional) - 与 ``BaseTransform`` 定义一致。默认值: None。

形状
:::::::::

- img (PIL.Image|np.ndarray|Paddle.Tensor) - 输入的图像数据,数据格式为'HWC'。
- output (PIL.Image|np.ndarray|Paddle.Tensor) - 返回随机裁剪后的图像数据。

返回
:::::::::

``numpy ndarray``,随机裁剪后的图像
计算 ``RandomCrop`` 的可调用对象

代码示例
:::::::::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@ RandomHorizontalFlip
- prob (float) - 图片执行水平翻转的概率,取值范围为[0, 1], 默认值为0.5。
- keys (list[str]|tuple[str], optional) - 与 ``BaseTransform`` 定义一致。默认值: None。

形状
:::::::::

- img (PIL.Image|np.ndarray|Paddle.Tensor) - 输入的图像数据,数据格式为'HWC'。
- output (PIL.Image|np.ndarray|Paddle.Tensor) - 返回概率执行水平翻转后的图像数据。

返回
:::::::::

``PIL.Image 或 numpy ndarray``,概率执行水平翻转后的图像
计算 ``RandomHorizontalFlip`` 的可调用对象

代码示例
:::::::::
Expand Down
8 changes: 7 additions & 1 deletion docs/api/paddle/vision/transforms/RandomResizedCrop_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,16 @@ RandomResizedCrop
- interpolation (int|str, optional) - 插值的方法. 默认值: 'bilinear'. 当使用 ``pil`` 作为后端时, 支持的插值方法如下: - "nearest": Image.NEAREST, - "bilinear": Image.BILINEAR, - "bicubic": Image.BICUBIC, - "box": Image.BOX, - "lanczos": Image.LANCZOS, - "hamming": Image.HAMMING。当使用 ``cv2`` 作为后端时, 支持的插值方法如下: - "nearest": cv2.INTER_NEAREST, - "bilinear": cv2.INTER_LINEAR, - "area": cv2.INTER_AREA, - "bicubic": cv2.INTER_CUBIC, - "lanczos": cv2.INTER_LANCZOS4。
- keys (list[str]|tuple[str], optional) - 与 ``BaseTransform`` 定义一致。默认值: None。

形状
:::::::::

- img (PIL.Image|np.ndarray|Paddle.Tensor) - 输入的图像数据,数据格式为'HWC'。
- output (PIL.Image|np.ndarray|Paddle.Tensor) - 返回裁剪后的图像数据。

返回
:::::::::

``numpy ndarray``,随机裁剪和改变大小后的图像。
计算 ``RandomResizedCrop`` 的可调用对象。

代码示例
:::::::::
Expand Down
8 changes: 7 additions & 1 deletion docs/api/paddle/vision/transforms/RandomRotation_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,16 @@ RandomRotate
- fill (int,可选) - 对图像扩展时填充的值。默认值:0。
- keys (list[str]|tuple[str], optional) - 与 ``BaseTransform`` 定义一致。默认值: None。

形状
:::::::::

- img (PIL.Image|np.ndarray|Paddle.Tensor) - 输入的图像数据,数据格式为'HWC'。
- output (PIL.Image|np.ndarray|Paddle.Tensor) - 返回随机旋转一定角度后的图像数据。

返回
:::::::::

``numpy ndarray``,随机旋转一定角度后的图像
计算 ``RandomRotation`` 的可调用对象

代码示例
:::::::::
Expand Down
10 changes: 8 additions & 2 deletions docs/api/paddle/vision/transforms/RandomVerticalFlip_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@ RandomVerticalFlip
- prob (float) - 执行图片垂直翻转的概率,默认值为0.5。
- keys (list[str]|tuple[str], optional) - 与 ``BaseTransform`` 定义一致。默认值: None。

形状
:::::::::

- img (PIL.Image|np.ndarray|Paddle.Tensor) - 输入的图像数据,数据格式为'HWC'。
- output (PIL.Image|np.ndarray|Paddle.Tensor) - 返回概率执行垂直翻转后的图像数据。

返回
:::::::::

``PIL.Image 或 numpy ndarray``,概率执行垂直翻转后的图像
计算 ``RandomVerticalFlip`` 的可调用对象

代码示例
:::::::::
Expand All @@ -27,7 +33,7 @@ RandomVerticalFlip
from PIL import Image
from paddle.vision.transforms import RandomVerticalFlip
transform = RandomVerticalFlip(224)
transform = RandomVerticalFlip()
fake_img = Image.fromarray((np.random.rand(300, 320, 3) * 255.).astype(np.uint8))
Expand Down
8 changes: 7 additions & 1 deletion docs/api/paddle/vision/transforms/Resize_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,16 @@ Resize
- interpolation (int|str, optional) - 插值的方法. 默认值: 'bilinear'. 当使用 ``pil`` 作为后端时, 支持的插值方法如下: - "nearest": Image.NEAREST, - "bilinear": Image.BILINEAR, - "bicubic": Image.BICUBIC, - "box": Image.BOX, - "lanczos": Image.LANCZOS, - "hamming": Image.HAMMING;当使用 ``cv2`` 作为后端时, 支持的插值方法如下: - "nearest": cv2.INTER_NEAREST, - "bilinear": cv2.INTER_LINEAR, - "area": cv2.INTER_AREA, - "bicubic": cv2.INTER_CUBIC, - "lanczos": cv2.INTER_LANCZOS4
- keys (list[str]|tuple[str], optional) - 与 ``BaseTransform`` 定义一致。默认值: None。

形状
:::::::::

- img (PIL.Image|np.ndarray|Paddle.Tensor) - 输入的图像数据,数据格式为'HWC'。
- output (PIL.Image|np.ndarray|Paddle.Tensor) - 返回调整大小后的图像数据。

返回
:::::::::

``numpy ndarray``,调整大小后的图像
计算 ``Resize`` 的可调用对象

代码示例
:::::::::
Expand Down
8 changes: 7 additions & 1 deletion docs/api/paddle/vision/transforms/SaturationTransform_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@ SaturationTransform
- value (float) - 饱和度的调整数值,非负数,当参数值为0时返回原始图像。
- keys (list[str]|tuple[str], optional) - 与 ``BaseTransform`` 定义一致。默认值: None。

形状
:::::::::

- img (PIL.Image|np.ndarray|Paddle.Tensor) - 输入的图像数据,数据格式为'HWC'。
- output (PIL.Image|np.ndarray|Paddle.Tensor) - 返回调整饱和度后的图像数据。

返回
:::::::::

``numpy ndarray``,调整饱和度后的图像
计算 ``SaturationTransform`` 的可调用对象

代码示例
:::::::::
Expand Down
8 changes: 7 additions & 1 deletion docs/api/paddle/vision/transforms/ToTensor_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,16 @@ ToTensor
- data_format (str, optional): 返回张量的格式,必须为 'HWC' 或 'CHW'。 默认值: 'CHW'。
- keys (list[str]|tuple[str], optional) - 与 ``BaseTransform`` 定义一致。默认值: None。

形状
:::::::::

- img (PIL.Image|numpy.ndarray) - 输入的图像数据,数据格式为'HWC'。
- output (np.ndarray) - 返回的张量数据,根据参数 ``data_format``,张量的格式必须为 'HWC' 或 'CHW'。

返回
:::::::::

``paddle.Tensor``,变换后的图像
计算 ``ToTensor`` 的可调用对象

代码示例
:::::::::
Expand Down
8 changes: 7 additions & 1 deletion docs/api/paddle/vision/transforms/Transpose_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,16 @@ Transpose
- order (list|tuple, optional) - 目标的维度顺序. Default: (2, 0, 1)。
- keys (list[str]|tuple[str], optional) - 与 ``BaseTransform``. 默认值: None。

形状
:::::::::

- img (PIL.Image|np.ndarray|Paddle.Tensor) - 输入的图像数据,数据格式为'HWC'。
- output (np.ndarray|Paddle.Tensor) - 返回更改格式后的数组或张量。如果输入是``PIL.Image``,输出将会自动转换为``np.ndarray``。

返回
:::::::::

``PIL.Image 或 numpy ndarray``,更改格式后的图像
计算 ``Transpose`` 的可调用对象

代码示例
:::::::::
Expand Down
2 changes: 1 addition & 1 deletion docs/api/paddle/vision/transforms/resize_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ resize
参数
:::::::::

- img (numpy.ndarray) - 输入数据,可以是(H, W, C)形状的图像或遮罩。
- img (numpy.ndarray|PIL.Image) - 输入数据,可以是(H, W, C)形状的图像或遮罩。
- size (int|tuple) - 输出图像大小。如果size是一个序列,例如(h,w),输出大小将与此匹配。如果size为int,图像的较小边缘将与此数字匹配,即如果 height > width,则图像将重新缩放为(size * height / width, size)。
- interpolation (int|str, optional) - 插值的方法. 默认值: 'bilinear'。 当使用 ``pil`` 作为后端时, 支持的插值方法如下: - "nearest": Image.NEAREST, - "bilinear": Image.BILINEAR, - "bicubic": Image.BICUBIC, - "box": Image.BOX, - "lanczos": Image.LANCZOS, - "hamming": Image.HAMMING。当使用 ``cv2`` 作为后端时, 支持的插值方法如下: - "nearest": cv2.INTER_NEAREST, - "bilinear": cv2.INTER_LINEAR, - "area": cv2.INTER_AREA, - "bicubic": cv2.INTER_CUBIC, - "lanczos": cv2.INTER_LANCZOS4。

Expand Down

0 comments on commit 3b40fe3

Please sign in to comment.