Merge pull request !3532 from guansongsong/gss_fix_apitags/v0.7.0-beta
| @@ -27,7 +27,7 @@ def mstype_to_detype(type_): | |||||
| Get de data type corresponding to mindspore dtype. | Get de data type corresponding to mindspore dtype. | ||||
| Args: | Args: | ||||
| type_ (:class:`mindspore.dtype`): MindSpore's dtype. | |||||
| type_ (mindspore.dtype): MindSpore's dtype. | |||||
| Returns: | Returns: | ||||
| The data type of de. | The data type of de. | ||||
| @@ -57,7 +57,7 @@ def mstypelist_to_detypelist(type_list): | |||||
| Get list[de type] corresponding to list[mindspore.dtype]. | Get list[de type] corresponding to list[mindspore.dtype]. | ||||
| Args: | Args: | ||||
| type_list (:list[mindspore.dtype]): a list of MindSpore's dtype. | |||||
| type_list (list[mindspore.dtype]): a list of MindSpore's dtype. | |||||
| Returns: | Returns: | ||||
| The list of de data type. | The list of de data type. | ||||
| @@ -155,8 +155,8 @@ def parse_user_args(method, *args, **kwargs): | |||||
| Args: | Args: | ||||
| method (method): a callable function. | method (method): a callable function. | ||||
| *args: user passed args. | |||||
| **kwargs: user passed kwargs. | |||||
| args: user passed args. | |||||
| kwargs: user passed kwargs. | |||||
| Returns: | Returns: | ||||
| user_filled_args (list): values of what the user passed in for the arguments. | 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. | Check the type of each parameter in the list. | ||||
| Args: | 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. | 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: | Returns: | ||||
| Exception: when the type is not correct, otherwise nothing. | 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. | Check the type of the parameter. | ||||
| Args: | Args: | ||||
| arg : any variable. | |||||
| arg (Any) : any variable. | |||||
| types (tuple): tuple of all valid types for arg. | types (tuple): tuple of all valid types for arg. | ||||
| arg_name (str): the name of 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. | Check if the input parameter is list or numpy.ndarray. | ||||
| Args: | Args: | ||||
| param (list, nd.ndarray): param. | |||||
| param (Union[list, nd.ndarray]): param. | |||||
| param_name (str): param_name. | param_name (str): param_name. | ||||
| Returns: | Returns: | ||||
| @@ -188,13 +188,13 @@ class Dataset: | |||||
| except for maybe the last batch for each bucket. | except for maybe the last batch for each bucket. | ||||
| Args: | 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, | 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 | n+1 buckets are created: One bucket for [0, bucket_boundaries[0]), one | ||||
| bucket for [bucket_boundaries[i], bucket_boundaries[i+1]) for each | bucket for [bucket_boundaries[i], bucket_boundaries[i+1]) for each | ||||
| 0<i<n, and one bucket for [bucket_boundaries[n-1], inf). | 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. | each bucket. Must contain len(bucket_boundaries)+1 elements. | ||||
| element_length_function (Callable, optional): A function that takes in | element_length_function (Callable, optional): A function that takes in | ||||
| len(column_names) arguments and returns an int. If no value is | 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 | (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 | 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. | 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. | 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)} | 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. | 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 | input columns expected by the first operator. (default=None, the first | ||||
| operation will be passed however many columns that is required, starting from | operation will be passed however many columns that is required, starting from | ||||
| the first column). | 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. | 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 | 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) != | the last operation. This parameter is mandatory if len(input_columns) != | ||||
| @@ -724,7 +724,7 @@ class Dataset: | |||||
| called where ds is a MappableDataset. | called where ds is a MappableDataset. | ||||
| Args: | 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 | 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 | respectively. If the sum of all sizes does not equal the original dataset size, an | ||||
| an error will occur. | an error will occur. | ||||
| @@ -806,7 +806,7 @@ class Dataset: | |||||
| Zip the datasets in the input tuple of datasets. Columns in the input datasets must not have the same name. | Zip the datasets in the input tuple of datasets. Columns in the input datasets must not have the same name. | ||||
| Args: | 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. | to be zipped together with this dataset. | ||||
| Returns: | Returns: | ||||
| @@ -835,7 +835,7 @@ class Dataset: | |||||
| The column name,column data type and rank of column data should be the same in input datasets. | The column name,column data type and rank of column data should be the same in input datasets. | ||||
| Args: | 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. | to be concatenated together with this dataset. | ||||
| Returns: | Returns: | ||||
| @@ -1261,10 +1261,10 @@ class Dataset: | |||||
| Args: | Args: | ||||
| condition_name (str): The condition name that is used to toggle sending next row. | 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 | When num_batch is None, it will default to the number specified by the | ||||
| sync_wait operator (default=None). | 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: | if isinstance(num_batch, int) and num_batch <= 0: | ||||
| # throwing exception, disable all sync_wait in pipeline | # throwing exception, disable all sync_wait in pipeline | ||||
| @@ -1343,7 +1343,7 @@ class SourceDataset(Dataset): | |||||
| Utility function to search for files with the given glob patterns. | Utility function to search for files with the given glob patterns. | ||||
| Args: | 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: | Returns: | ||||
| List, files. | List, files. | ||||
| @@ -1445,7 +1445,7 @@ class MappableDataset(SourceDataset): | |||||
| that calls this function is a MappableDataset. | that calls this function is a MappableDataset. | ||||
| Args: | 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 | 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 | respectively. If the sum of all sizes does not equal the original dataset size, an | ||||
| an error will occur. | an error will occur. | ||||
| @@ -1593,7 +1593,7 @@ class BatchDataset(DatasetOp): | |||||
| Args: | Args: | ||||
| input_dataset (Dataset): Input Dataset to be batched. | 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. | int or callable which takes exactly 1 parameter, BatchInfo. | ||||
| drop_remainder (bool, optional): Determines whether or not to drop the last | drop_remainder (bool, optional): Determines whether or not to drop the last | ||||
| possibly incomplete batch (default=False). If True, and if there are less | possibly incomplete batch (default=False). If True, and if there are less | ||||
| @@ -1604,7 +1604,7 @@ class BatchDataset(DatasetOp): | |||||
| (list[Tensor], list[Tensor], ..., BatchInfo) as input parameters. Each list[Tensor] represent a batch of | (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 | 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. | 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. | 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)} | 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. | would pad column with name "col1" to a tensor of size [224,224] and fill the missing with 0. | ||||
| @@ -2447,7 +2447,7 @@ def _select_sampler(num_samples, input_sampler, shuffle, num_shards, shard_id, n | |||||
| Args: | Args: | ||||
| num_samples (int): Number of samples. | num_samples (int): Number of samples. | ||||
| input_sampler (Iterable / Sampler): Sampler from user. | |||||
| input_sampler (Union[Iterable, Sampler]): Sampler from user. | |||||
| shuffle (bool): Shuffle. | shuffle (bool): Shuffle. | ||||
| num_shards (int): Number of shard for sharding. | num_shards (int): Number of shard for sharding. | ||||
| shard_id (int): Shard ID. | shard_id (int): Shard ID. | ||||
| @@ -2786,7 +2786,7 @@ class MindDataset(MappableDataset): | |||||
| A source dataset that reads from shard files and database. | A source dataset that reads from shard files and database. | ||||
| Args: | 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). | columns_list (list[str], optional): List of columns to be read (default=None). | ||||
| num_parallel_workers (int, optional): The number of readers (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 | shuffle (bool, optional): Whether or not to perform shuffle on the dataset | ||||
| @@ -3158,7 +3158,7 @@ class GeneratorDataset(MappableDataset): | |||||
| - not allowed | - not allowed | ||||
| Args: | 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. | 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(). | 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(). | Iterable source is required to return a tuple of numpy array as a row of the dataset on iter(source).next(). | ||||
| @@ -3168,15 +3168,15 @@ class GeneratorDataset(MappableDataset): | |||||
| provide either column_names or schema. | provide either column_names or schema. | ||||
| column_types (list[mindspore.dtype], optional): List of column data types of the dataset (default=None). | 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. | 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. | 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 | num_samples (int, optional): The number of samples to be included in the dataset | ||||
| (default=None, all images). | (default=None, all images). | ||||
| num_parallel_workers (int, optional): Number of subprocesses used to fetch the dataset in parallel (default=1). | 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. | 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). | (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 | |||||
| required (default=None, expected order behavior shown in the table). | |||||
| 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). | 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. | When this argument is specified, 'num_samples' will not effect. Random accessible input is required. | ||||
| shard_id (int, optional): The shard ID within num_shards (default=None). This argument should be specified only | shard_id (int, optional): The shard ID within num_shards (default=None). This argument should be specified only | ||||
| @@ -3328,9 +3328,9 @@ class TFRecordDataset(SourceDataset): | |||||
| A source dataset that reads and parses datasets stored on disk in TFData format. | A source dataset that reads and parses datasets stored on disk in TFData format. | ||||
| Args: | Args: | ||||
| dataset_files (str or 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). | |||||
| 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 (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. | 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) | 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). | num_samples (int, optional): number of samples(rows) to read (default=None). | ||||
| @@ -3339,7 +3339,8 @@ class TFRecordDataset(SourceDataset): | |||||
| If both num_samples and numRows(parsed from schema) are greater than 0, read num_samples rows. | 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 | num_parallel_workers (int, optional): number of workers to read the data | ||||
| (default=None, number set in the config). | (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 False, no shuffling will be performed; | ||||
| If shuffle is True, the behavior is the same as setting shuffle to be Shuffle.GLOBAL | If shuffle is True, the behavior is the same as setting shuffle to be Shuffle.GLOBAL | ||||
| Otherwise, there are two levels of shuffling: | Otherwise, there are two levels of shuffling: | ||||
| @@ -3920,7 +3921,7 @@ class RandomDataset(SourceDataset): | |||||
| Args: | Args: | ||||
| total_rows (int): number of rows for the dataset to generate (default=None, number of rows is random) | 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. | 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) | 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) | num_samples (int): number of samples to draw from the total. (default=None, which means all rows) | ||||
| @@ -4097,7 +4098,7 @@ class Schema: | |||||
| Parse the columns and add it to self. | Parse the columns and add it to self. | ||||
| Args: | 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. | - list[dict], 'name' and 'type' must be in keys, 'shape' optional. | ||||
| @@ -4710,7 +4711,7 @@ class CLUEDataset(SourceDataset): | |||||
| } | } | ||||
| Args: | 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. | 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'. | task (str, optional): The kind of task, one of 'AFQMC', 'TNEWS', 'IFLYTEK', 'CMNLI', 'WSC' and 'CSL'. | ||||
| (default=AFQMC). | (default=AFQMC). | ||||
| @@ -4718,7 +4719,8 @@ class CLUEDataset(SourceDataset): | |||||
| num_samples (int, optional): number of samples(rows) to read (default=None, reads the full dataset). | 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 | num_parallel_workers (int, optional): number of workers to read the data | ||||
| (default=None, number set in the config). | (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 False, no shuffling will be performed; | ||||
| If shuffle is True, the behavior is the same as setting shuffle to be Shuffle.GLOBAL | If shuffle is True, the behavior is the same as setting shuffle to be Shuffle.GLOBAL | ||||
| Otherwise, there are two levels of shuffling: | Otherwise, there are two levels of shuffling: | ||||
| @@ -4923,18 +4925,19 @@ class CSVDataset(SourceDataset): | |||||
| A source dataset that reads and parses CSV datasets. | A source dataset that reads and parses CSV datasets. | ||||
| Args: | 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. | 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=','). | 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 | 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 | in the list is either a valid type (float, int, or string). If this is not provided, treats all | ||||
| columns as string type. | 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. | 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_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 | num_parallel_workers (int, optional): number of workers to read the data | ||||
| (default=None, number set in the config). | (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 False, no shuffling will be performed; | ||||
| If shuffle is True, the behavior is the same as setting shuffle to be Shuffle.GLOBAL | If shuffle is True, the behavior is the same as setting shuffle to be Shuffle.GLOBAL | ||||
| Otherwise, there are two levels of shuffling: | Otherwise, there are two levels of shuffling: | ||||
| @@ -5026,12 +5029,13 @@ class TextFileDataset(SourceDataset): | |||||
| The generated dataset has one columns ['text']. | The generated dataset has one columns ['text']. | ||||
| Args: | Args: | ||||
| dataset_files (str or 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. | |||||
| 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_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 | num_parallel_workers (int, optional): number of workers to read the data | ||||
| (default=None, number set in the config). | (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 False, no shuffling will be performed; | ||||
| If shuffle is True, the behavior is the same as setting shuffle to be Shuffle.GLOBAL | If shuffle is True, the behavior is the same as setting shuffle to be Shuffle.GLOBAL | ||||
| Otherwise, there are two levels of shuffling: | Otherwise, there are two levels of shuffling: | ||||
| @@ -5212,17 +5216,17 @@ class NumpySlicesDataset(GeneratorDataset): | |||||
| - not allowed | - not allowed | ||||
| Args: | Args: | ||||
| data (list, tuple or 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. | |||||
| 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 | column_names (list[str], optional): List of column names of the dataset (default=None). If column_names not | ||||
| provided, when data is dict, column_names will be its key, otherwise it will be like column_1, column_2 ... | provided, when data is dict, column_names will be its key, otherwise it will be like column_1, column_2 ... | ||||
| num_samples (int, optional): The number of samples to be included in the dataset (default=None, all images). | 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). | 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. | 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). | (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 | |||||
| required (default=None, expected order behavior shown in the table). | |||||
| 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). | 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. | When this argument is specified, 'num_samples' will not effect. Random accessible input is required. | ||||
| shard_id (int, optional): The shard ID within num_shards (default=None). This argument should be specified only | shard_id (int, optional): The shard ID within num_shards (default=None). This argument should be specified only | ||||
| @@ -5263,8 +5267,8 @@ class BuildVocabDataset(DatasetOp): | |||||
| Args: | Args: | ||||
| vocab(Vocab): text.vocab object. | 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 | |||||
| None, all columns are used, return error if any column isn't string). | |||||
| 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 | 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 | range would be kept. 0 <= min_frequency <= max_frequency <= total_words. min_frequency/max_frequency | ||||
| can be None, which corresponds to 0/total_words separately (default=None, all words are included). | can be None, which corresponds to 0/total_words separately (default=None, all words are included). | ||||
| @@ -91,7 +91,7 @@ class GraphData: | |||||
| Get nodes from the edges. | Get nodes from the edges. | ||||
| Args: | Args: | ||||
| edge_list (list or numpy.ndarray): The given list of edges. | |||||
| edge_list (Union[list, numpy.ndarray]): The given list of edges. | |||||
| Returns: | Returns: | ||||
| numpy.ndarray: array of nodes. | numpy.ndarray: array of nodes. | ||||
| @@ -107,7 +107,7 @@ class GraphData: | |||||
| Get `neighbor_type` neighbors of the nodes in `node_list`. | Get `neighbor_type` neighbors of the nodes in `node_list`. | ||||
| Args: | 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. | neighbor_type (int): Specify the type of neighbor. | ||||
| Returns: | Returns: | ||||
| @@ -137,9 +137,9 @@ class GraphData: | |||||
| 2-hop samling result ...] | 2-hop samling result ...] | ||||
| Args: | 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: | Returns: | ||||
| numpy.ndarray: array of nodes. | numpy.ndarray: array of nodes. | ||||
| @@ -164,7 +164,7 @@ class GraphData: | |||||
| Get `neg_neighbor_type` negative sampled neighbors of the nodes in `node_list`. | Get `neg_neighbor_type` negative sampled neighbors of the nodes in `node_list`. | ||||
| Args: | 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_num (int): Number of neighbors sampled. | ||||
| neg_neighbor_type (int): Specify the type of negative neighbor. | 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`. | Get `feature_types` feature of the nodes in `node_list`. | ||||
| Args: | 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: | Returns: | ||||
| numpy.ndarray: array of features. | numpy.ndarray: array of features. | ||||
| @@ -220,8 +220,8 @@ class GraphData: | |||||
| Get `feature_types` feature of the edges in `edge_list`. | Get `feature_types` feature of the edges in `edge_list`. | ||||
| Args: | 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: | Returns: | ||||
| numpy.ndarray: array of features. | numpy.ndarray: array of features. | ||||
| @@ -30,7 +30,7 @@ def serialize(dataset, json_filepath=None): | |||||
| Args: | Args: | ||||
| dataset (Dataset): the starting node. | 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: | Returns: | ||||
| dict containing the serialized dataset graph. | dict containing the serialized dataset graph. | ||||
| @@ -63,7 +63,7 @@ def deserialize(input_dict=None, json_filepath=None): | |||||
| Args: | Args: | ||||
| input_dict (dict): a python dictionary containing a serialized dataset graph | 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: | Returns: | ||||
| de.Dataset or None if error occurs. | 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. | Refer to https://en.wikipedia.org/wiki/N-gram#Examples for an overview of what n-gram is and how it works. | ||||
| Args: | 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 | 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 | 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. | empty string be produced. | ||||
| @@ -199,7 +199,7 @@ class JiebaTokenizer(cde.JiebaTokenizerOp): | |||||
| Add user defined word to JiebaTokenizer's dictionary. | Add user defined word to JiebaTokenizer's dictionary. | ||||
| Args: | 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,...}. | Python Dict format: {word1:freq1, word2:freq2,...}. | ||||
| Jieba dictionary format : word(required), freq(optional), such as: | 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. | Tokenize scalar token or 1-D tokens to tokens by sentencepiece. | ||||
| Args: | 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. | 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): | def __init__(self, mode, out_type): | ||||
| @@ -51,7 +51,7 @@ class Vocab(cde.Vocab): | |||||
| Args: | Args: | ||||
| dataset(Dataset): dataset to build vocab from. | 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). | (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 | 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 | 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. | The output tensor will have the same shape and type as the input tensor. | ||||
| Args: | 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. | to fill created tensor with. | ||||
| """ | """ | ||||
| @@ -78,9 +78,9 @@ class Slice(cde.SliceOp): | |||||
| (Currently only rank-1 tensors are supported). | (Currently only rank-1 tensors are supported). | ||||
| Args: | 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. | 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. | 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`. | 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: | Args: | ||||
| operator (Relational): One of the relational operator EQ, NE LT, GT, LE or GE | 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 | 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: | Examples: | ||||
| >>> # Data before | >>> # Data before | ||||
| @@ -171,7 +171,7 @@ class PadEnd(cde.PadEndOp): | |||||
| Args: | Args: | ||||
| pad_shape (list(int)): list on integers representing the shape needed. Dimensions that set to `None` will | 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. | 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. | string in case of Tensors of strings. | ||||
| Examples: | Examples: | ||||
| @@ -77,7 +77,7 @@ class AutoContrast(cde.AutoContrastOp): | |||||
| Args: | Args: | ||||
| cutoff (float, optional): Percent of pixels to cut off from the histogram (default=0.0). | 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 | @check_auto_contrast | ||||
| @@ -151,10 +151,10 @@ class RandomCrop(cde.RandomCropOp): | |||||
| Crop the input image at a random location. | Crop the input image at a random location. | ||||
| Args: | 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 an int, a square crop of size (size, size) is returned. | ||||
| If size is a sequence of length 2, it should be (height, width). | 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 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 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) | 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. | it pads the left, top, right and bottom respectively. | ||||
| pad_if_needed (bool, optional): Pad the image if either side is smaller than | pad_if_needed (bool, optional): Pad the image if either side is smaller than | ||||
| the given output size (default=False). | 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 | the padding_mode is Border.CONSTANT (default=0). If it is a 3-tuple, it is used to | ||||
| fill R, G, B channels respectively. | fill R, G, B channels respectively. | ||||
| padding_mode (Border mode, optional): The method of padding (default=Border.CONSTANT). Can be any of | 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. | Crop the input image at a random location and adjust bounding boxes accordingly. | ||||
| Args: | 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 an int, a square crop of size (size, size) is returned. | ||||
| If size is a sequence of length 2, it should be (height, width). | 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 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 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) | 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. | 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 | pad_if_needed (bool, optional): Pad the image if either side is smaller than | ||||
| the given output size (default=False). | 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 | the padding_mode is Border.CONSTANT (default=0). If it is a 3-tuple, it is used to | ||||
| fill R, G, B channels respectively. | fill R, G, B channels respectively. | ||||
| padding_mode (Border mode, optional): The method of padding (default=Border.CONSTANT). Can be any of | 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. | Resize the input image to the given size. | ||||
| Args: | 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 | If size is an int, smaller edge of the image will be resized to this value with | ||||
| the same image aspect ratio. | the same image aspect ratio. | ||||
| If size is a sequence of length 2, it should be (height, width). | 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. | Resize the input image to the given size and adjust bounding boxes accordingly. | ||||
| Args: | 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 | If size is an int, smaller edge of the image will be resized to this value with | ||||
| the same image aspect ratio. | the same image aspect ratio. | ||||
| If size is a sequence of length 2, it should be (height, width). | 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. | Crop the input image to a random size and aspect ratio and adjust bounding boxes accordingly. | ||||
| Args: | 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 an int, a square crop of size (size, size) is returned. | ||||
| If size is a sequence of length 2, it should be (height, width). | 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 | 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. | Crop the input image to a random size and aspect ratio. | ||||
| Args: | 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 an int, a square crop of size (size, size) is returned. | ||||
| If size is a sequence of length 2, it should be (height, width). | 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 | 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. | Crops the input image at the center to the given size. | ||||
| Args: | 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 an int, a square crop of size (size, size) is returned. | ||||
| If size is a sequence of length 2, it should be (height, width). | 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. | Randomly adjust the brightness, contrast, saturation, and hue of the input image. | ||||
| Args: | 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 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. | 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 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. | 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 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. | 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 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. | 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. | Rotate the input image by a random angle. | ||||
| Args: | 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 number, the range will be converted to (-degrees, degrees). | ||||
| If degrees is a sequence, it should be (min, max). | If degrees is a sequence, it should be (min, max). | ||||
| resample (Inter mode, optional): An optional resampling filter (default=Inter.NEAREST). | 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. | 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). | 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. | 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 a 3-tuple, it is used for R, G, B channels respectively. | ||||
| If it is an int, it is used for all RGB channels. | 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. | Tensor operation to resize the input image using a randomly selected interpolation mode. | ||||
| Args: | 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 | If size is an int, smaller edge of the image will be resized to this value with | ||||
| the same image aspect ratio. | the same image aspect ratio. | ||||
| If size is a sequence of length 2, it should be (height, width). | If size is a sequence of length 2, it should be (height, width). | ||||
| @@ -616,7 +617,7 @@ class RandomResizeWithBBox(cde.RandomResizeWithBBoxOp): | |||||
| bounding boxes accordingly. | bounding boxes accordingly. | ||||
| Args: | 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 | If size is an int, smaller edge of the image will be resized to this value with | ||||
| the same image aspect ratio. | the same image aspect ratio. | ||||
| If size is a sequence of length 2, it should be (height, width). | 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. | Equivalent to RandomResizedCrop, but crops before decodes. | ||||
| Args: | 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 an int, a square crop of size (size, size) is returned. | ||||
| If size is a sequence of length 2, it should be (height, width). | If size is a sequence of length 2, it should be (height, width). | ||||
| scale (tuple, optional): Range (min, max) of respective size of the | 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. | Pads the image according to padding parameters. | ||||
| Args: | 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 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) | 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. | with the first value and (right and bottom) with the second value. | ||||
| If 4 values are provided as a list or tuple, | If 4 values are provided as a list or tuple, | ||||
| it pads the left, top, right and bottom respectively. | 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 | the padding_mode is Border.CONSTANT (default=0). If it is a 3-tuple, it is used to | ||||
| fill R, G, B channels respectively. | fill R, G, B channels respectively. | ||||
| padding_mode (Border mode): The method of padding (default=Border.CONSTANT). Can be any of | 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. | The range of channel dimension remains the same. | ||||
| Args: | 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: | Examples: | ||||
| >>> py_transforms.ComposeOp([py_transforms.Decode(), | >>> py_transforms.ComposeOp([py_transforms.Decode(), | ||||
| @@ -260,10 +260,10 @@ class RandomCrop: | |||||
| Crop the input PIL Image at a random location. | Crop the input PIL Image at a random location. | ||||
| Args: | 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 an int, a square crop of size (size, size) is returned. | ||||
| If size is a sequence of length 2, it should be (height, width). | 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 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 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) | 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. | Resize the input PIL Image to the given size. | ||||
| Args: | 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 | If size is an int, smaller edge of the image will be resized to this value with | ||||
| the same image aspect ratio. | the same image aspect ratio. | ||||
| If size is a sequence of length 2, it should be (height, width). | 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. | Extract crop from the input image and resize it to a random size and aspect ratio. | ||||
| Args: | 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 an int, a square crop of size (size, size) is returned. | ||||
| If size is a sequence of length 2, it should be (height, width). | 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 | 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. | Crop the central reigion of the input PIL Image to the given size. | ||||
| Args: | 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 an int, a square crop of size (size, size) is returned. | ||||
| If size is a sequence of length 2, it should be (height, width). | 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. | Perform a random brightness, contrast, saturation, and hue adjustment on the input PIL image. | ||||
| Args: | 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 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. | 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 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. | 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 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. | 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 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. | 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. | See https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.Image.rotate. | ||||
| Args: | 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 number, the range will be converted to (-degrees, degrees). | ||||
| If degrees is a sequence, it should be (min, max). | If degrees is a sequence, it should be (min, max). | ||||
| resample (Inter mode, optional): An optional resampling filter (default=Inter.NEAREST). | 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). | Generate 10 cropped images (first 5 from FiveCrop, second 5 from their flipped version). | ||||
| Args: | 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 an int, a square crop of size (size, size) is returned. | ||||
| If size is a sequence of length 2, it should be (height, width). | 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 | 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. | Pad the input PIL image according to padding parameters. | ||||
| Args: | 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 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) | 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. | with the first value and (right and bottom) with the second value. | ||||
| If 4 values are provided as a list or tuple, | If 4 values are provided as a list or tuple, | ||||
| it pads the left, top, right and bottom respectively. | 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. | 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. | 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). | 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)). | original image (default=(0.02, 0.33)). | ||||
| ratio (sequence of floats, optional): Range of the aspect ratio of the erase | ratio (sequence of floats, optional): Range of the aspect ratio of the erase | ||||
| area (default=(0.3, 3.3)). | 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 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 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. | 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. | Apply Random affine transformation to the input PIL image. | ||||
| Args: | 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 number, the range will be (-degrees, degrees). | ||||
| If degrees is a sequence, it should be (min, max). | If degrees is a sequence, it should be (min, max). | ||||
| translate (sequence, optional): Sequence (tx, ty) of maximum translation in | 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. | (-tx*width, tx*width) and (-ty*height, ty*height), respectively. | ||||
| If None, no translations gets applied. | If None, no translations gets applied. | ||||
| scale (sequence, optional): Scaling factor interval (default=None, original scale is used). | 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 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]) | 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. | is applied. | ||||
| @@ -1114,7 +1114,7 @@ class RandomAffine: | |||||
| - Inter.BICUBIC, means resample method is bicubic interpolation. | - 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). | in the output image. Used only in Pillow versions > 5.0.0 (default=0, filling is performed). | ||||
| Raises: | Raises: | ||||
| @@ -1363,7 +1363,7 @@ class AutoContrast: | |||||
| Args: | Args: | ||||
| cutoff (float, optional): Percent of pixels to cut off from the histogram (default=0.0). | 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: | Examples: | ||||
| >>> py_transforms.ComposeOp([py_transforms.Decode(), | >>> 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. | Change the input image (PIL Image or Numpy image array) to numpy format. | ||||
| Args: | 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 | output_type: The datatype of the numpy output. e.g. np.float32 | ||||
| Returns: | Returns: | ||||
| @@ -284,7 +284,7 @@ def resize(img, size, interpolation=Inter.BILINEAR): | |||||
| Args: | Args: | ||||
| img (PIL Image): Image to be resized. | 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 | If size is an int, smaller edge of the image will be resized to this value with | ||||
| the same image aspect ratio. | the same image aspect ratio. | ||||
| If size is a sequence of (height, width), this will be the desired output size. | 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: | Args: | ||||
| img (PIL Image): Image to be cropped. | 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 an int, a square crop of size (size, size) is returned. | ||||
| If size is a sequence of length 2, it should be (height, width). | 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: | Args: | ||||
| img (PIL Image): Image to be randomly cropped and resized. | 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 an int, a square crop of size (size, size) is returned. | ||||
| If size is a sequence of length 2, it should be (height, width). | 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. | 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: | Args: | ||||
| img (PIL Image): Image to be randomly cropped. | 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 an int, a square crop of size (size, size) is returned. | ||||
| If size is a sequence of length 2, it should be (height, width). | 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 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) | 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. | 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. | Default is None. | ||||
| pad_if_needed (bool): Pad the image if either side is smaller than | pad_if_needed (bool): Pad the image if either side is smaller than | ||||
| the given output size. Default is False. | 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 | the padding_mode is 'constant'. If it is a 3-tuple, it is used to | ||||
| fill R, G, B channels respectively. | fill R, G, B channels respectively. | ||||
| padding_mode (str): The method of padding. Can be any of | 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: | Args: | ||||
| img (PIL Image): Image to be rotated. | img (PIL Image): Image to be rotated. | ||||
| angle (int or float): Rotation angle in degrees, counter-clockwise. | 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. | 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 | 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. | 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. | Note that the expand flag assumes rotation around the center and no translation. | ||||
| center (tuple, optional): Optional center of rotation (a 2-tuple). | center (tuple, optional): Optional center of rotation (a 2-tuple). | ||||
| Origin is the top left corner. | 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 a 3-tuple, it is used for R, G, B channels respectively. | ||||
| If it is an int, it is used for all RGB channels. | 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: | Args: | ||||
| img (PIL Image): Image to have its color adjusted randomly. | 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 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. | 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 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. | 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 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. | 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 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. | 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: | Args: | ||||
| img (PIL Image): Image to be rotated. | 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 number, the range will be converted to (-degrees, degrees). | ||||
| If degrees is a sequence, it should be (min, max). | 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. | 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 | 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. | 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. | Note that the expand flag assumes rotation around the center and no translation. | ||||
| center (tuple, optional): Optional center of rotation (a 2-tuple). | center (tuple, optional): Optional center of rotation (a 2-tuple). | ||||
| Origin is the top left corner. | 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 a 3-tuple, it is used for R, G, B channels respectively. | ||||
| If it is an int, it is used for all RGB channels. | If it is an int, it is used for all RGB channels. | ||||
| @@ -789,7 +789,7 @@ def five_crop(img, size): | |||||
| Args: | Args: | ||||
| img (PIL Image): PIL Image to be cropped. | 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 an int, a square crop of size (size, size) is returned. | ||||
| If size is a sequence of length 2, it should be (height, width). | 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: | Args: | ||||
| img (PIL Image): PIL Image to be cropped. | 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 an int, a square crop of size (size, size) is returned. | ||||
| If size is a sequence of length 2, it should be (height, width). | 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. | 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: | Args: | ||||
| img (PIL Image): Image to be padded. | 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 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) | 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. | with the first value and (right and bottom) with the second value. | ||||
| If 4 values are provided as a list or tuple, | If 4 values are provided as a list or tuple, | ||||
| it pads the left, top, right and bottom respectively. | it pads the left, top, right and bottom respectively. | ||||
| Default is None. | 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 | the padding_mode is "constant". If it is a 3-tuple, it is used to | ||||
| fill R, G, B channels respectively. | fill R, G, B channels respectively. | ||||
| padding_mode (str): The method of padding. Can be any of | 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: | Args: | ||||
| img (PIL Image): Image to be applied affine transformation. | 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. | translations (sequence): Translations in horizontal and vertical axis. | ||||
| scale (float): Scale parameter, a single number. | 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. | in the output image. Used only in Pillow versions > 5.0.0. | ||||
| If None, no filling is performed. | If None, no filling is performed. | ||||
| @@ -1465,7 +1465,7 @@ def auto_contrast(img, cutoff, ignore): | |||||
| Args: | Args: | ||||
| img (PIL Image): Image to be augmented with AutoContrast. | img (PIL Image): Image to be augmented with AutoContrast. | ||||
| cutoff (float, optional): Percent of pixels to cut off from the histogram (default=0.0). | 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: | Returns: | ||||
| img (PIL Image), Augmented image. | img (PIL Image), Augmented image. | ||||