提交 eeb8d72a 编写于 作者: M mindspore-ci-bot 提交者: Gitee

!3532 fix python api doc for mindspore .dataset

Merge pull request !3532 from guansongsong/gss_fix_api
......@@ -27,7 +27,7 @@ def mstype_to_detype(type_):
Get de data type corresponding to mindspore dtype.
Args:
type_ (:class:`mindspore.dtype`): MindSpore's dtype.
type_ (mindspore.dtype): MindSpore's dtype.
Returns:
The data type of de.
......@@ -57,7 +57,7 @@ def mstypelist_to_detypelist(type_list):
Get list[de type] corresponding to list[mindspore.dtype].
Args:
type_list (:list[mindspore.dtype]): a list of MindSpore's dtype.
type_list (list[mindspore.dtype]): a list of MindSpore's dtype.
Returns:
The list of de data type.
......
......@@ -155,8 +155,8 @@ def parse_user_args(method, *args, **kwargs):
Args:
method (method): a callable function.
*args: user passed args.
**kwargs: user passed kwargs.
args: user passed args.
kwargs: user passed kwargs.
Returns:
user_filled_args (list): values of what the user passed in for the arguments.
......@@ -181,9 +181,9 @@ def type_check_list(args, types, arg_names):
Check the type of each parameter in the list.
Args:
args (list, tuple): a list or tuple of any variable.
args (Union[list, tuple]): a list or tuple of any variable.
types (tuple): tuple of all valid types for arg.
arg_names (list, tuple of str): the names of args.
arg_names (Union[list, tuple of str]): the names of args.
Returns:
Exception: when the type is not correct, otherwise nothing.
......@@ -202,7 +202,7 @@ def type_check(arg, types, arg_name):
Check the type of the parameter.
Args:
arg : any variable.
arg (Any) : any variable.
types (tuple): tuple of all valid types for arg.
arg_name (str): the name of arg.
......@@ -346,7 +346,7 @@ def check_gnn_list_or_ndarray(param, param_name):
Check if the input parameter is list or numpy.ndarray.
Args:
param (list, nd.ndarray): param.
param (Union[list, nd.ndarray]): param.
param_name (str): param_name.
Returns:
......
......@@ -91,7 +91,7 @@ class GraphData:
Get nodes from the edges.
Args:
edge_list (list or numpy.ndarray): The given list of edges.
edge_list (Union[list, numpy.ndarray]): The given list of edges.
Returns:
numpy.ndarray: array of nodes.
......@@ -107,7 +107,7 @@ class GraphData:
Get `neighbor_type` neighbors of the nodes in `node_list`.
Args:
node_list (list or numpy.ndarray): The given list of nodes.
node_list (Union[list, numpy.ndarray]): The given list of nodes.
neighbor_type (int): Specify the type of neighbor.
Returns:
......@@ -137,9 +137,9 @@ class GraphData:
2-hop samling result ...]
Args:
node_list (list or numpy.ndarray): The given list of nodes.
neighbor_nums (list or numpy.ndarray): Number of neighbors sampled per hop.
neighbor_types (list or numpy.ndarray): Neighbor type sampled per hop.
node_list (Union[list, numpy.ndarray]): The given list of nodes.
neighbor_nums (Union[list, numpy.ndarray]): Number of neighbors sampled per hop.
neighbor_types (Union[list, numpy.ndarray]): Neighbor type sampled per hop.
Returns:
numpy.ndarray: array of nodes.
......@@ -164,7 +164,7 @@ class GraphData:
Get `neg_neighbor_type` negative sampled neighbors of the nodes in `node_list`.
Args:
node_list (list or numpy.ndarray): The given list of nodes.
node_list (Union[list, numpy.ndarray]): The given list of nodes.
neg_neighbor_num (int): Number of neighbors sampled.
neg_neighbor_type (int): Specify the type of negative neighbor.
......@@ -191,8 +191,8 @@ class GraphData:
Get `feature_types` feature of the nodes in `node_list`.
Args:
node_list (list or numpy.ndarray): The given list of nodes.
feature_types (list or numpy.ndarray): The given list of feature types.
node_list (Union[list, numpy.ndarray]): The given list of nodes.
feature_types (Union[list, numpy.ndarray]): The given list of feature types.
Returns:
numpy.ndarray: array of features.
......@@ -220,8 +220,8 @@ class GraphData:
Get `feature_types` feature of the edges in `edge_list`.
Args:
edge_list (list or numpy.ndarray): The given list of edges.
feature_types (list or numpy.ndarray): The given list of feature types.
edge_list (Union[list, numpy.ndarray]): The given list of edges.
feature_types (Union[list, numpy.ndarray]): The given list of feature types.
Returns:
numpy.ndarray: array of features.
......
......@@ -30,7 +30,7 @@ def serialize(dataset, json_filepath=None):
Args:
dataset (Dataset): the starting node.
json_filepath (string): a filepath where a serialized json file will be generated.
json_filepath (str): a filepath where a serialized json file will be generated.
Returns:
dict containing the serialized dataset graph.
......@@ -63,7 +63,7 @@ def deserialize(input_dict=None, json_filepath=None):
Args:
input_dict (dict): a python dictionary containing a serialized dataset graph
json_filepath (string): a path to the json file.
json_filepath (str): a path to the json file.
Returns:
de.Dataset or None if error occurs.
......
......@@ -108,7 +108,7 @@ class Ngram(cde.NgramOp):
Refer to https://en.wikipedia.org/wiki/N-gram#Examples for an overview of what n-gram is and how it works.
Args:
n (list of int): n in n-gram, n >= 1. n is a list of positive integers, for e.g. n=[4,3], The result
n (list[int]): n in n-gram, n >= 1. n is a list of positive integers, for e.g. n=[4,3], The result
would be a 4-gram followed by a 3-gram in the same tensor. If number of words is not enough to make up for
a n-gram, an empty string would be returned. For e.g. 3 grams on ["mindspore","best"] would result in an
empty string be produced.
......@@ -199,7 +199,7 @@ class JiebaTokenizer(cde.JiebaTokenizerOp):
Add user defined word to JiebaTokenizer's dictionary.
Args:
user_dict (str or dict): Dictionary to be added, file path or Python dictionary,
user_dict (Union[str, dict]): Dictionary to be added, file path or Python dictionary,
Python Dict format: {word1:freq1, word2:freq2,...}.
Jieba dictionary format : word(required), freq(optional), such as:
......@@ -339,9 +339,9 @@ class SentencePieceTokenizer(cde.SentencePieceTokenizerOp):
Tokenize scalar token or 1-D tokens to tokens by sentencepiece.
Args:
mode(str or SentencePieceVocab): If the input parameter is a file, then it is of type string,
mode(Union[str, SentencePieceVocab]): If the input parameter is a file, then it is of type string,
if the input parameter is a SentencePieceVocab object, then it is of type SentencePieceVocab.
out_type(str or int): The type of output.
out_type(Union[str, int]): The type of output.
"""
def __init__(self, mode, out_type):
......
......@@ -51,7 +51,7 @@ class Vocab(cde.Vocab):
Args:
dataset(Dataset): dataset to build vocab from.
columns(list of str, optional): column names to get words from. It can be a list of column names.
columns(list[str], optional): column names to get words from. It can be a list of column names.
(default=None, where all columns will be used. If any column isn't string type, will return error).
freq_range(tuple, optional): A tuple of integers (min_frequency, max_frequency). Words within the frequency
range would be kept. 0 <= min_frequency <= max_frequency <= total_words. min_frequency=0 is the same as
......
......@@ -46,7 +46,7 @@ class Fill(cde.FillOp):
The output tensor will have the same shape and type as the input tensor.
Args:
fill_value (python types (str, bytes, int, float, or bool)) : scalar value
fill_value (Union[str, bytes, int, float, bool])) : scalar value
to fill created tensor with.
"""
......@@ -78,9 +78,9 @@ class Slice(cde.SliceOp):
(Currently only rank-1 tensors are supported).
Args:
slices(Variable length argument list, supported types are, int, list[int], slice, None or Ellipses):
Maximum `n` number of arguments to slice a tensor of rank `n`, one object in slices can be one of:
slices(Union[int, list(int), slice, None, Ellipses]):
Maximum `n` number of arguments to slice a tensor of rank `n`.
One object in slices can be one of:
1. :py:obj:`int`: Slice this index only. Negative index is supported.
2. :py:obj:`list(int)`: Slice these indices ion the list only. Negative indices are supported.
3. :py:obj:`slice`: Slice the generated indices from the slice object. Similar to `start:stop:step`.
......@@ -139,9 +139,9 @@ class Mask(cde.MaskOp):
Args:
operator (Relational): One of the relational operator EQ, NE LT, GT, LE or GE
constant (python types (str, int, float, or bool): constant to be compared to.
constant (Union[str, int, float, bool]): constant to be compared to.
Constant will be casted to the type of the input tensor
dtype (optional, mindspore.dtype): type of the generated mask. Default to bool
dtype (mindspore.dtype, optional): type of the generated mask. Default to bool
Examples:
>>> # Data before
......@@ -171,7 +171,7 @@ class PadEnd(cde.PadEndOp):
Args:
pad_shape (list(int)): list on integers representing the shape needed. Dimensions that set to `None` will
not be padded (i.e., original dim will be used). Shorter dimensions will truncate the values.
pad_value (python types (str, bytes, int, float, or bool), optional): value used to pad. Default to 0 or empty
pad_value (Union[str, bytes, int, float, bool]), optional): value used to pad. Default to 0 or empty
string in case of Tensors of strings.
Examples:
......
......@@ -77,7 +77,7 @@ class AutoContrast(cde.AutoContrastOp):
Args:
cutoff (float, optional): Percent of pixels to cut off from the histogram (default=0.0).
ignore (int or sequence, optional): Pixel values to ignore (default=None).
ignore (Union[int, sequence], optional): Pixel values to ignore (default=None).
"""
@check_auto_contrast
......@@ -151,10 +151,10 @@ class RandomCrop(cde.RandomCropOp):
Crop the input image at a random location.
Args:
size (int or sequence): The output size of the cropped image.
size (Union[int, sequence]): The output size of the cropped image.
If size is an int, a square crop of size (size, size) is returned.
If size is a sequence of length 2, it should be (height, width).
padding (int or sequence, optional): The number of pixels to pad the image (default=None).
padding (Union[int, sequence], optional): The number of pixels to pad the image (default=None).
If padding is not None, pad image firstly with padding values.
If a single number is provided, it pads all borders with this value.
If a tuple or list of 2 values are provided, it pads the (left and top)
......@@ -163,7 +163,7 @@ class RandomCrop(cde.RandomCropOp):
it pads the left, top, right and bottom respectively.
pad_if_needed (bool, optional): Pad the image if either side is smaller than
the given output size (default=False).
fill_value (int or tuple, optional): The pixel intensity of the borders if
fill_value (Union[int, tuple], optional): The pixel intensity of the borders if
the padding_mode is Border.CONSTANT (default=0). If it is a 3-tuple, it is used to
fill R, G, B channels respectively.
padding_mode (Border mode, optional): The method of padding (default=Border.CONSTANT). Can be any of
......@@ -206,10 +206,10 @@ class RandomCropWithBBox(cde.RandomCropWithBBoxOp):
Crop the input image at a random location and adjust bounding boxes accordingly.
Args:
size (int or sequence): The output size of the cropped image.
size (Union[int, sequence]): The output size of the cropped image.
If size is an int, a square crop of size (size, size) is returned.
If size is a sequence of length 2, it should be (height, width).
padding (int or sequence, optional): The number of pixels to pad the image (default=None).
padding (Union[int, sequence], optional): The number of pixels to pad the image (default=None).
If padding is not None, pad image firstly with padding values.
If a single number is provided, it pads all borders with this value.
If a tuple or list of 2 values are provided, it pads the (left and top)
......@@ -217,7 +217,7 @@ class RandomCropWithBBox(cde.RandomCropWithBBoxOp):
If 4 values are provided as a list or tuple,it pads the left, top, right and bottom respectively.
pad_if_needed (bool, optional): Pad the image if either side is smaller than
the given output size (default=False).
fill_value (int or tuple, optional): The pixel intensity of the borders if
fill_value (Union[int, tuple], optional): The pixel intensity of the borders if
the padding_mode is Border.CONSTANT (default=0). If it is a 3-tuple, it is used to
fill R, G, B channels respectively.
padding_mode (Border mode, optional): The method of padding (default=Border.CONSTANT). Can be any of
......@@ -335,7 +335,7 @@ class Resize(cde.ResizeOp):
Resize the input image to the given size.
Args:
size (int or sequence): The output size of the resized image.
size (Union[int, sequence]): The output size of the resized image.
If size is an int, smaller edge of the image will be resized to this value with
the same image aspect ratio.
If size is a sequence of length 2, it should be (height, width).
......@@ -365,7 +365,7 @@ class ResizeWithBBox(cde.ResizeWithBBoxOp):
Resize the input image to the given size and adjust bounding boxes accordingly.
Args:
size (int or sequence): The output size of the resized image.
size (Union[int, sequence]): The output size of the resized image.
If size is an int, smaller edge of the image will be resized to this value with
the same image aspect ratio.
If size is a sequence of length 2, it should be (height, width).
......@@ -395,7 +395,7 @@ class RandomResizedCropWithBBox(cde.RandomCropAndResizeWithBBoxOp):
Crop the input image to a random size and aspect ratio and adjust bounding boxes accordingly.
Args:
size (int or sequence): The size of the output image.
size (Union[int, sequence]): The size of the output image.
If size is an int, a square crop of size (size, size) is returned.
If size is a sequence of length 2, it should be (height, width).
scale (tuple, optional): Range (min, max) of respective size of the original
......@@ -434,7 +434,7 @@ class RandomResizedCrop(cde.RandomCropAndResizeOp):
Crop the input image to a random size and aspect ratio.
Args:
size (int or sequence): The size of the output image.
size (Union[int, sequence]): The size of the output image.
If size is an int, a square crop of size (size, size) is returned.
If size is a sequence of length 2, it should be (height, width).
scale (tuple, optional): Range (min, max) of respective size of the original
......@@ -473,7 +473,7 @@ class CenterCrop(cde.CenterCropOp):
Crops the input image at the center to the given size.
Args:
size (int or sequence): The output size of the cropped image.
size (Union[int, sequence]): The output size of the cropped image.
If size is an int, a square crop of size (size, size) is returned.
If size is a sequence of length 2, it should be (height, width).
"""
......@@ -491,16 +491,16 @@ class RandomColorAdjust(cde.RandomColorAdjustOp):
Randomly adjust the brightness, contrast, saturation, and hue of the input image.
Args:
brightness (float or tuple, optional): Brightness adjustment factor (default=(1, 1)). Cannot be negative.
brightness (Union[float, tuple], optional): Brightness adjustment factor (default=(1, 1)). Cannot be negative.
If it is a float, the factor is uniformly chosen from the range [max(0, 1-brightness), 1+brightness].
If it is a sequence, it should be [min, max] for the range.
contrast (float or tuple, optional): Contrast adjustment factor (default=(1, 1)). Cannot be negative.
contrast (Union[float, tuple], optional): Contrast adjustment factor (default=(1, 1)). Cannot be negative.
If it is a float, the factor is uniformly chosen from the range [max(0, 1-contrast), 1+contrast].
If it is a sequence, it should be [min, max] for the range.
saturation (float or tuple, optional): Saturation adjustment factor (default=(1, 1)). Cannot be negative.
saturation (Union[float, tuple], optional): Saturation adjustment factor (default=(1, 1)). Cannot be negative.
If it is a float, the factor is uniformly chosen from the range [max(0, 1-saturation), 1+saturation].
If it is a sequence, it should be [min, max] for the range.
hue (float or tuple, optional): Hue adjustment factor (default=(0, 0)).
hue (Union[float, tuple], optional): Hue adjustment factor (default=(0, 0)).
If it is a float, the range will be [-hue, hue]. Value should be 0 <= hue <= 0.5.
If it is a sequence, it should be [min, max] where -0.5 <= min <= max <= 0.5.
"""
......@@ -533,7 +533,7 @@ class RandomRotation(cde.RandomRotationOp):
Rotate the input image by a random angle.
Args:
degrees (int or float or sequence): Range of random rotation degrees.
degrees (Union[int, float, sequence): Range of random rotation degrees.
If degrees is a number, the range will be converted to (-degrees, degrees).
If degrees is a sequence, it should be (min, max).
resample (Inter mode, optional): An optional resampling filter (default=Inter.NEAREST).
......@@ -552,7 +552,8 @@ class RandomRotation(cde.RandomRotationOp):
Note that the expand flag assumes rotation around the center and no translation.
center (tuple, optional): Optional center of rotation (a 2-tuple) (default=None).
Origin is the top left corner. None sets to the center of the image.
fill_value (int or tuple, optional): Optional fill color for the area outside the rotated image (default=0).
fill_value (Union[int, tuple], optional): Optional fill color for the area outside the rotated image
(default=0).
If it is a 3-tuple, it is used for R, G, B channels respectively.
If it is an int, it is used for all RGB channels.
"""
......@@ -595,7 +596,7 @@ class RandomResize(cde.RandomResizeOp):
Tensor operation to resize the input image using a randomly selected interpolation mode.
Args:
size (int or sequence): The output size of the resized image.
size (Union[int, sequence]): The output size of the resized image.
If size is an int, smaller edge of the image will be resized to this value with
the same image aspect ratio.
If size is a sequence of length 2, it should be (height, width).
......@@ -616,7 +617,7 @@ class RandomResizeWithBBox(cde.RandomResizeWithBBoxOp):
bounding boxes accordingly.
Args:
size (int or sequence): The output size of the resized image.
size (Union[int, sequence]): The output size of the resized image.
If size is an int, smaller edge of the image will be resized to this value with
the same image aspect ratio.
If size is a sequence of length 2, it should be (height, width).
......@@ -642,7 +643,7 @@ class RandomCropDecodeResize(cde.RandomCropDecodeResizeOp):
Equivalent to RandomResizedCrop, but crops before decodes.
Args:
size (int or sequence, optional): The size of the output image.
size (Union[int, sequence], optional): The size of the output image.
If size is an int, a square crop of size (size, size) is returned.
If size is a sequence of length 2, it should be (height, width).
scale (tuple, optional): Range (min, max) of respective size of the
......@@ -681,13 +682,13 @@ class Pad(cde.PadOp):
Pads the image according to padding parameters.
Args:
padding (int or sequence): The number of pixels to pad the image.
padding (Union[int, sequence]): The number of pixels to pad the image.
If a single number is provided, it pads all borders with this value.
If a tuple or list of 2 values are provided, it pads the (left and top)
with the first value and (right and bottom) with the second value.
If 4 values are provided as a list or tuple,
it pads the left, top, right and bottom respectively.
fill_value (int or tuple, optional): The pixel intensity of the borders if
fill_value (Union[int, tuple], optional): The pixel intensity of the borders if
the padding_mode is Border.CONSTANT (default=0). If it is a 3-tuple, it is used to
fill R, G, B channels respectively.
padding_mode (Border mode): The method of padding (default=Border.CONSTANT). Can be any of
......
......@@ -100,7 +100,7 @@ class ToTensor:
The range of channel dimension remains the same.
Args:
output_type (numpy datatype, optional): The datatype of the numpy output (default=numpy.float32).
output_type (numpy datatype, optional): The datatype of the numpy output (default=np.float32).
Examples:
>>> py_transforms.ComposeOp([py_transforms.Decode(),
......@@ -260,10 +260,10 @@ class RandomCrop:
Crop the input PIL Image at a random location.
Args:
size (int or sequence): The output size of the cropped image.
size (Union[int, sequence]): The output size of the cropped image.
If size is an int, a square crop of size (size, size) is returned.
If size is a sequence of length 2, it should be (height, width).
padding (int or sequence, optional): The number of pixels to pad the image (default=None).
padding (Union[int, sequence], optional): The number of pixels to pad the image (default=None).
If padding is not None, pad image firstly with padding values.
If a single number is provided, it pads all borders with this value.
If a tuple or list of 2 values are provided, it pads the (left and top)
......@@ -385,7 +385,7 @@ class Resize:
Resize the input PIL Image to the given size.
Args:
size (int or sequence): The output size of the resized image.
size (Union[int, sequence]): The output size of the resized image.
If size is an int, smaller edge of the image will be resized to this value with
the same image aspect ratio.
If size is a sequence of length 2, it should be (height, width).
......@@ -427,7 +427,7 @@ class RandomResizedCrop:
Extract crop from the input image and resize it to a random size and aspect ratio.
Args:
size (int or sequence): The size of the output image.
size (Union[int, sequence]): The size of the output image.
If size is an int, a square crop of size (size, size) is returned.
If size is a sequence of length 2, it should be (height, width).
scale (tuple, optional): Range (min, max) of respective size of the original size
......@@ -479,7 +479,7 @@ class CenterCrop:
Crop the central reigion of the input PIL Image to the given size.
Args:
size (int or sequence): The output size of the cropped image.
size (Union[int, sequence]): The output size of the cropped image.
If size is an int, a square crop of size (size, size) is returned.
If size is a sequence of length 2, it should be (height, width).
......@@ -511,16 +511,16 @@ class RandomColorAdjust:
Perform a random brightness, contrast, saturation, and hue adjustment on the input PIL image.
Args:
brightness (float or tuple, optional): Brightness adjustment factor (default=(1, 1)). Cannot be negative.
brightness (Union[float, tuple], optional): Brightness adjustment factor (default=(1, 1)). Cannot be negative.
If it is a float, the factor is uniformly chosen from the range [max(0, 1-brightness), 1+brightness].
If it is a sequence, it should be [min, max] for the range.
contrast (float or tuple, optional): Contrast adjustment factor (default=(1, 1)). Cannot be negative.
contrast (Union[float, tuple], optional): Contrast adjustment factor (default=(1, 1)). Cannot be negative.
If it is a float, the factor is uniformly chosen from the range [max(0, 1-contrast), 1+contrast].
If it is a sequence, it should be [min, max] for the range.
saturation (float or tuple, optional): Saturation adjustment factor (default=(1, 1)). Cannot be negative.
saturation (Union[float, tuple], optional): Saturation adjustment factor (default=(1, 1)). Cannot be negative.
If it is a float, the factor is uniformly chosen from the range [max(0, 1-saturation), 1+saturation].
If it is a sequence, it should be [min, max] for the range.
hue (float or tuple, optional): Hue adjustment factor (default=(0, 0)).
hue (Union[float, tuple], optional): Hue adjustment factor (default=(0, 0)).
If it is a float, the range will be [-hue, hue]. Value should be 0 <= hue <= 0.5.
If it is a sequence, it should be [min, max] where -0.5 <= min <= max <= 0.5.
......@@ -558,7 +558,7 @@ class RandomRotation:
See https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.Image.rotate.
Args:
degrees (int or float or sequence): Range of random rotation degrees.
degrees (Union[int, float, sequence]): Range of random rotation degrees.
If degrees is a number, the range will be converted to (-degrees, degrees).
If degrees is a sequence, it should be (min, max).
resample (Inter mode, optional): An optional resampling filter (default=Inter.NEAREST).
......@@ -743,7 +743,7 @@ class TenCrop:
Generate 10 cropped images (first 5 from FiveCrop, second 5 from their flipped version).
Args:
size (int or sequence): The output size of the crop.
size (Union[int, sequence]): The output size of the crop.
If size is an int, a square crop of size (size, size) is returned.
If size is a sequence of length 2, it should be (height, width).
use_vertical_flip (bool, optional): Flip the image vertically instead of horizontally
......@@ -853,13 +853,13 @@ class Pad:
Pad the input PIL image according to padding parameters.
Args:
padding (int or sequence): The number of pixels to pad the image.
padding (Union[int, sequence]): The number of pixels to pad the image.
If a single number is provided, it pads all borders with this value.
If a tuple or list of 2 values are provided, it pads the (left and top)
with the first value and (right and bottom) with the second value.
If 4 values are provided as a list or tuple,
it pads the left, top, right and bottom respectively.
fill_value (int or tuple, optional): Filling value (default=0). The pixel intensity
fill_value (Union[int, tuple], optional): Filling value (default=0). The pixel intensity
of the borders if the padding_mode is Border.CONSTANT.
If it is a 3-tuple, it is used to fill R, G, B channels respectively.
padding_mode (Border mode, optional): The method of padding (default=Border.CONSTANT).
......@@ -961,7 +961,7 @@ class RandomErasing:
original image (default=(0.02, 0.33)).
ratio (sequence of floats, optional): Range of the aspect ratio of the erase
area (default=(0.3, 3.3)).
value (int or sequence): Erasing value (default=0).
value (Union[int, sequence]): Erasing value (default=0).
If value is a single int, it is applied to all pixels to be erases.
If value is a sequence of length 3, it is applied to R, G, B channels respectively.
If value is a str 'random', the erase value will be obtained from a standard normal distribution.
......@@ -1088,7 +1088,7 @@ class RandomAffine:
Apply Random affine transformation to the input PIL image.
Args:
degrees (int or float or sequence): Range of the rotation degrees.
degrees (Union[int, float, sequence]): Range of the rotation degrees.
If degrees is a number, the range will be (-degrees, degrees).
If degrees is a sequence, it should be (min, max).
translate (sequence, optional): Sequence (tx, ty) of maximum translation in
......@@ -1097,7 +1097,7 @@ class RandomAffine:
(-tx*width, tx*width) and (-ty*height, ty*height), respectively.
If None, no translations gets applied.
scale (sequence, optional): Scaling factor interval (default=None, original scale is used).
shear (int or float or sequence, optional): Range of shear factor (default=None).
shear (Union[int, float, sequence], optional): Range of shear factor (default=None).
If a number 'shear', then a shear parallel to the x axis in the range of (-shear, +shear) is applied.
If a tuple or list of size 2, then a shear parallel to the x axis in the range of (shear[0], shear[1])
is applied.
......@@ -1114,7 +1114,7 @@ class RandomAffine:
- Inter.BICUBIC, means resample method is bicubic interpolation.
fill_value (tuple or int, optional): Optional fill_value to fill the area outside the transform
fill_value (Union[tuple, int], optional): Optional fill_value to fill the area outside the transform
in the output image. Used only in Pillow versions > 5.0.0 (default=0, filling is performed).
Raises:
......@@ -1363,7 +1363,7 @@ class AutoContrast:
Args:
cutoff (float, optional): Percent of pixels to cut off from the histogram (default=0.0).
ignore (int or sequence, optional): Pixel values to ignore (default=None).
ignore (Union[int, sequence], optional): Pixel values to ignore (default=None).
Examples:
>>> py_transforms.ComposeOp([py_transforms.Decode(),
......
......@@ -148,7 +148,7 @@ def to_tensor(img, output_type):
Change the input image (PIL Image or Numpy image array) to numpy format.
Args:
img (PIL Image or numpy.ndarray): Image to be converted.
img (Union[PIL Image, numpy.ndarray]): Image to be converted.
output_type: The datatype of the numpy output. e.g. np.float32
Returns:
......@@ -284,7 +284,7 @@ def resize(img, size, interpolation=Inter.BILINEAR):
Args:
img (PIL Image): Image to be resized.
size (int or sequence): The output size of the resized image.
size (Union[int, sequence]): The output size of the resized image.
If size is an int, smaller edge of the image will be resized to this value with
the same image aspect ratio.
If size is a sequence of (height, width), this will be the desired output size.
......@@ -321,7 +321,7 @@ def center_crop(img, size):
Args:
img (PIL Image): Image to be cropped.
size (int or tuple): The size of the crop box.
size (Union[int, tuple]): The size of the crop box.
If size is an int, a square crop of size (size, size) is returned.
If size is a sequence of length 2, it should be (height, width).
......@@ -346,7 +346,7 @@ def random_resize_crop(img, size, scale, ratio, interpolation=Inter.BILINEAR, ma
Args:
img (PIL Image): Image to be randomly cropped and resized.
size (int or sequence): The size of the output image.
size (Union[int, sequence]): The size of the output image.
If size is an int, a square crop of size (size, size) is returned.
If size is a sequence of length 2, it should be (height, width).
scale (tuple): Range (min, max) of respective size of the original size to be cropped.
......@@ -416,10 +416,10 @@ def random_crop(img, size, padding, pad_if_needed, fill_value, padding_mode):
Args:
img (PIL Image): Image to be randomly cropped.
size (int or sequence): The output size of the cropped image.
size (Union[int, sequence]): The output size of the cropped image.
If size is an int, a square crop of size (size, size) is returned.
If size is a sequence of length 2, it should be (height, width).
padding (int or sequence, optional): The number of pixels to pad the image.
padding (Union[int, sequence], optional): The number of pixels to pad the image.
If a single number is provided, it pads all borders with this value.
If a tuple or list of 2 values are provided, it pads the (left and top)
with the first value and (right and bottom) with the second value.
......@@ -428,7 +428,7 @@ def random_crop(img, size, padding, pad_if_needed, fill_value, padding_mode):
Default is None.
pad_if_needed (bool): Pad the image if either side is smaller than
the given output size. Default is False.
fill_value (int or tuple): The pixel intensity of the borders if
fill_value (Union[int, tuple]): The pixel intensity of the borders if
the padding_mode is 'constant'. If it is a 3-tuple, it is used to
fill R, G, B channels respectively.
padding_mode (str): The method of padding. Can be any of
......@@ -602,7 +602,7 @@ def rotate(img, angle, resample, expand, center, fill_value):
Args:
img (PIL Image): Image to be rotated.
angle (int or float): Rotation angle in degrees, counter-clockwise.
resample (Inter.NEAREST, or Inter.BILINEAR, Inter.BICUBIC, optional): An optional resampling filter.
resample (Union[Inter.NEAREST, Inter.BILINEAR, Inter.BICUBIC], optional): An optional resampling filter.
If omitted, or if the image has mode "1" or "P", it is set to be Inter.NEAREST.
expand (bool, optional): Optional expansion flag. If set to True, expand the output
image to make it large enough to hold the entire rotated image.
......@@ -610,7 +610,7 @@ def rotate(img, angle, resample, expand, center, fill_value):
Note that the expand flag assumes rotation around the center and no translation.
center (tuple, optional): Optional center of rotation (a 2-tuple).
Origin is the top left corner.
fill_value (int or tuple): Optional fill color for the area outside the rotated image.
fill_value (Union[int, tuple]): Optional fill color for the area outside the rotated image.
If it is a 3-tuple, it is used for R, G, B channels respectively.
If it is an int, it is used for all RGB channels.
......@@ -634,16 +634,16 @@ def random_color_adjust(img, brightness, contrast, saturation, hue):
Args:
img (PIL Image): Image to have its color adjusted randomly.
brightness (float or tuple): Brightness adjustment factor. Cannot be negative.
brightness (Union[float, tuple]): Brightness adjustment factor. Cannot be negative.
If it is a float, the factor is uniformly chosen from the range [max(0, 1-brightness), 1+brightness].
If it is a sequence, it should be [min, max] for the range.
contrast (float or tuple): Contrast adjustment factor. Cannot be negative.
contrast (Union[float, tuple]): Contrast adjustment factor. Cannot be negative.
If it is a float, the factor is uniformly chosen from the range [max(0, 1-contrast), 1+contrast].
If it is a sequence, it should be [min, max] for the range.
saturation (float or tuple): Saturation adjustment factor. Cannot be negative.
saturation (Union[float, tuple]): Saturation adjustment factor. Cannot be negative.
If it is a float, the factor is uniformly chosen from the range [max(0, 1-saturation), 1+saturation].
If it is a sequence, it should be [min, max] for the range.
hue (float or tuple): Hue adjustment factor.
hue (Union[float, tuple]): Hue adjustment factor.
If it is a float, the range will be [-hue, hue]. Value should be 0 <= hue <= 0.5.
If it is a sequence, it should be [min, max] where -0.5 <= min <= max <= 0.5.
......@@ -696,10 +696,10 @@ def random_rotation(img, degrees, resample, expand, center, fill_value):
Args:
img (PIL Image): Image to be rotated.
degrees (int or float or sequence): Range of random rotation degrees.
degrees (Union[int, float, sequence]): Range of random rotation degrees.
If degrees is a number, the range will be converted to (-degrees, degrees).
If degrees is a sequence, it should be (min, max).
resample (Inter.NEAREST, or Inter.BILINEAR, Inter.BICUBIC, optional): An optional resampling filter.
resample (Union[Inter.NEAREST, Inter.BILINEAR, Inter.BICUBIC], optional): An optional resampling filter.
If omitted, or if the image has mode "1" or "P", it is set to be Inter.NEAREST.
expand (bool, optional): Optional expansion flag. If set to True, expand the output
image to make it large enough to hold the entire rotated image.
......@@ -707,7 +707,7 @@ def random_rotation(img, degrees, resample, expand, center, fill_value):
Note that the expand flag assumes rotation around the center and no translation.
center (tuple, optional): Optional center of rotation (a 2-tuple).
Origin is the top left corner.
fill_value (int or tuple): Optional fill color for the area outside the rotated image.
fill_value (Union[int, tuple]): Optional fill color for the area outside the rotated image.
If it is a 3-tuple, it is used for R, G, B channels respectively.
If it is an int, it is used for all RGB channels.
......@@ -789,7 +789,7 @@ def five_crop(img, size):
Args:
img (PIL Image): PIL Image to be cropped.
size (int or sequence): The output size of the crop.
size (Union[int, sequence]): The output size of the crop.
If size is an int, a square crop of size (size, size) is returned.
If size is a sequence of length 2, it should be (height, width).
......@@ -829,7 +829,7 @@ def ten_crop(img, size, use_vertical_flip=False):
Args:
img (PIL Image): PIL Image to be cropped.
size (int or sequence): The output size of the crop.
size (Union[int, sequence]): The output size of the crop.
If size is an int, a square crop of size (size, size) is returned.
If size is a sequence of length 2, it should be (height, width).
use_vertical_flip (bool): Flip the image vertically instead of horizontally if set to True.
......@@ -895,14 +895,14 @@ def pad(img, padding, fill_value, padding_mode):
Args:
img (PIL Image): Image to be padded.
padding (int or sequence, optional): The number of pixels to pad the image.
padding (Union[int, sequence], optional): The number of pixels to pad the image.
If a single number is provided, it pads all borders with this value.
If a tuple or list of 2 values are provided, it pads the (left and top)
with the first value and (right and bottom) with the second value.
If 4 values are provided as a list or tuple,
it pads the left, top, right and bottom respectively.
Default is None.
fill_value (int or tuple): The pixel intensity of the borders if
fill_value (Union[int, tuple]): The pixel intensity of the borders if
the padding_mode is "constant". If it is a 3-tuple, it is used to
fill R, G, B channels respectively.
padding_mode (str): The method of padding. Can be any of
......@@ -1137,12 +1137,12 @@ def random_affine(img, angle, translations, scale, shear, resample, fill_value=0
Args:
img (PIL Image): Image to be applied affine transformation.
angle (int or float): Rotation angle in degrees, clockwise.
angle (Union[int, float]): Rotation angle in degrees, clockwise.
translations (sequence): Translations in horizontal and vertical axis.
scale (float): Scale parameter, a single number.
shear (float or sequence): Shear amount parallel to x and y axis.
resample (Inter.NEAREST, or Inter.BILINEAR, Inter.BICUBIC, optional): An optional resampling filter.
fill_value (tuple or int, optional): Optional fill_value to fill the area outside the transform
shear (Union[float, sequence]): Shear amount parallel to x and y axis.
resample (Union[Inter.NEAREST, Inter.BILINEAR, Inter.BICUBIC], optional): An optional resampling filter.
fill_value (Union[tuple int], optional): Optional fill_value to fill the area outside the transform
in the output image. Used only in Pillow versions > 5.0.0.
If None, no filling is performed.
......@@ -1465,7 +1465,7 @@ def auto_contrast(img, cutoff, ignore):
Args:
img (PIL Image): Image to be augmented with AutoContrast.
cutoff (float, optional): Percent of pixels to cut off from the histogram (default=0.0).
ignore (int or sequence, optional): Pixel values to ignore (default=None).
ignore (Union[int, sequence], optional): Pixel values to ignore (default=None).
Returns:
img (PIL Image), Augmented image.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册