| @@ -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: | |||
| @@ -188,13 +188,13 @@ class Dataset: | |||
| except for maybe the last batch for each bucket. | |||
| Args: | |||
| column_names (list of string): Columns passed to element_length_function. | |||
| bucket_boundaries (list of int): A list consisting of the upper boundaries | |||
| column_names (list[str]): Columns passed to element_length_function. | |||
| bucket_boundaries (list[int]): A list consisting of the upper boundaries | |||
| of the buckets. Must be strictly increasing. If there are n boundaries, | |||
| n+1 buckets are created: One bucket for [0, bucket_boundaries[0]), one | |||
| bucket for [bucket_boundaries[i], bucket_boundaries[i+1]) for each | |||
| 0<i<n, and one bucket for [bucket_boundaries[n-1], inf). | |||
| bucket_batch_sizes (list of int): A list consisting of the batch sizes for | |||
| bucket_batch_sizes (list[int]): A list consisting of the batch sizes for | |||
| each bucket. Must contain len(bucket_boundaries)+1 elements. | |||
| element_length_function (Callable, optional): A function that takes in | |||
| len(column_names) arguments and returns an int. If no value is | |||
| @@ -269,7 +269,7 @@ class Dataset: | |||
| (list[Tensor], list[Tensor], ..., BatchInfo) as input parameters. Each list[Tensor] represent a batch of | |||
| Tensors on a given column. The number of lists should match with number of entries in input_columns. The | |||
| last parameter of the callable should always be a BatchInfo object. | |||
| input_columns (list of string, optional): List of names of the input columns. The size of the list should | |||
| input_columns (list[str], optional): List of names of the input columns. The size of the list should | |||
| match with signature of per_batch_map callable. | |||
| pad_info (dict, optional): Whether to perform padding on selected columns. pad_info={"col1":([224,224],0)} | |||
| would pad column with name "col1" to a tensor of size [224,224] and fill the missing with 0. | |||
| @@ -417,7 +417,7 @@ class Dataset: | |||
| input columns expected by the first operator. (default=None, the first | |||
| operation will be passed however many columns that is required, starting from | |||
| the first column). | |||
| operations (list[TensorOp] or Python list[functions]): List of operations to be | |||
| operations (Union[list[TensorOp], list[functions]]): List of operations to be | |||
| applied on the dataset. Operations are applied in the order they appear in this list. | |||
| output_columns (list[str], optional): List of names assigned to the columns outputted by | |||
| the last operation. This parameter is mandatory if len(input_columns) != | |||
| @@ -723,7 +723,7 @@ class Dataset: | |||
| called where ds is a MappableDataset. | |||
| Args: | |||
| sizes (list of int or list of float): If a list of integers [s1, s2, …, sn] is | |||
| sizes (Union[list[int], list[float]]): If a list of integers [s1, s2, …, sn] is | |||
| provided, the dataset will be split into n datasets of size s1, size s2, …, size sn | |||
| respectively. If the sum of all sizes does not equal the original dataset size, an | |||
| an error will occur. | |||
| @@ -805,7 +805,7 @@ class Dataset: | |||
| Zip the datasets in the input tuple of datasets. Columns in the input datasets must not have the same name. | |||
| Args: | |||
| datasets (tuple or class Dataset): A tuple of datasets or a single class Dataset | |||
| datasets (Union[tuple, class Dataset]): A tuple of datasets or a single class Dataset | |||
| to be zipped together with this dataset. | |||
| Returns: | |||
| @@ -834,7 +834,7 @@ class Dataset: | |||
| The column name,column data type and rank of column data should be the same in input datasets. | |||
| Args: | |||
| datasets (list or class Dataset): A list of datasets or a single class Dataset | |||
| datasets (Union[list, class Dataset]): A list of datasets or a single class Dataset | |||
| to be concatenated together with this dataset. | |||
| Returns: | |||
| @@ -1260,10 +1260,10 @@ class Dataset: | |||
| Args: | |||
| condition_name (str): The condition name that is used to toggle sending next row. | |||
| num_batch (int or None): The number of batches(rows) that are released. | |||
| num_batch (Union[int, None]): The number of batches(rows) that are released. | |||
| When num_batch is None, it will default to the number specified by the | |||
| sync_wait operator (default=None). | |||
| data (dict or None): The data passed to the callback (default=None). | |||
| data (Union[dict, None]): The data passed to the callback (default=None). | |||
| """ | |||
| if isinstance(num_batch, int) and num_batch <= 0: | |||
| # throwing exception, disable all sync_wait in pipeline | |||
| @@ -1342,7 +1342,7 @@ class SourceDataset(Dataset): | |||
| Utility function to search for files with the given glob patterns. | |||
| Args: | |||
| patterns (str or list[str]): string or list of patterns to be searched. | |||
| patterns (Union[str, list[str]]): string or list of patterns to be searched. | |||
| Returns: | |||
| List, files. | |||
| @@ -1444,7 +1444,7 @@ class MappableDataset(SourceDataset): | |||
| that calls this function is a MappableDataset. | |||
| Args: | |||
| sizes (list of int or list of float): If a list of integers [s1, s2, …, sn] is | |||
| sizes (Union[list[int], list[float]]): If a list of integers [s1, s2, …, sn] is | |||
| provided, the dataset will be split into n datasets of size s1, size s2, …, size sn | |||
| respectively. If the sum of all sizes does not equal the original dataset size, an | |||
| an error will occur. | |||
| @@ -1592,7 +1592,7 @@ class BatchDataset(DatasetOp): | |||
| Args: | |||
| input_dataset (Dataset): Input Dataset to be batched. | |||
| batch_size (int or function): The number of rows each batch is created with. An | |||
| batch_size (Union[int, function]): The number of rows each batch is created with. An | |||
| int or callable which takes exactly 1 parameter, BatchInfo. | |||
| drop_remainder (bool, optional): Determines whether or not to drop the last | |||
| possibly incomplete batch (default=False). If True, and if there are less | |||
| @@ -1603,7 +1603,7 @@ class BatchDataset(DatasetOp): | |||
| (list[Tensor], list[Tensor], ..., BatchInfo) as input parameters. Each list[Tensor] represent a batch of | |||
| Tensors on a given column. The number of lists should match with number of entries in input_columns. The | |||
| last parameter of the callable should always be a BatchInfo object. | |||
| input_columns (list of string, optional): List of names of the input columns. The size of the list should | |||
| input_columns (list[str], optional): List of names of the input columns. The size of the list should | |||
| match with signature of per_batch_map callable. | |||
| pad_info (dict, optional): Whether to perform padding on selected columns. pad_info={"col1":([224,224],0)} | |||
| would pad column with name "col1" to a tensor of size [224,224] and fill the missing with 0. | |||
| @@ -2442,7 +2442,7 @@ def _select_sampler(num_samples, input_sampler, shuffle, num_shards, shard_id, n | |||
| Args: | |||
| num_samples (int): Number of samples. | |||
| input_sampler (Iterable / Sampler): Sampler from user. | |||
| input_sampler (Union[Iterable, Sampler]): Sampler from user. | |||
| shuffle (bool): Shuffle. | |||
| num_shards (int): Number of shard for sharding. | |||
| shard_id (int): Shard ID. | |||
| @@ -2780,7 +2780,7 @@ class MindDataset(MappableDataset): | |||
| A source dataset that reads from shard files and database. | |||
| Args: | |||
| dataset_file (str, list[str]): One of file names or file list in dataset. | |||
| dataset_file (Union[str, list[str]]): One of file names or file list in dataset. | |||
| columns_list (list[str], optional): List of columns to be read (default=None). | |||
| num_parallel_workers (int, optional): The number of readers (default=None). | |||
| shuffle (bool, optional): Whether or not to perform shuffle on the dataset | |||
| @@ -3152,7 +3152,7 @@ class GeneratorDataset(MappableDataset): | |||
| - not allowed | |||
| Args: | |||
| source (Callable/Iterable/Random Accessible): | |||
| source (Union[Callable, Iterable, Random Accessible]): | |||
| A generator callable object, an iterable python object or a random accessible python object. | |||
| Callable source is required to return a tuple of numpy array as a row of the dataset on source().next(). | |||
| Iterable source is required to return a tuple of numpy array as a row of the dataset on iter(source).next(). | |||
| @@ -3162,14 +3162,14 @@ class GeneratorDataset(MappableDataset): | |||
| provide either column_names or schema. | |||
| column_types (list[mindspore.dtype], optional): List of column data types of the dataset (default=None). | |||
| If provided, sanity check will be performed on generator output. | |||
| schema (Schema/str, optional): Path to the json schema file or schema object (default=None). Users are | |||
| schema (Union[Schema, str], optional): Path to the json schema file or schema object (default=None). Users are | |||
| required to provide either column_names or schema. If both are provided, schema will be used. | |||
| num_samples (int, optional): The number of samples to be included in the dataset | |||
| (default=None, all images). | |||
| num_parallel_workers (int, optional): Number of subprocesses used to fetch the dataset in parallel (default=1). | |||
| shuffle (bool, optional): Whether or not to perform shuffle on the dataset. Random accessible input is required. | |||
| (default=None, expected order behavior shown in the table). | |||
| sampler (Sampler/Iterable, optional): Object used to choose samples from the dataset. Random accessible input is | |||
| sampler (Union[Sampler, Iterable], optional): Object used to choose samples from the dataset. Random accessible input is | |||
| required (default=None, expected order behavior shown in the table). | |||
| num_shards (int, optional): Number of shards that the dataset should be divided into (default=None). | |||
| When this argument is specified, 'num_samples' will not effect. Random accessible input is required. | |||
| @@ -3322,9 +3322,9 @@ class TFRecordDataset(SourceDataset): | |||
| A source dataset that reads and parses datasets stored on disk in TFData format. | |||
| Args: | |||
| dataset_files (str or list[str]): String or list of files to be read or glob strings to search for a pattern of | |||
| dataset_files (Union[str, list[str]]): String or list of files to be read or glob strings to search for a pattern of | |||
| files. The list will be sorted in a lexicographical order. | |||
| schema (str or Schema, optional): Path to the json schema file or schema object (default=None). | |||
| schema (Union[str, Schema], optional): Path to the json schema file or schema object (default=None). | |||
| If the schema is not provided, the meta data from the TFData file is considered the schema. | |||
| columns_list (list[str], optional): List of columns to be read (default=None, read all columns) | |||
| num_samples (int, optional): number of samples(rows) to read (default=None). | |||
| @@ -3333,7 +3333,7 @@ class TFRecordDataset(SourceDataset): | |||
| If both num_samples and numRows(parsed from schema) are greater than 0, read num_samples rows. | |||
| num_parallel_workers (int, optional): number of workers to read the data | |||
| (default=None, number set in the config). | |||
| shuffle (bool, Shuffle level, optional): perform reshuffling of the data every epoch (default=Shuffle.GLOBAL). | |||
| shuffle (Union[bool, Shuffle level], optional): perform reshuffling of the data every epoch (default=Shuffle.GLOBAL). | |||
| If shuffle is False, no shuffling will be performed; | |||
| If shuffle is True, the behavior is the same as setting shuffle to be Shuffle.GLOBAL | |||
| Otherwise, there are two levels of shuffling: | |||
| @@ -3913,7 +3913,7 @@ class RandomDataset(SourceDataset): | |||
| Args: | |||
| total_rows (int): number of rows for the dataset to generate (default=None, number of rows is random) | |||
| schema (str or Schema, optional): Path to the json schema file or schema object (default=None). | |||
| schema (Union[str, Schema], optional): Path to the json schema file or schema object (default=None). | |||
| If the schema is not provided, the random dataset generates a random schema. | |||
| columns_list (list[str], optional): List of columns to be read (default=None, read all columns) | |||
| num_samples (int): number of samples to draw from the total. (default=None, which means all rows) | |||
| @@ -4089,7 +4089,7 @@ class Schema: | |||
| Parse the columns and add it to self. | |||
| Args: | |||
| columns (dict or list[dict]): dataset attribution information, decoded from schema file. | |||
| columns (Union[dict, list[dict]]): dataset attribution information, decoded from schema file. | |||
| - list[dict], 'name' and 'type' must be in keys, 'shape' optional. | |||
| @@ -4702,7 +4702,7 @@ class CLUEDataset(SourceDataset): | |||
| } | |||
| Args: | |||
| dataset_files (str or a list of strings): String or list of files to be read or glob strings to search for | |||
| dataset_files (Union[str, list[str]]): String or list of files to be read or glob strings to search for | |||
| a pattern of files. The list will be sorted in a lexicographical order. | |||
| task (str, optional): The kind of task, one of 'AFQMC', 'TNEWS', 'IFLYTEK', 'CMNLI', 'WSC' and 'CSL'. | |||
| (default=AFQMC). | |||
| @@ -4710,7 +4710,7 @@ class CLUEDataset(SourceDataset): | |||
| num_samples (int, optional): number of samples(rows) to read (default=None, reads the full dataset). | |||
| num_parallel_workers (int, optional): number of workers to read the data | |||
| (default=None, number set in the config). | |||
| shuffle (bool, Shuffle level, optional): perform reshuffling of the data every epoch (default=Shuffle.GLOBAL). | |||
| shuffle (Union[bool, Shuffle level], optional): perform reshuffling of the data every epoch (default=Shuffle.GLOBAL). | |||
| If shuffle is False, no shuffling will be performed; | |||
| If shuffle is True, the behavior is the same as setting shuffle to be Shuffle.GLOBAL | |||
| Otherwise, there are two levels of shuffling: | |||
| @@ -4915,18 +4915,18 @@ class CSVDataset(SourceDataset): | |||
| A source dataset that reads and parses CSV datasets. | |||
| Args: | |||
| dataset_files (str or a list of strings): String or list of files to be read or glob strings to search | |||
| dataset_files (Union[str, list[str]]): String or list of files to be read or glob strings to search | |||
| for a pattern of files. The list will be sorted in a lexicographical order. | |||
| field_delim (str, optional): A string that indicates the char delimiter to separate fields (default=','). | |||
| column_defaults (list, optional): List of default values for the CSV field (default=None). Each item | |||
| in the list is either a valid type (float, int, or string). If this is not provided, treats all | |||
| columns as string type. | |||
| column_names (list of string, optional): List of column names of the dataset (default=None). If this | |||
| column_names (list[str], optional): List of column names of the dataset (default=None). If this | |||
| is not provided, infers the column_names from the first row of CSV file. | |||
| num_samples (int, optional): number of samples(rows) to read (default=None, reads the full dataset). | |||
| num_parallel_workers (int, optional): number of workers to read the data | |||
| (default=None, number set in the config). | |||
| shuffle (bool, Shuffle level, optional): perform reshuffling of the data every epoch (default=Shuffle.GLOBAL). | |||
| shuffle (Union[bool, Shuffle level], optional): perform reshuffling of the data every epoch (default=Shuffle.GLOBAL). | |||
| If shuffle is False, no shuffling will be performed; | |||
| If shuffle is True, the behavior is the same as setting shuffle to be Shuffle.GLOBAL | |||
| Otherwise, there are two levels of shuffling: | |||
| @@ -5018,12 +5018,12 @@ class TextFileDataset(SourceDataset): | |||
| The generated dataset has one columns ['text']. | |||
| Args: | |||
| dataset_files (str or list[str]): String or list of files to be read or glob strings to search for a pattern of | |||
| dataset_files (Union[str, list[str]]): String or list of files to be read or glob strings to search for a pattern of | |||
| files. The list will be sorted in a lexicographical order. | |||
| num_samples (int, optional): number of samples(rows) to read (default=None, reads the full dataset). | |||
| num_parallel_workers (int, optional): number of workers to read the data | |||
| (default=None, number set in the config). | |||
| shuffle (bool, Shuffle level, optional): perform reshuffling of the data every epoch (default=Shuffle.GLOBAL). | |||
| shuffle (Union[bool, Shuffle level], optional): perform reshuffling of the data every epoch (default=Shuffle.GLOBAL). | |||
| If shuffle is False, no shuffling will be performed; | |||
| If shuffle is True, the behavior is the same as setting shuffle to be Shuffle.GLOBAL | |||
| Otherwise, there are two levels of shuffling: | |||
| @@ -5204,7 +5204,7 @@ class NumpySlicesDataset(GeneratorDataset): | |||
| - not allowed | |||
| Args: | |||
| data (list, tuple or dict) Input of Given data, supported data type includes list, tuple, dict and other numpy | |||
| data (Union[list, tuple, dict]) Input of Given data, supported data type includes list, tuple, dict and other numpy | |||
| format. Input data will be sliced in first dimension and generate many rows, large data is not recommend to | |||
| load in this way as data is loading into memory. | |||
| column_names (list[str], optional): List of column names of the dataset (default=None). If column_names not | |||
| @@ -5213,7 +5213,7 @@ class NumpySlicesDataset(GeneratorDataset): | |||
| num_parallel_workers (int, optional): Number of subprocesses used to fetch the dataset in parallel (default=1). | |||
| shuffle (bool, optional): Whether or not to perform shuffle on the dataset. Random accessible input is required. | |||
| (default=None, expected order behavior shown in the table). | |||
| sampler (Sampler/Iterable, optional): Object used to choose samples from the dataset. Random accessible input is | |||
| sampler (Union[Sampler, Iterable], optional): Object used to choose samples from the dataset. Random accessible input is | |||
| required (default=None, expected order behavior shown in the table). | |||
| num_shards (int, optional): Number of shards that the dataset should be divided into (default=None). | |||
| When this argument is specified, 'num_samples' will not effect. Random accessible input is required. | |||
| @@ -5255,7 +5255,7 @@ class BuildVocabDataset(DatasetOp): | |||
| Args: | |||
| vocab(Vocab): text.vocab object. | |||
| columns(str or list, optional): column names to get words from. It can be a list of column names (Default is | |||
| columns(Union[str, list], optional): column names to get words from. It can be a list of column names (Default is | |||
| None, all columns are used, return error if any column isn't string). | |||
| 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/max_frequency | |||
| @@ -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,7 @@ 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 +595,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 +616,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 +642,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 +681,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. | |||