Update doc for Unify Transform API - stage 2

This commit is contained in:
luoyang 2022-06-07 15:50:32 +08:00
parent 5c565a0520
commit 076d141913
25 changed files with 286 additions and 408 deletions

View File

@ -0,0 +1,20 @@
mindspore.dataset.transforms.Compose
====================================
.. py:class:: mindspore.dataset.transforms.Compose(transforms)
将多个数据增强算子组合使用。
.. note::
Compose可以将 `mindspore.dataset.transforms` / `mindspore.dataset.vision` 等模块中的数据增强算子以及用户自定义的Python可调用对象
合并成单个数据增强。对于用户定义的Python可调用对象要求其返回值是numpy.ndarray类型。
**参数:**
- **transforms** (list) - 一个数据增强的列表。
**异常:**
- **TypeError** - 参数 `transforms` 类型不为list。
- **ValueError** - 参数 `transforms` 是空的list。
- **TypeError** - 参数 `transforms` 的元素不是Python的可调用对象或audio/text/transforms/vision模块中的数据增强方法。

View File

@ -1,7 +1,7 @@
mindspore.dataset.transforms.c_transforms.Concatenate mindspore.dataset.transforms.Concatenate
===================================================== ========================================
.. py:class:: mindspore.dataset.transforms.c_transforms.Concatenate(axis=0, prepend=None, append=None) .. py:class:: mindspore.dataset.transforms.Concatenate(axis=0, prepend=None, append=None)
在Tensor的某一个轴上进行元素拼接。 在Tensor的某一个轴上进行元素拼接。

View File

@ -1,7 +1,7 @@
mindspore.dataset.transforms.c_transforms.Duplicate mindspore.dataset.transforms.Duplicate
=================================================== ======================================
.. py:class:: mindspore.dataset.transforms.c_transforms.Duplicate() .. py:class:: mindspore.dataset.transforms.Duplicate()
将输入的数据列复制得到新的数据列每次仅可以输入1个数据列进行复制。 将输入的数据列复制得到新的数据列每次仅可以输入1个数据列进行复制。

View File

@ -1,7 +1,7 @@
mindspore.dataset.transforms.c_transforms.Fill mindspore.dataset.transforms.Fill
============================================== =================================
.. py:class:: mindspore.dataset.transforms.c_transforms.Fill(fill_value) .. py:class:: mindspore.dataset.transforms.Fill(fill_value)
将Tensor的所有元素都赋值为指定的值输出Tensor将与输入Tensor具有与具有相同的shape和数据类型。 将Tensor的所有元素都赋值为指定的值输出Tensor将与输入Tensor具有与具有相同的shape和数据类型。

View File

@ -1,7 +1,7 @@
mindspore.dataset.transforms.c_transforms.Mask mindspore.dataset.transforms.Mask
============================================== =================================
.. py:class:: mindspore.dataset.transforms.c_transforms.Mask(operator, constant, dtype=mstype.bool_) .. py:class:: mindspore.dataset.transforms.Mask(operator, constant, dtype=mstype.bool_)
用给条件判断输入Tensor的内容并返回一个掩码Tensor。Tensor中任何符合条件的元素都将被标记为True否则为False。 用给条件判断输入Tensor的内容并返回一个掩码Tensor。Tensor中任何符合条件的元素都将被标记为True否则为False。

View File

@ -1,9 +1,9 @@
mindspore.dataset.transforms.py_transforms.OneHotOp mindspore.dataset.transforms.OneHot
=================================================== ===================================
.. py:class:: mindspore.dataset.transforms.py_transforms.OneHotOp(num_classes, smoothing_rate=0.0) .. py:class:: mindspore.dataset.transforms.OneHot(num_classes, smoothing_rate=0.0)
将Tensor进行OneHot编码,可以进一步对标签进行平滑处理 将Tensor进行OneHot编码。
**参数:** **参数:**
@ -11,7 +11,9 @@ mindspore.dataset.transforms.py_transforms.OneHotOp
- **smoothing_rate** (float可选) - 标签平滑的系数默认值0.0。 - **smoothing_rate** (float可选) - 标签平滑的系数默认值0.0。
**异常:** **异常:**
- **TypeError** - 参数 `num_classes` 类型不为int。 - **TypeError** - 参数 `num_classes` 类型不为int。
- **TypeError** - 参数 `smoothing_rate` 类型不为float。 - **TypeError** - 参数 `smoothing_rate` 类型不为float。
- **ValueError** - 参数 `smoothing_rate` 取值范围不为[0.0, 1.0]。 - **ValueError** - 参数 `smoothing_rate` 取值范围不为[0.0, 1.0]。
- **RuntimeError** - 输入Tensor的数据类型不为int。
- **RuntimeError** - 参数Tensor的shape不是1-D。

View File

@ -1,7 +1,7 @@
mindspore.dataset.transforms.c_transforms.PadEnd mindspore.dataset.transforms.PadEnd
================================================ ===================================
.. py:class:: mindspore.dataset.transforms.c_transforms.PadEnd(pad_shape, pad_value=None) .. py:class:: mindspore.dataset.transforms.PadEnd(pad_shape, pad_value=None)
对输入Tensor进行填充要求 `pad_shape` 与输入Tensor的维度保持一致。 对输入Tensor进行填充要求 `pad_shape` 与输入Tensor的维度保持一致。

View File

@ -1,7 +1,7 @@
mindspore.dataset.transforms.c_transforms.RandomApply mindspore.dataset.transforms.RandomApply
===================================================== ========================================
.. py:class:: mindspore.dataset.transforms.c_transforms.RandomApply(transforms, prob=0.5) .. py:class:: mindspore.dataset.transforms.RandomApply(transforms, prob=0.5)
指定一组数据增强处理及其被应用的概率,在运算时按概率随机应用其中的增强处理。 指定一组数据增强处理及其被应用的概率,在运算时按概率随机应用其中的增强处理。
@ -14,6 +14,6 @@ mindspore.dataset.transforms.c_transforms.RandomApply
- **TypeError** - 参数 `transforms` 类型不为list。 - **TypeError** - 参数 `transforms` 类型不为list。
- **ValueError** - 参数 `transforms` 的长度为空。 - **ValueError** - 参数 `transforms` 的长度为空。
- **TypeError** - 参数 `transforms` 的元素不是Python可调用对象或c_transforms模块中的数据处理操作。 - **TypeError** - 参数 `transforms` 的元素不是Python可调用对象或audio/text/transforms/vision模块中的数据处理操作。
- **TypeError** - 参数 `prob` 的类型不为float。 - **TypeError** - 参数 `prob` 的类型不为float。
- **ValueError** - 参数 `prob` 的取值范围不为[0.0, 1.0]。 - **ValueError** - 参数 `prob` 的取值范围不为[0.0, 1.0]。

View File

@ -1,7 +1,7 @@
mindspore.dataset.transforms.c_transforms.RandomChoice mindspore.dataset.transforms.RandomChoice
====================================================== =========================================
.. py:class:: mindspore.dataset.transforms.c_transforms.RandomChoice(transforms) .. py:class:: mindspore.dataset.transforms.RandomChoice(transforms)
在一组数据增强中随机选择部分增强处理进行应用。 在一组数据增强中随机选择部分增强处理进行应用。
@ -13,4 +13,4 @@ mindspore.dataset.transforms.c_transforms.RandomChoice
- **TypeError** - 参数 `transforms` 类型不为list。 - **TypeError** - 参数 `transforms` 类型不为list。
- **ValueError** - 参数 `transforms` 是空的list。 - **ValueError** - 参数 `transforms` 是空的list。
- **TypeError** - 参数 `transforms` 的元素不是Python可调用对象或c_transforms模块中的数据处理操作。 - **TypeError** - 参数 `transforms` 的元素不是Python可调用对象或audio/text/transforms/vision模块中的数据处理操作。

View File

@ -1,7 +1,7 @@
mindspore.dataset.transforms.py_transforms.RandomOrder mindspore.dataset.transforms.RandomOrder
====================================================== ======================================================
.. py:class:: mindspore.dataset.transforms.py_transforms.RandomOrder(transforms) .. py:class:: mindspore.dataset.transforms.RandomOrder(transforms)
给一个数据增强的列表,随机打乱数据增强处理的顺序。 给一个数据增强的列表,随机打乱数据增强处理的顺序。
@ -12,5 +12,5 @@ mindspore.dataset.transforms.py_transforms.RandomOrder
**异常:** **异常:**
- **TypeError** - 参数 `transforms` 类型不为list。 - **TypeError** - 参数 `transforms` 类型不为list。
- **TypeError** - 参数 `transforms` 的元素不是Python可调用对象或py_transforms模块中的数据处理操作。 - **TypeError** - 参数 `transforms` 的元素不是Python可调用对象或audio/text/transforms/vision模块中的数据处理操作。
- **ValueError** - 参数 `transforms` 是空的list。 - **ValueError** - 参数 `transforms` 是空的list。

View File

@ -1,7 +1,7 @@
mindspore.dataset.transforms.c_transforms.Relational mindspore.dataset.transforms.Relational
==================================================== =======================================
.. py:class:: mindspore.dataset.transforms.c_transforms.Relational .. py:class:: mindspore.dataset.transforms.Relational
关系操作符可以取值为Relational.EQ、Relational.NE、Relational.GT、Relational.GE、Relational.LT、Relational.LE。 关系操作符可以取值为Relational.EQ、Relational.NE、Relational.GT、Relational.GE、Relational.LT、Relational.LE。

View File

@ -1,7 +1,7 @@
mindspore.dataset.transforms.c_transforms.Slice mindspore.dataset.transforms.Slice
=============================================== ==================================
.. py:class:: mindspore.dataset.transforms.c_transforms.Slice(*slices) .. py:class:: mindspore.dataset.transforms.Slice(*slices)
对Tensor进行切片操作功能类似于NumPy的索引(目前只支持1D形状的Tensor)。 对Tensor进行切片操作功能类似于NumPy的索引(目前只支持1D形状的Tensor)。

View File

@ -1,7 +1,7 @@
mindspore.dataset.transforms.c_transforms.TypeCast mindspore.dataset.transforms.TypeCast
================================================== =====================================
.. py:class:: mindspore.dataset.transforms.c_transforms.TypeCast(data_type) .. py:class:: mindspore.dataset.transforms.TypeCast(data_type)
将输入的Tensor转换为指定的数据类型。 将输入的Tensor转换为指定的数据类型。

View File

@ -1,7 +1,7 @@
mindspore.dataset.transforms.c_transforms.Unique mindspore.dataset.transforms.Unique
================================================ ===================================
.. py:class:: mindspore.dataset.transforms.c_transforms.Unique() .. py:class:: mindspore.dataset.transforms.Unique()
对输入张量进行唯一运算,每次只支持对一个数据列进行变换。 对输入张量进行唯一运算,每次只支持对一个数据列进行变换。

View File

@ -1,16 +0,0 @@
mindspore.dataset.transforms.c_transforms.Compose
=================================================
.. py:class:: mindspore.dataset.transforms.c_transforms.Compose(transforms)
将多个数据增强算子组合使用。
**参数:**
- **transforms** (list) - 一个数据增强的列表。
**异常:**
- **TypeError** - 参数 `transforms` 类型不为list。
- **ValueError** - 参数 `transforms` 是空的list。
- **TypeError** - 参数 `transforms` 的元素不是Python可调用对象或c_transforms模块中的数据处理操作。

View File

@ -1,16 +0,0 @@
mindspore.dataset.transforms.c_transforms.OneHot
================================================
.. py:class:: mindspore.dataset.transforms.c_transforms.OneHot(num_classes)
将Tensor进行OneHot编码。
**参数:**
- **num_classes** (int) - 数据集的类别数它应该大于数据集中最大的label编号。
**异常:**
- **TypeError** - 参数 `num_classes` 类型不为int。
- **RuntimeError** - 输入Tensor的数据类型不为int。
- **RuntimeError** - 参数Tensor的shape不是1-D。

View File

@ -1,33 +0,0 @@
mindspore.dataset.transforms.py_transforms.Compose
==================================================
.. py:class:: mindspore.dataset.transforms.py_transforms.Compose(transforms)
将多个数据增强算子组合使用。
.. note::
Compose可以将 `mindspore.dataset.transforms.py_transforms` 模块中的数据增强算子以及用户自定义的Python可调用对象
合并成单个数据增强。对于用户定义的Python可调用对象要求其返回值是numpy.ndarray类型。有关如何使用请参阅Compose的示例或阅读
:class:`mindspore.dataset.vision.py_transforms.FiveCrop` 的示例学习如何与用户自定义Python可调用对象配合使用。
**参数:**
- **transforms** (list) - 一个数据增强的列表。
**异常:**
- **TypeError** - 参数 `transforms` 类型不为list。
- **ValueError** - 参数 `transforms` 是空的list。
- **TypeError** - 参数 `transforms` 的元素不是Python的可调用对象。
.. py:method:: reduce(operations)
使用Compose将指定数据增强操作列表中相邻的Python操作组合以允许混用Python和C++操作。
**参数:**
- **operations** (list) - 数据增强的列表。
**返回:**
list组合后的数据增强操作列表。

View File

@ -1,19 +0,0 @@
mindspore.dataset.transforms.py_transforms.RandomApply
======================================================
.. py:class:: mindspore.dataset.transforms.py_transforms.RandomApply(transforms, prob=0.5)
指定一组数据增强处理及其被应用的概率,在运算时按概率随机应用其中的增强处理。
**参数:**
- **transforms** (list) - 一个数据增强的列表。
- **prob** (float, 可选) - 随机应用某个数据增强的概率默认值0.5。
**异常:**
- **TypeError** - 参数 `transforms` 类型不为list。
- **ValueError** - 参数 `transforms` 为空的list。
- **TypeError** - 参数 `transforms` 的元素不是Python可调用对象或py_transforms模块中的数据处理操作。
- **TypeError** - 参数 `prob` 的类型不为float。
- **ValueError** - 参数 `prob` 的取值范围不为[0.0, 1.0]。

View File

@ -1,16 +0,0 @@
mindspore.dataset.transforms.py_transforms.RandomChoice
=======================================================
.. py:class:: mindspore.dataset.transforms.py_transforms.RandomChoice(transforms)
在一组数据增强中随机选择部分增强处理进行应用。
**参数:**
- **transforms** (list) - 一个数据增强的列表。
**异常:**
- **TypeError** - 参数 `transforms` 类型不为list。
- **TypeError** - 参数 `transforms` 的元素不是Python可调用对象或py_transforms模块中的数据处理操作。
- **ValueError** - 参数 `transforms` 是空的list。

View File

@ -1,19 +1,19 @@
mindspore.dataset.transforms mindspore.dataset.transforms
============================ ============================
此模块用于通用数据增强,包括 `c_transforms``py_transforms` 两个子模块。 此模块用于通用数据增强其中一部分增强操作是用C++实现的具有较好的高性能另一部分是基于Python实现使用了NumPy模块作为支持。
`c_transforms` 是一个高性能数据增强模块基于C++实现。
`py_transforms` 提供了一种基于Python和NumPy的实现方式。
在API示例中常用的模块导入方法如下 在API示例中常用的模块导入方法如下
.. code-block:: .. code-block::
import mindspore.dataset as ds import mindspore.dataset as ds
import mindspore.dataset.vision.c_transforms as c_vision import mindspore.dataset.transforms as transforms
import mindspore.dataset.vision.py_transforms as py_vision
注意旧的API导入方式已经过时且会逐步废弃因此推荐使用上面的方式但目前仍可按以下方式导入
.. code-block::
from mindspore.dataset.transforms import c_transforms from mindspore.dataset.transforms import c_transforms
from mindspore.dataset.transforms import py_transforms from mindspore.dataset.transforms import py_transforms
@ -22,38 +22,34 @@ mindspore.dataset.transforms
- TensorOperation所有C++实现的数据处理操作的基类。 - TensorOperation所有C++实现的数据处理操作的基类。
- PyTensorOperation所有Python实现的数据处理操作的基类。 - PyTensorOperation所有Python实现的数据处理操作的基类。
mindspore.dataset.transforms.c_transforms Transforms
----------------------------------------- ----------
.. mscnautosummary:: .. mscnautosummary::
:toctree: dataset_transforms :toctree: dataset_transforms
:nosignatures: :nosignatures:
:template: classtemplate.rst :template: classtemplate.rst
mindspore.dataset.transforms.c_transforms.Compose mindspore.dataset.transforms.Compose
mindspore.dataset.transforms.c_transforms.Concatenate mindspore.dataset.transforms.Concatenate
mindspore.dataset.transforms.c_transforms.Duplicate mindspore.dataset.transforms.Duplicate
mindspore.dataset.transforms.c_transforms.Fill mindspore.dataset.transforms.Fill
mindspore.dataset.transforms.c_transforms.Mask mindspore.dataset.transforms.Mask
mindspore.dataset.transforms.c_transforms.OneHot mindspore.dataset.transforms.OneHot
mindspore.dataset.transforms.c_transforms.PadEnd mindspore.dataset.transforms.PadEnd
mindspore.dataset.transforms.c_transforms.RandomApply mindspore.dataset.transforms.RandomApply
mindspore.dataset.transforms.c_transforms.RandomChoice mindspore.dataset.transforms.RandomChoice
mindspore.dataset.transforms.c_transforms.Relational mindspore.dataset.transforms.RandomOrder
mindspore.dataset.transforms.c_transforms.Slice mindspore.dataset.transforms.Slice
mindspore.dataset.transforms.c_transforms.TypeCast mindspore.dataset.transforms.TypeCast
mindspore.dataset.transforms.c_transforms.Unique mindspore.dataset.transforms.Unique
mindspore.dataset.transforms.py_transforms Others
------------------------------------------ ------
.. mscnautosummary:: .. mscnautosummary::
:toctree: dataset_transforms :toctree: dataset_transforms
:nosignatures: :nosignatures:
:template: classtemplate.rst :template: classtemplate.rst
mindspore.dataset.transforms.py_transforms.Compose mindspore.dataset.transforms.Relational
mindspore.dataset.transforms.py_transforms.OneHotOp
mindspore.dataset.transforms.py_transforms.RandomApply
mindspore.dataset.transforms.py_transforms.RandomChoice
mindspore.dataset.transforms.py_transforms.RandomOrder

View File

@ -1,12 +1,18 @@
mindspore.dataset.vision mindspore.dataset.vision
=================================== ===================================
此模块用于图像数据增强,包括 `c_transforms``py_transforms` 两个子模块。 此模块用于图像数据增强其中有一部分增强是基于C++ OpenCV实现的具有较好的性能而另一部分是基于Python Pillow实现的。
`c_transforms` 是使用 C++ OpenCv 开发的高性能图像增强模块。
`py_transforms` 是使用 Python Pillow 开发的图像增强模块。
API样例中常用的导入模块如下 API样例中常用的导入模块如下
.. code-block::
import mindspore.dataset as ds
import mindspore.dataset.vision as vision
import mindspore.dataset.vision.utils as utils
注意旧的API导入方式已经过时且会逐步废弃因此推荐使用上面的方式但目前仍可按以下方式导入
.. code-block:: .. code-block::
import mindspore.dataset.vision.c_transforms as c_vision import mindspore.dataset.vision.c_transforms as c_vision
@ -17,113 +23,90 @@ API样例中常用的导入模块如下
- TensorOperation所有C++实现的数据处理操作的基类。 - TensorOperation所有C++实现的数据处理操作的基类。
- PyTensorOperation所有Python实现的数据处理操作的基类。 - PyTensorOperation所有Python实现的数据处理操作的基类。
- ImageTensorOperation所有图像数据处理操作的基类派生自TensorOperation。
mindspore.dataset.vision.c_transforms Transforms
------------------------------------------------ ----------
.. mscnautosummary:: .. mscnautosummary::
:toctree: dataset_vision :toctree: dataset_vision
:nosignatures: :nosignatures:
:template: classtemplate.rst :template: classtemplate.rst
mindspore.dataset.vision.c_transforms.AutoContrast mindspore.dataset.vision.AdjustGamma
mindspore.dataset.vision.c_transforms.BoundingBoxAugment mindspore.dataset.vision.AutoAugment
mindspore.dataset.vision.c_transforms.CenterCrop mindspore.dataset.vision.AutoContrast
mindspore.dataset.vision.c_transforms.ConvertColor mindspore.dataset.vision.BoundingBoxAugment
mindspore.dataset.vision.c_transforms.Crop mindspore.dataset.vision.CenterCrop
mindspore.dataset.vision.c_transforms.CutMixBatch mindspore.dataset.vision.ConvertColor
mindspore.dataset.vision.c_transforms.CutOut mindspore.dataset.vision.Crop
mindspore.dataset.vision.c_transforms.Decode mindspore.dataset.vision.CutMixBatch
mindspore.dataset.vision.c_transforms.Equalize mindspore.dataset.vision.CutOut
mindspore.dataset.vision.c_transforms.GaussianBlur mindspore.dataset.vision.Decode
mindspore.dataset.vision.c_transforms.HorizontalFlip mindspore.dataset.vision.Equalize
mindspore.dataset.vision.c_transforms.HWC2CHW mindspore.dataset.vision.FiveCrop
mindspore.dataset.vision.c_transforms.Invert mindspore.dataset.vision.GaussianBlur
mindspore.dataset.vision.c_transforms.MixUpBatch mindspore.dataset.vision.GrayScale
mindspore.dataset.vision.c_transforms.Normalize mindspore.dataset.vision.HorizontalFlip
mindspore.dataset.vision.c_transforms.NormalizePad mindspore.dataset.vision.HsvToRgb
mindspore.dataset.vision.c_transforms.Pad mindspore.dataset.vision.HWC2CHW
mindspore.dataset.vision.c_transforms.RandomAffine mindspore.dataset.vision.Invert
mindspore.dataset.vision.c_transforms.RandomColor mindspore.dataset.vision.LinearTransformation
mindspore.dataset.vision.c_transforms.RandomColorAdjust mindspore.dataset.vision.MixUp
mindspore.dataset.vision.c_transforms.RandomCrop mindspore.dataset.vision.MixUpBatch
mindspore.dataset.vision.c_transforms.RandomCropDecodeResize mindspore.dataset.vision.Normalize
mindspore.dataset.vision.c_transforms.RandomCropWithBBox mindspore.dataset.vision.NormalizePad
mindspore.dataset.vision.c_transforms.RandomHorizontalFlip mindspore.dataset.vision.Pad
mindspore.dataset.vision.c_transforms.RandomHorizontalFlipWithBBox mindspore.dataset.vision.PadToSize
mindspore.dataset.vision.c_transforms.RandomPosterize mindspore.dataset.vision.RandomAdjustSharpness
mindspore.dataset.vision.c_transforms.RandomResize mindspore.dataset.vision.RandomAffine
mindspore.dataset.vision.c_transforms.RandomResizedCrop mindspore.dataset.vision.RandomAutoContrast
mindspore.dataset.vision.c_transforms.RandomResizedCropWithBBox mindspore.dataset.vision.RandomColor
mindspore.dataset.vision.c_transforms.RandomResizeWithBBox mindspore.dataset.vision.RandomColorAdjust
mindspore.dataset.vision.c_transforms.RandomRotation mindspore.dataset.vision.RandomCrop
mindspore.dataset.vision.c_transforms.RandomSelectSubpolicy mindspore.dataset.vision.RandomCropDecodeResize
mindspore.dataset.vision.c_transforms.RandomSharpness mindspore.dataset.vision.RandomCropWithBBox
mindspore.dataset.vision.c_transforms.RandomSolarize mindspore.dataset.vision.RandomEqualize
mindspore.dataset.vision.c_transforms.RandomVerticalFlip mindspore.dataset.vision.RandomErasing
mindspore.dataset.vision.c_transforms.RandomVerticalFlipWithBBox mindspore.dataset.vision.RandomGrayscale
mindspore.dataset.vision.c_transforms.Rescale mindspore.dataset.vision.RandomHorizontalFlip
mindspore.dataset.vision.c_transforms.Resize mindspore.dataset.vision.RandomHorizontalFlipWithBBox
mindspore.dataset.vision.c_transforms.ResizeWithBBox mindspore.dataset.vision.RandomInvert
mindspore.dataset.vision.c_transforms.Rotate mindspore.dataset.vision.RandomLighting
mindspore.dataset.vision.c_transforms.SlicePatches mindspore.dataset.vision.RandomPerspective
mindspore.dataset.vision.c_transforms.SoftDvppDecodeRandomCropResizeJpeg mindspore.dataset.vision.RandomPosterize
mindspore.dataset.vision.c_transforms.SoftDvppDecodeResizeJpeg mindspore.dataset.vision.RandomResizedCrop
mindspore.dataset.vision.c_transforms.UniformAugment mindspore.dataset.vision.RandomResizedCropWithBBox
mindspore.dataset.vision.c_transforms.VerticalFlip mindspore.dataset.vision.RandomResize
mindspore.dataset.vision.RandomResizeWithBBox
mindspore.dataset.vision.RandomRotation
mindspore.dataset.vision.RandomSelectSubpolicy
mindspore.dataset.vision.RandomSharpness
mindspore.dataset.vision.RandomSolarize
mindspore.dataset.vision.RandomVerticalFlip
mindspore.dataset.vision.RandomVerticalFlipWithBBox
mindspore.dataset.vision.Rescale
mindspore.dataset.vision.Resize
mindspore.dataset.vision.ResizeWithBBox
mindspore.dataset.vision.RgbToHsv
mindspore.dataset.vision.Rotate
mindspore.dataset.vision.SlicePatches
mindspore.dataset.vision.TenCrop
mindspore.dataset.vision.ToNumpy
mindspore.dataset.vision.ToPIL
mindspore.dataset.vision.ToTensor
mindspore.dataset.vision.ToType
mindspore.dataset.vision.UniformAugment
mindspore.dataset.vision.VerticalFlip
mindspore.dataset.vision.py_transforms Others
------------------------------------------------- ------
.. mscnautosummary::
:toctree: dataset_vision
:nosignatures:
:template: classtemplate.rst
mindspore.dataset.vision.py_transforms.AutoContrast
mindspore.dataset.vision.py_transforms.CenterCrop
mindspore.dataset.vision.py_transforms.Cutout
mindspore.dataset.vision.py_transforms.Decode
mindspore.dataset.vision.py_transforms.Equalize
mindspore.dataset.vision.py_transforms.FiveCrop
mindspore.dataset.vision.py_transforms.Grayscale
mindspore.dataset.vision.py_transforms.HsvToRgb
mindspore.dataset.vision.py_transforms.HWC2CHW
mindspore.dataset.vision.py_transforms.Invert
mindspore.dataset.vision.py_transforms.LinearTransformation
mindspore.dataset.vision.py_transforms.MixUp
mindspore.dataset.vision.py_transforms.Normalize
mindspore.dataset.vision.py_transforms.NormalizePad
mindspore.dataset.vision.py_transforms.Pad
mindspore.dataset.vision.py_transforms.RandomAffine
mindspore.dataset.vision.py_transforms.RandomColor
mindspore.dataset.vision.py_transforms.RandomColorAdjust
mindspore.dataset.vision.py_transforms.RandomCrop
mindspore.dataset.vision.py_transforms.RandomErasing
mindspore.dataset.vision.py_transforms.RandomGrayscale
mindspore.dataset.vision.py_transforms.RandomHorizontalFlip
mindspore.dataset.vision.py_transforms.RandomPerspective
mindspore.dataset.vision.py_transforms.RandomResizedCrop
mindspore.dataset.vision.py_transforms.RandomRotation
mindspore.dataset.vision.py_transforms.RandomSharpness
mindspore.dataset.vision.py_transforms.RandomVerticalFlip
mindspore.dataset.vision.py_transforms.Resize
mindspore.dataset.vision.py_transforms.RgbToHsv
mindspore.dataset.vision.py_transforms.TenCrop
mindspore.dataset.vision.py_transforms.ToPIL
mindspore.dataset.vision.py_transforms.ToTensor
mindspore.dataset.vision.py_transforms.ToType
mindspore.dataset.vision.py_transforms.UniformAugment
mindspore.dataset.vision.utils
-------------------------------
.. mscnautosummary:: .. mscnautosummary::
:toctree: dataset_vision :toctree: dataset_vision
:nosignatures: :nosignatures:
:template: classtemplate.rst :template: classtemplate.rst
mindspore.dataset.vision.AutoAugmentPolicy
mindspore.dataset.vision.Border mindspore.dataset.vision.Border
mindspore.dataset.vision.ConvertMode mindspore.dataset.vision.ConvertMode
mindspore.dataset.vision.ImageBatchFormat mindspore.dataset.vision.ImageBatchFormat

View File

@ -3,38 +3,34 @@ mindspore.dataset.transforms
.. automodule:: mindspore.dataset.transforms .. automodule:: mindspore.dataset.transforms
mindspore.dataset.transforms.c_transforms Transforms
----------------------------------------- ----------
.. autosummary:: .. autosummary::
:toctree: dataset_transforms :toctree: dataset_transforms
:nosignatures: :nosignatures:
:template: classtemplate.rst :template: classtemplate.rst
mindspore.dataset.transforms.c_transforms.Compose mindspore.dataset.transforms.Compose
mindspore.dataset.transforms.c_transforms.Concatenate mindspore.dataset.transforms.Concatenate
mindspore.dataset.transforms.c_transforms.Duplicate mindspore.dataset.transforms.Duplicate
mindspore.dataset.transforms.c_transforms.Fill mindspore.dataset.transforms.Fill
mindspore.dataset.transforms.c_transforms.Mask mindspore.dataset.transforms.Mask
mindspore.dataset.transforms.c_transforms.OneHot mindspore.dataset.transforms.OneHot
mindspore.dataset.transforms.c_transforms.PadEnd mindspore.dataset.transforms.PadEnd
mindspore.dataset.transforms.c_transforms.RandomApply mindspore.dataset.transforms.RandomApply
mindspore.dataset.transforms.c_transforms.RandomChoice mindspore.dataset.transforms.RandomChoice
mindspore.dataset.transforms.c_transforms.Relational mindspore.dataset.transforms.RandomOrder
mindspore.dataset.transforms.c_transforms.Slice mindspore.dataset.transforms.Slice
mindspore.dataset.transforms.c_transforms.TypeCast mindspore.dataset.transforms.TypeCast
mindspore.dataset.transforms.c_transforms.Unique mindspore.dataset.transforms.Unique
mindspore.dataset.transforms.py_transforms Others
------------------------------------------ ------
.. autosummary:: .. autosummary::
:toctree: dataset_transforms :toctree: dataset_transforms
:nosignatures: :nosignatures:
:template: classtemplate.rst :template: classtemplate.rst
mindspore.dataset.transforms.py_transforms.Compose mindspore.dataset.transforms.Relational
mindspore.dataset.transforms.py_transforms.OneHotOp
mindspore.dataset.transforms.py_transforms.RandomApply
mindspore.dataset.transforms.py_transforms.RandomChoice
mindspore.dataset.transforms.py_transforms.RandomOrder

View File

@ -3,111 +3,89 @@ mindspore.dataset.vision
.. automodule:: mindspore.dataset.vision .. automodule:: mindspore.dataset.vision
mindspore.dataset.vision.c_transforms Transforms
------------------------------------------------ ----------
.. autosummary:: .. autosummary::
:toctree: dataset_vision :toctree: dataset_vision
:nosignatures: :nosignatures:
:template: classtemplate.rst :template: classtemplate.rst
mindspore.dataset.vision.c_transforms.AutoContrast mindspore.dataset.vision.AdjustGamma
mindspore.dataset.vision.c_transforms.BoundingBoxAugment mindspore.dataset.vision.AutoAugment
mindspore.dataset.vision.c_transforms.CenterCrop mindspore.dataset.vision.AutoContrast
mindspore.dataset.vision.c_transforms.ConvertColor mindspore.dataset.vision.BoundingBoxAugment
mindspore.dataset.vision.c_transforms.Crop mindspore.dataset.vision.CenterCrop
mindspore.dataset.vision.c_transforms.CutMixBatch mindspore.dataset.vision.ConvertColor
mindspore.dataset.vision.c_transforms.CutOut mindspore.dataset.vision.Crop
mindspore.dataset.vision.c_transforms.Decode mindspore.dataset.vision.CutMixBatch
mindspore.dataset.vision.c_transforms.Equalize mindspore.dataset.vision.CutOut
mindspore.dataset.vision.c_transforms.GaussianBlur mindspore.dataset.vision.Decode
mindspore.dataset.vision.c_transforms.HorizontalFlip mindspore.dataset.vision.Equalize
mindspore.dataset.vision.c_transforms.HWC2CHW mindspore.dataset.vision.FiveCrop
mindspore.dataset.vision.c_transforms.Invert mindspore.dataset.vision.GaussianBlur
mindspore.dataset.vision.c_transforms.MixUpBatch mindspore.dataset.vision.GrayScale
mindspore.dataset.vision.c_transforms.Normalize mindspore.dataset.vision.HorizontalFlip
mindspore.dataset.vision.c_transforms.NormalizePad mindspore.dataset.vision.HsvToRgb
mindspore.dataset.vision.c_transforms.Pad mindspore.dataset.vision.HWC2CHW
mindspore.dataset.vision.c_transforms.RandomAffine mindspore.dataset.vision.Invert
mindspore.dataset.vision.c_transforms.RandomColor mindspore.dataset.vision.LinearTransformation
mindspore.dataset.vision.c_transforms.RandomColorAdjust mindspore.dataset.vision.MixUp
mindspore.dataset.vision.c_transforms.RandomCrop mindspore.dataset.vision.MixUpBatch
mindspore.dataset.vision.c_transforms.RandomCropDecodeResize mindspore.dataset.vision.Normalize
mindspore.dataset.vision.c_transforms.RandomCropWithBBox mindspore.dataset.vision.NormalizePad
mindspore.dataset.vision.c_transforms.RandomHorizontalFlip mindspore.dataset.vision.Pad
mindspore.dataset.vision.c_transforms.RandomHorizontalFlipWithBBox mindspore.dataset.vision.PadToSize
mindspore.dataset.vision.c_transforms.RandomPosterize mindspore.dataset.vision.RandomAdjustSharpness
mindspore.dataset.vision.c_transforms.RandomResize mindspore.dataset.vision.RandomAffine
mindspore.dataset.vision.c_transforms.RandomResizedCrop mindspore.dataset.vision.RandomAutoContrast
mindspore.dataset.vision.c_transforms.RandomResizedCropWithBBox mindspore.dataset.vision.RandomColor
mindspore.dataset.vision.c_transforms.RandomResizeWithBBox mindspore.dataset.vision.RandomColorAdjust
mindspore.dataset.vision.c_transforms.RandomRotation mindspore.dataset.vision.RandomCrop
mindspore.dataset.vision.c_transforms.RandomSelectSubpolicy mindspore.dataset.vision.RandomCropDecodeResize
mindspore.dataset.vision.c_transforms.RandomSharpness mindspore.dataset.vision.RandomCropWithBBox
mindspore.dataset.vision.c_transforms.RandomSolarize mindspore.dataset.vision.RandomEqualize
mindspore.dataset.vision.c_transforms.RandomVerticalFlip mindspore.dataset.vision.RandomErasing
mindspore.dataset.vision.c_transforms.RandomVerticalFlipWithBBox mindspore.dataset.vision.RandomGrayscale
mindspore.dataset.vision.c_transforms.Rescale mindspore.dataset.vision.RandomHorizontalFlip
mindspore.dataset.vision.c_transforms.Resize mindspore.dataset.vision.RandomHorizontalFlipWithBBox
mindspore.dataset.vision.c_transforms.ResizeWithBBox mindspore.dataset.vision.RandomInvert
mindspore.dataset.vision.c_transforms.Rotate mindspore.dataset.vision.RandomLighting
mindspore.dataset.vision.c_transforms.SlicePatches mindspore.dataset.vision.RandomPerspective
mindspore.dataset.vision.c_transforms.SoftDvppDecodeRandomCropResizeJpeg mindspore.dataset.vision.RandomPosterize
mindspore.dataset.vision.c_transforms.SoftDvppDecodeResizeJpeg mindspore.dataset.vision.RandomResizedCrop
mindspore.dataset.vision.c_transforms.UniformAugment mindspore.dataset.vision.RandomResizedCropWithBBox
mindspore.dataset.vision.c_transforms.VerticalFlip mindspore.dataset.vision.RandomResize
mindspore.dataset.vision.RandomResizeWithBBox
mindspore.dataset.vision.RandomRotation
mindspore.dataset.vision.RandomSelectSubpolicy
mindspore.dataset.vision.RandomSharpness
mindspore.dataset.vision.RandomSolarize
mindspore.dataset.vision.RandomVerticalFlip
mindspore.dataset.vision.RandomVerticalFlipWithBBox
mindspore.dataset.vision.Rescale
mindspore.dataset.vision.Resize
mindspore.dataset.vision.ResizeWithBBox
mindspore.dataset.vision.RgbToHsv
mindspore.dataset.vision.Rotate
mindspore.dataset.vision.SlicePatches
mindspore.dataset.vision.TenCrop
mindspore.dataset.vision.ToNumpy
mindspore.dataset.vision.ToPIL
mindspore.dataset.vision.ToTensor
mindspore.dataset.vision.ToType
mindspore.dataset.vision.UniformAugment
mindspore.dataset.vision.VerticalFlip
mindspore.dataset.vision.py_transforms Others
------------------------------------------------- ------
.. autosummary::
:toctree: dataset_vision
:nosignatures:
:template: classtemplate.rst
mindspore.dataset.vision.py_transforms.AutoContrast
mindspore.dataset.vision.py_transforms.CenterCrop
mindspore.dataset.vision.py_transforms.Cutout
mindspore.dataset.vision.py_transforms.Decode
mindspore.dataset.vision.py_transforms.Equalize
mindspore.dataset.vision.py_transforms.FiveCrop
mindspore.dataset.vision.py_transforms.Grayscale
mindspore.dataset.vision.py_transforms.HsvToRgb
mindspore.dataset.vision.py_transforms.HWC2CHW
mindspore.dataset.vision.py_transforms.Invert
mindspore.dataset.vision.py_transforms.LinearTransformation
mindspore.dataset.vision.py_transforms.MixUp
mindspore.dataset.vision.py_transforms.Normalize
mindspore.dataset.vision.py_transforms.NormalizePad
mindspore.dataset.vision.py_transforms.Pad
mindspore.dataset.vision.py_transforms.RandomAffine
mindspore.dataset.vision.py_transforms.RandomColor
mindspore.dataset.vision.py_transforms.RandomColorAdjust
mindspore.dataset.vision.py_transforms.RandomCrop
mindspore.dataset.vision.py_transforms.RandomErasing
mindspore.dataset.vision.py_transforms.RandomGrayscale
mindspore.dataset.vision.py_transforms.RandomHorizontalFlip
mindspore.dataset.vision.py_transforms.RandomPerspective
mindspore.dataset.vision.py_transforms.RandomResizedCrop
mindspore.dataset.vision.py_transforms.RandomRotation
mindspore.dataset.vision.py_transforms.RandomSharpness
mindspore.dataset.vision.py_transforms.RandomVerticalFlip
mindspore.dataset.vision.py_transforms.Resize
mindspore.dataset.vision.py_transforms.RgbToHsv
mindspore.dataset.vision.py_transforms.TenCrop
mindspore.dataset.vision.py_transforms.ToPIL
mindspore.dataset.vision.py_transforms.ToTensor
mindspore.dataset.vision.py_transforms.ToType
mindspore.dataset.vision.py_transforms.UniformAugment
mindspore.dataset.vision.utils
-------------------------------
.. autosummary:: .. autosummary::
:toctree: dataset_vision :toctree: dataset_vision
:nosignatures: :nosignatures:
:template: classtemplate.rst :template: classtemplate.rst
mindspore.dataset.vision.AutoAugmentPolicy
mindspore.dataset.vision.Border mindspore.dataset.vision.Border
mindspore.dataset.vision.ConvertMode mindspore.dataset.vision.ConvertMode
mindspore.dataset.vision.ImageBatchFormat mindspore.dataset.vision.ImageBatchFormat

View File

@ -21,7 +21,7 @@ Common imported modules in corresponding API examples are as follows:
.. code-block:: .. code-block::
import mindspore.dataset as ds import mindspore.dataset as ds
import mindspore.dataset.transforms import mindspore.dataset.transforms as transforms
Alternative and equivalent imported transforms is as follows: Alternative and equivalent imported transforms is as follows:

View File

@ -523,9 +523,11 @@ class CutOut(TensorOperation):
Raises: Raises:
TypeError: If `length` is not of type integer. TypeError: If `length` is not of type integer.
TypeError: If `is_hwc` is not of type bool.
TypeError: If `num_patches` is not of type integer. TypeError: If `num_patches` is not of type integer.
ValueError: If `length` is less than or equal 0. ValueError: If `length` is less than or equal 0.
ValueError: If `num_patches` is less than or equal 0. ValueError: If `num_patches` is less than or equal 0.
RuntimeError: If given tensor shape is not <H, W, C>.
Supported Platforms: Supported Platforms:
``CPU`` ``CPU``
@ -2847,7 +2849,7 @@ class RandomVerticalFlip(TensorOperation, PyTensorOperation):
Randomly flip the input image vertically with a given probability. Randomly flip the input image vertically with a given probability.
Args: Args:
prob (float, optional): Probability of the image being flipped (default=0.5). prob (float, optional): Probability of the image being flipped. Default=0.5.
Raises: Raises:
TypeError: If `prob` is not of type float. TypeError: If `prob` is not of type float.
@ -2920,6 +2922,9 @@ class Rescale(TensorOperation):
Rescale the input image with the given rescale and shift. This operator will rescale the input image Rescale the input image with the given rescale and shift. This operator will rescale the input image
with: output = image * rescale + shift. with: output = image * rescale + shift.
Note:
This operation supports running on Ascend or GPU platforms by Offload.
Args: Args:
rescale (float): Rescale factor. rescale (float): Rescale factor.
shift (float): Shift factor. shift (float): Shift factor.
@ -2929,7 +2934,7 @@ class Rescale(TensorOperation):
TypeError: If `shift` is not of type float. TypeError: If `shift` is not of type float.
Supported Platforms: Supported Platforms:
``CPU`` ``CPU`` ``Ascend`` ``GPU``
Examples: Examples:
>>> transforms_list = [vision.Decode(), vision.Rescale(1.0 / 255.0, -1.0)] >>> transforms_list = [vision.Decode(), vision.Rescale(1.0 / 255.0, -1.0)]
@ -2961,20 +2966,14 @@ class Resize(TensorOperation, PyTensorOperation):
It can be any of [Inter.BILINEAR, Inter.LINEAR, Inter.NEAREST, Inter.BICUBIC, Inter.AREA, Inter.PILCUBIC, It can be any of [Inter.BILINEAR, Inter.LINEAR, Inter.NEAREST, Inter.BICUBIC, Inter.AREA, Inter.PILCUBIC,
Inter.ANTIALIAS]. Inter.ANTIALIAS].
- Inter.BILINEAR, means interpolation method is bilinear interpolation. - Inter.BILINEAR, bilinear interpolation.
- Inter.LINEAR, bilinear interpolation, here is the same as Inter.BILINEAR.
- Inter.LINEAR, means interpolation method is bilinear interpolation, here is the same as Inter.BILINEAR. - Inter.NEAREST, nearest-neighbor interpolation.
- Inter.BICUBIC, bicubic interpolation.
- Inter.NEAREST, means interpolation method is nearest-neighbor interpolation. - Inter.AREA, pixel area interpolation.
- Inter.PILCUBIC, bicubic interpolation like implemented in Pillow, only valid when the input is
- Inter.BICUBIC, means interpolation method is bicubic interpolation. a 3-channel image in the numpy.ndarray format.
- Inter.ANTIALIAS, antialias interpolation.
- Inter.AREA, means interpolation method is pixel area interpolation.
- Inter.PILCUBIC, means interpolation method is bicubic interpolation like implemented in Pillow, input
should be in 3 channels format.
- Inter.ANTIALIAS, means antialias interpolation.
Raises: Raises:
TypeError: If `size` is not of type int or Sequence[int]. TypeError: If `size` is not of type int or Sequence[int].
@ -3086,6 +3085,9 @@ class RgbToHsv(PyTensorOperation):
is_hwc (bool): If True, means the input image is in shape of (H, W, C) or (N, H, W, C). is_hwc (bool): If True, means the input image is in shape of (H, W, C) or (N, H, W, C).
Otherwise, it is in shape of (C, H, W) or (N, C, H, W). Default: False. Otherwise, it is in shape of (C, H, W) or (N, C, H, W). Default: False.
Raises:
TypeError: If `is_hwc` is not of type bool.
Supported Platforms: Supported Platforms:
``CPU`` ``CPU``
@ -3303,7 +3305,7 @@ class TenCrop(PyTensorOperation):
class ToNumpy(PyTensorOperation): class ToNumpy(PyTensorOperation):
""" """
Convert the PIL input image to NumPy array. Convert the PIL input image to numpy.ndarray image.
Supported Platforms: Supported Platforms:
``CPU`` ``CPU``
@ -3385,11 +3387,11 @@ class ToPIL(PyTensorOperation):
class ToTensor(TensorOperation, PyTensorOperation): class ToTensor(TensorOperation, PyTensorOperation):
""" """
Rescale of pixel value range from [0, 255] to [0.0, 1.0] and change the shape from (H, W, C) to (C, H, W). Convert the input PIL Image or numpy.ndarray to numpy.ndarray of the desired dtype, rescale the pixel value
Also convert the input PIL Image or numpy.ndarray to numpy.ndarray of the desired dtype. range from [0, 255] to [0.0, 1.0] and change the shape from (H, W, C) to (C, H, W).
Args: Args:
output_type (mindspore.dtype or numpy.dtype, optional): The desired dtype of the output image. output_type (Union[mindspore.dtype, numpy.dtype], optional): The desired dtype of the output image.
Default: :class:`numpy.float32`. Default: :class:`numpy.float32`.
Raises: Raises:
@ -3427,18 +3429,19 @@ class ToTensor(TensorOperation, PyTensorOperation):
class ToType(TypeCast): class ToType(TypeCast):
""" """
Tensor operation to cast to a given MindSpore data type or NumPy data type. Cast the input to a given MindSpore data type or NumPy data type.
Note: This operation is an alias for TypeCast operation.
It is the same as that of :class:`mindspore.dataset.transforms.TypeCast`.
Note: Note:
This operation supports running on Ascend or GPU platforms by Offload. This operation supports running on Ascend or GPU platforms by Offload.
Args: Args:
data_type (mindspore.dtype or numpy.dtype): mindspore.dtype or numpy.dtype (e.g. :class:`numpy.float32`) data_type (Union[mindspore.dtype, numpy.dtype]): The desired data type of the output image,
to be cast to. such as :class:`numpy.float32`.
Raises: Raises:
TypeError: If `data_type` is not of MindSpore data type bool, int, float, string or type :class:`numpy.ndarray`. TypeError: If `data_type` is not of type :class:`mindspore.dtype` or :class:`numpy.dtype`.
Supported Platforms: Supported Platforms:
``CPU`` ``Ascend`` ``GPU`` ``CPU`` ``Ascend`` ``GPU``