Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
832689a
Update Normalize_cn.rst
Liyulingyue Apr 28, 2022
2fb4d40
Update Normalize_cn.rst
Liyulingyue Apr 28, 2022
15b01ec
Update alexnet_cn.rst
Liyulingyue Apr 29, 2022
ba54a40
Update VGG_cn.rst
Liyulingyue May 9, 2022
e2f8bb4
Merge pull request #1 from PaddlePaddle/develop
Liyulingyue May 9, 2022
d7aeb86
Update MobileNetV2_cn.rst
Liyulingyue May 9, 2022
f3fd681
Update Normalize_cn.rst
Liyulingyue May 9, 2022
fdb7469
Update MobileNetV1_cn.rst
Liyulingyue May 9, 2022
433558f
Update MobileNetV1_cn.rst
Liyulingyue May 18, 2022
0eaac5b
Update MobileNetV2_cn.rst
Liyulingyue May 18, 2022
b90caa3
Update VGG_cn.rst
Liyulingyue May 18, 2022
3b202fe
Update PSRoIPool_cn.rst
Liyulingyue May 18, 2022
ff08ed1
Update psroi_pool_cn.rst
Liyulingyue May 18, 2022
6fe4ee7
Update roi_align_cn.rst
Liyulingyue May 18, 2022
5360b76
Update RoIAlign_cn.rst
Liyulingyue May 18, 2022
e8cf1bd
Update alexnet_cn.rst
Liyulingyue May 21, 2022
ad71096
Update MobileNetV1_cn.rst
Liyulingyue May 21, 2022
a4235d3
Update MobileNetV2_cn.rst
Liyulingyue May 21, 2022
f2ce3db
Update VGG_cn.rst
Liyulingyue May 22, 2022
4820b4d
Update VGG_cn.rst
Liyulingyue May 22, 2022
5fbfdcd
Update PSRoIPool_cn.rst
Liyulingyue May 22, 2022
947a72d
Update psroi_pool_cn.rst
Liyulingyue May 22, 2022
d69b735
Update psroi_pool_cn.rst
Liyulingyue May 22, 2022
92ecb21
Update roi_align_cn.rst
Liyulingyue May 22, 2022
597dce6
Update psroi_pool_cn.rst
Liyulingyue May 22, 2022
c401ad9
Update roi_align_cn.rst
Liyulingyue May 22, 2022
9a5b13f
Update Normalize_cn.rst
Liyulingyue May 22, 2022
036afb0
Update VGG_cn.rst
Ligoml Jun 13, 2022
43285e3
Update alexnet_cn.rst
Ligoml Jun 13, 2022
20cfca0
Update PSRoIPool_cn.rst
Ligoml Jun 13, 2022
2f6517b
Merge branch 'develop' into for_Normalize
Ligoml Jun 17, 2022
fd1735c
Update docs/api/paddle/vision/models/alexnet_cn.rst
Ligoml Jun 17, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions docs/api/paddle/vision/models/MobileNetV1_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ MobileNetV1

.. py:class:: paddle.vision.models.MobileNetV1(scale=1.0, num_classes=1000, with_pool=True)



MobileNetV1模型,来自论文 `"MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications" <https://arxiv.org/abs/1704.04861>`_ 。

参数
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

num_classes:, -->

Expand All @@ -19,14 +21,5 @@ mobilenetv1模型,Layer的实例。

代码示例
:::::::::
.. code-block:: python

import paddle
from paddle.vision.models import MobileNetV1

model = MobileNetV1()

x = paddle.rand([1, 3, 224, 224])
out = model(x)
COPY-FROM: paddle.vision.models.MobileNetV1:code-example1

print(out.shape)
14 changes: 3 additions & 11 deletions docs/api/paddle/vision/models/MobileNetV2_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ MobileNetV2

.. py:class:: paddle.vision.models.MobileNetV2(scale=1.0, num_classes=1000, with_pool=True)



MobileNetV2模型,来自论文 `"MobileNetV2: Inverted Residuals and Linear Bottlenecks" <https://arxiv.org/abs/1801.04381>`_ 。

参数
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

num_classes:, -->

Expand All @@ -19,15 +21,5 @@ mobilenetv2模型,Layer的实例。

代码示例
:::::::::
COPY-FROM: paddle.vision.models.MobileNetV2:code-example1

.. code-block:: python

import paddle
from paddle.vision.models import MobileNetV2

model = MobileNetV2()

x = paddle.rand([1, 3, 224, 224])
out = model(x)

print(out.shape)
23 changes: 5 additions & 18 deletions docs/api/paddle/vision/models/VGG_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@
VGG
-------------------------------

.. py:class:: paddle.vision.models.VGG(features, num_classes=1000)
.. py:class:: paddle.vision.models.VGG(features, num_classes=1000, with_pool=True)



VGG模型,来自论文 `"Very Deep Convolutional Networks For Large-Scale Image Recognition" <https://arxiv.org/pdf/1409.1556.pdf>`_ 。

参数
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • num_classes (int,可选) ,int, 后面多一个空格
  • with_pool 后面多一个:

:::::::::
- **features** (Layer) - vgg模型的特征层。由函数make_layers产生。
- **num_classes** (int,可选) - 最后一个全连接层输出的维度。如果该值小于等于0,则不定义最后一个全连接层。默认值:1000。
- **with_pool** (bool,可选): - 是否在最后三个全连接层前使用池化。默认值:True。
- **with_pool** (bool,可选) - 是否在最后三个全连接层前使用池化。默认值:True。

返回
:::::::::
Expand All @@ -20,19 +22,4 @@ vgg模型,Layer的实例。
代码示例
:::::::::

.. code-block:: python

import paddle
from paddle.vision.models import VGG
from paddle.vision.models.vgg import make_layers

vgg11_cfg = [64, 'M', 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, 512, 'M']

features = make_layers(vgg11_cfg)

vgg11 = VGG(features)

x = paddle.rand([1, 3, 224, 224])
out = vgg11(x)

print(out.shape)
COPY-FROM: paddle.vision.models.VGG:code-example
18 changes: 3 additions & 15 deletions docs/api/paddle/vision/models/alexnet_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,18 @@ alexnet

.. py:function:: paddle.vision.models.alexnet(pretrained=False, **kwargs)


AlexNet模型,来自论文 `"ImageNet Classification with Deep Convolutional Neural Networks" <https://papers.nips.cc/paper/2012/file/c399862d3b9d6b76c8436e924a68c45b-Paper.pdf>`_ 。

参数
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

参数是不是少了 **kwargs

:::::::::
- **pretrained** (bool,可选) - 是否加载在imagenet数据集上的预训练权重。默认值:False。

- **\*\*kwargs** (可选) - 附加的关键字参数,具体可选参数请参见 :ref:`AlexNet <cn_api_paddle_vision_models_AlexNet>`。
返回
:::::::::
alexnet模型,Layer的实例。

代码示例
:::::::::
.. code-block:: python

import paddle
from paddle.vision.models import alexnet

# build model
model = alexnet()

# build model and load imagenet pretrained weight
# model = alexnet(pretrained=True)

x = paddle.rand([1, 3, 224, 224])
out = model(x)

print(out.shape)
COPY-FROM: paddle.vision.models.alexnet:code-example
15 changes: 3 additions & 12 deletions docs/api/paddle/vision/ops/PSRoIPool_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ PSRoIPool

参数
:::::::::
- output_size (int|Tuple(int, int)) - 池化后输出的尺寸(H, W)数据类型为int32如果output_size是int类型,H和W都与其相等。
- spatial_scale (float) - 空间比例因子,用于将boxes中的坐标从其输入尺寸按比例映射到输入特征图的尺寸。
- **output_size** (int|Tuple(int, int)) - 池化后输出的尺寸(H, W), 数据类型为int32. 如果output_size是int类型,H和W都与其相等。
- **spatial_scale** (float,可选) - 空间比例因子,用于将boxes中的坐标从其输入尺寸按比例映射到输入特征图的尺寸。

形状
:::::::::
Expand All @@ -25,13 +25,4 @@ PSRoIPool

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spatial_scale是可选参数

代码示例
:::::::::

.. code-block:: python

import paddle

psroi_module = paddle.vision.ops.PSRoIPool(7, 1.0)
x = paddle.uniform([2, 490, 28, 28], dtype='float32')
boxes = paddle.to_tensor([[1, 5, 8, 10], [4, 2, 6, 7], [12, 12, 19, 21]], dtype='float32')
boxes_num = paddle.to_tensor([1, 2], dtype='int32')
pool_out = psroi_module(x, boxes, boxes_num)
COPY-FROM: paddle.vision.ops.PSRoIPool:code-example1
19 changes: 5 additions & 14 deletions docs/api/paddle/vision/ops/RoIAlign_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,10 @@ RoIAlign
- boxes_num: 1-D Tensor。数据类型为int32。
- output: 4-D tensor,形状为(RoI数量,输出通道数,池化后高度,池化后宽度)。输出通道数等于输入通道数/(池化后高度 * 池化后宽度)。

代码示例
返回
:::::::::
Tensor,形状为(num_boxes, channels, pooled_h, pooled_w)。

.. code-block:: python

import paddle
from paddle.vision.ops import RoIAlign

data = paddle.rand([1, 256, 32, 32])
boxes = paddle.rand([3, 4])
boxes[:, 2] += boxes[:, 0] + 3
boxes[:, 3] += boxes[:, 1] + 4
boxes_num = paddle.to_tensor([3]).astype('int32')
roi_align = RoIAlign(output_size=(4, 3))
align_out = roi_align(data, boxes, boxes_num)
assert align_out.shape == [3, 256, 4, 3]
代码示例
:::::::::
COPY-FROM: paddle.vision.ops.RoIAlign:code-example1
21 changes: 7 additions & 14 deletions docs/api/paddle/vision/ops/psroi_pool_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,18 @@ PSROIPooling由R-FCN提出。更多详细信息,请参阅 https://arxiv.org/ab

参数
:::::::::
- x (Tensor) - 输入的特征图,形状为(N, C, H, W),数据类型为float32或float64。
- boxes (Tensor) - 待执行池化的ROIs(Regions of Interest,感兴趣区域)的框坐标。它应当是一个形状为(num_rois, 4)的2-D Tensor,以[[x1, y1, x2, y2], ...]的形式给出。其中(x1, y1)是左上角的坐标值,(x2, y2)是右下角的坐标值。
- boxes_num (Tensor) - 该batch中每一张图所包含的框数量。
- output_size (int|Tuple(int, int)) - 池化后输出的尺寸(H, W),数据类型为int32。如果output_size是int类型,H和W都与其相等。
- spatial_scale (float) - 空间比例因子,用于将boxes中的坐标从其输入尺寸按比例映射到输入特征图的尺寸。
- **x** (Tensor) - 输入的特征图,形状为(N, C, H, W),数据类型为float32或float64。
- **boxes** (Tensor) - 待执行池化的ROIs(Regions of Interest,感兴趣区域)的框坐标。它应当是一个形状为(num_rois, 4)的2-D Tensor,以[[x1, y1, x2, y2], ...]的形式给出。其中(x1, y1)是左上角的坐标值,(x2, y2)是右下角的坐标值。
- **boxes_num** (Tensor) - 该batch中每一张图所包含的框数量。
- **output_size** (int|Tuple(int, int)) - 池化后输出的尺寸(H, W),数据类型为int32。如果output_size是int类型,H和W都与其相等。
- **spatial_scale** (float,可选) - 空间比例因子,用于将boxes中的坐标从其输入尺寸按比例映射到输入特征图的尺寸。
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。


返回
:::::::::
4-D Tensor。池化后的ROIs,其形状是(Roi数量,输出通道数,池化后高度,池化后宽度)。输出通道数等于输入通道数/(池化后高度 * 池化后宽度)。

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

中英文标点符号不要混用:

  • , -->
  • . -->
    spatial_scale是可选参数

代码示例
:::::::::

.. code-block:: python

import paddle

x = paddle.uniform([2, 490, 28, 28], dtype='float32')
boxes = paddle.to_tensor([[1, 5, 8, 10], [4, 2, 6, 7], [12, 12, 19, 21]], dtype='float32')
boxes_num = paddle.to_tensor([1, 2], dtype='int32')
pool_out = paddle.vision.ops.psroi_pool(x, boxes, boxes_num, 7, 1.0)
COPY-FROM: paddle.vision.ops.psroi_pool:code-example1
31 changes: 10 additions & 21 deletions docs/api/paddle/vision/ops/roi_align_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,27 @@
roi_align
-------------------------------

.. py:function:: paddle.vision.ops.roi_align(input, boxes, boxes_num, output_size, spatial_scale=1.0, aligned=True, name=None)
.. py:function:: paddle.vision.ops.roi_align(x, boxes, boxes_num, output_size, spatial_scale=1.0, sampling_ratio=-1, aligned=True, name=None)

RoI Align是在指定输入的感兴趣区域上执行双线性插值以获得固定大小的特征图(例如7*7),如 Mask R-CNN论文中所述。

论文参考:`Mask R-CNN <https://arxiv.org/abs/1703.06870>`_ 。

参数
:::::::::
- x (Tensor) - 输入的特征图,形状为(N, C, H, W)。数据类型为float32或float64。
- boxes (Tensor) - 待执行池化的RoIs(Regions of Interest)的框坐标。它应当是一个形状为(boxes_num, 4)的2-D Tensor,以[[x1, y1, x2, y2], ...]的形式给出。其中(x1, y1)是左上角的坐标值,(x2, y2)是右下角的坐标值。
- boxes_num (Tensor) - 该batch中每一张图所包含的框数量。数据类型为int32。
- output_size (int|Tuple(int, int)) - 池化后输出的尺寸(H, W),数据类型为int32。如果output_size是单个int类型整数,则H和W都与其相等。
- spatial_scale (float,可选) - 空间比例因子,用于将boxes中的坐标从其输入尺寸按比例映射到input特征图的尺寸。
- aligned (bool,可选)- 默认值为True,表示像素移动框将其坐标移动-0.5,以便与两个相邻像素索引更好地对齐。如果为False,则是使用遗留版本的实现。
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。
- **x** (Tensor) - 输入的特征图,形状为(N, C, H, W)。数据类型为float32或float64。
- **boxes** (Tensor) - 待执行池化的RoIs(Regions of Interest)的框坐标。它应当是一个形状为(boxes_num, 4)的2-D Tensor,以[[x1, y1, x2, y2], ...]的形式给出。其中(x1, y1)是左上角的坐标值,(x2, y2)是右下角的坐标值。
- **boxes_num** (Tensor) - 该batch中每一张图所包含的框数量。数据类型为int32。
- **output_size** (int|Tuple(int, int)) - 池化后输出的尺寸(H, W),数据类型为int32。如果output_size是单个int类型整数,则H和W都与其相等。
- **spatial_scale** (float32,可选) - 空间比例因子,用于将boxes中的坐标从其输入尺寸按比例映射到input特征图的尺寸。
- **sampling_ratio** (int32,可选) – 插值网格中用于计算每个池化输出条柱的输出值的采样点数。如果大于0,则使用每个条柱的精确采样点。如果小于或等于0,则使用自适应数量的网格点(计算为 ``ceil(roi_width / output_width)``,高度同理)。默认值:-1。
- **aligned** (bool,可选)- 默认值为True,表示像素移动框将其坐标移动-0.5,以便与两个相邻像素索引更好地对齐。如果为False,则是使用遗留版本的实现。
- **name** (str,可选)- 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。

返回
:::::::::
Tensor,池化后的RoIs,为一个形状是(RoI数量,输出通道数,池化后高度,池化后宽度)的4-D Tensor。输出通道数等于输入通道数/(池化后高度 * 池化后宽度)。

代码示例
:::::::::

.. code-block:: python

import paddle
from paddle.vision.ops import roi_align

data = paddle.rand([1, 256, 32, 32])
boxes = paddle.rand([3, 4])
boxes[:, 2] += boxes[:, 0] + 3
boxes[:, 3] += boxes[:, 1] + 4
boxes_num = paddle.to_tensor([3]).astype('int32')
align_out = roi_align(data, boxes, boxes_num=boxes_num, output_size=3)
assert align_out.shape == [3, 256, 3, 3]
COPY-FROM: paddle.vision.ops.roi_align:code-example1
33 changes: 13 additions & 20 deletions docs/api/paddle/vision/transforms/Normalize_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@ normalize
参数
:::::::::

- img (PIL.Image|np.array|paddle.Tensor) - 用于归一化的数据。
- mean (list|tuple) - 用于每个通道归一化的均值。
- std (list|tuple) - 用于每个通道归一化的标准差值。
- data_format (str, optional):数据的格式,必须为 'HWC' 或 'CHW'。默认值:'CHW'。
- to_rgb (bool, optional) - 是否转换为 ``rgb`` 的格式。默认值:False。
- **mean** (list|tuple,可选) - 用于每个通道归一化的均值。
- **std** (list|tuple,可选) - 用于每个通道归一化的标准差值。
- **data_format** (str,可选) - 数据的格式,必须为 'HWC' 或 'CHW'。 默认为 'CHW'。
- **to_rgb** (bool,可选) - 是否转换为 ``rgb`` 的格式。默认为 False。
- **keys** (list[str]|tuple[str],可选) – 与 BaseTransform 相同。默认为 None。

形状
:::::::::

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


返回
:::::::::
Expand All @@ -24,19 +31,5 @@ normalize
代码示例
:::::::::

.. code-block:: python

import numpy as np
from PIL import Image
from paddle.vision.transforms import functional as F

fake_img = (np.random.rand(256, 300, 3) * 255.).astype('uint8')

fake_img = Image.fromarray(fake_img)

mean = [127.5, 127.5, 127.5]
std = [127.5, 127.5, 127.5]
COPY-FROM: paddle.vision.transforms.Normalize:code-example

normalized_img = F.normalize(fake_img, mean, std, data_format='HWC')
print(normalized_img.max(), normalized_img.min())
# 0.99215686 -1.0