mindspore 2.1.0__cp37-cp37m-win_amd64.whl → 2.2.11__cp37-cp37m-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of mindspore might be problematic. Click here for more details.
- mindspore/.commit_id +1 -1
- mindspore/Microsoft.VisualStudio.Telemetry.dll +0 -0
- mindspore/Newtonsoft.Json.dll +0 -0
- mindspore/__init__.py +4 -1
- mindspore/_c_dataengine.cp37-win_amd64.pyd +0 -0
- mindspore/_c_expression.cp37-win_amd64.pyd +0 -0
- mindspore/_c_mindrecord.cp37-win_amd64.pyd +0 -0
- mindspore/_check_jit_forbidden_api.py +3 -1
- mindspore/_checkparam.py +23 -29
- mindspore/_extends/graph_kernel/__init__.py +0 -1
- mindspore/_extends/graph_kernel/model/graph_split.py +84 -76
- mindspore/_extends/graph_kernel/model/model_builder.py +9 -50
- mindspore/_extends/graph_kernel/splitter.py +4 -11
- mindspore/_extends/parallel_compile/akg_compiler/akg_process.py +122 -15
- mindspore/_extends/parallel_compile/akg_compiler/build_tbe_kernel.py +84 -67
- mindspore/_extends/parallel_compile/akg_compiler/tbe_topi.py +4 -2
- mindspore/_extends/parallel_compile/akg_compiler/util.py +10 -7
- mindspore/_extends/parallel_compile/tbe_compiler/tbe_adapter.py +2 -2
- mindspore/_extends/parallel_compile/tbe_compiler/tbe_helper.py +6 -5
- mindspore/_extends/parallel_compile/tbe_compiler/tbe_job.py +1 -1
- mindspore/_extends/parallel_compile/tbe_compiler/tbe_job_manager.py +1 -1
- mindspore/_extends/parse/__init__.py +13 -15
- mindspore/_extends/parse/namespace.py +7 -33
- mindspore/_extends/parse/parser.py +67 -72
- mindspore/_extends/parse/resources.py +1 -1
- mindspore/_extends/parse/standard_method.py +86 -106
- mindspore/_extends/parse/trope.py +1 -1
- mindspore/_extends/remote/kernel_build_server.py +25 -7
- mindspore/_extends/remote/kernel_build_server_akg_v2.py +55 -0
- mindspore/_install_custom.py +43 -0
- mindspore/amp.py +47 -11
- mindspore/atlprov.dll +0 -0
- mindspore/boost/boost.py +1 -8
- mindspore/boost/boost_cell_wrapper.py +3 -2
- mindspore/boost/grad_accumulation.py +1 -1
- mindspore/boost/group_loss_scale_manager.py +8 -7
- mindspore/c1.dll +0 -0
- mindspore/c1xx.dll +0 -0
- mindspore/c2.dll +0 -0
- mindspore/common/__init__.py +5 -3
- mindspore/common/_jit_fallback_utils.py +6 -0
- mindspore/common/_register_for_adapter.py +2 -0
- mindspore/common/_register_for_tensor.py +2 -2
- mindspore/common/_stub_tensor.py +13 -0
- mindspore/common/_utils.py +29 -0
- mindspore/common/api.py +174 -259
- mindspore/common/auto_dynamic_shape.py +494 -0
- mindspore/common/dtype.py +18 -11
- mindspore/common/dump.py +6 -4
- mindspore/common/initializer.py +14 -14
- mindspore/common/jit_config.py +33 -15
- mindspore/common/lazy_inline.py +126 -7
- mindspore/common/mindir_util.py +101 -0
- mindspore/common/parameter.py +51 -41
- mindspore/common/seed.py +4 -4
- mindspore/common/sparse_tensor.py +13 -14
- mindspore/common/tensor.py +243 -165
- mindspore/communication/__init__.py +7 -4
- mindspore/communication/_comm_helper.py +83 -4
- mindspore/communication/management.py +152 -84
- mindspore/config/op_info.config +14 -3
- mindspore/context.py +152 -61
- mindspore/dataset/__init__.py +5 -5
- mindspore/dataset/audio/__init__.py +2 -2
- mindspore/dataset/audio/transforms.py +52 -52
- mindspore/dataset/callback/ds_callback.py +16 -2
- mindspore/dataset/core/config.py +68 -51
- mindspore/dataset/engine/cache_client.py +33 -7
- mindspore/dataset/engine/datasets.py +250 -112
- mindspore/dataset/engine/datasets_audio.py +43 -211
- mindspore/dataset/engine/datasets_standard_format.py +16 -35
- mindspore/dataset/engine/datasets_text.py +43 -67
- mindspore/dataset/engine/datasets_user_defined.py +86 -100
- mindspore/dataset/engine/datasets_vision.py +219 -1029
- mindspore/dataset/engine/iterators.py +11 -4
- mindspore/dataset/engine/obs/obs_mindrecord_dataset.py +4 -0
- mindspore/dataset/engine/obs/util.py +3 -0
- mindspore/dataset/engine/samplers.py +1 -1
- mindspore/dataset/engine/validators.py +19 -5
- mindspore/dataset/text/__init__.py +3 -3
- mindspore/dataset/text/transforms.py +101 -127
- mindspore/dataset/text/utils.py +205 -138
- mindspore/dataset/transforms/__init__.py +1 -1
- mindspore/dataset/transforms/py_transforms_util.py +40 -12
- mindspore/dataset/transforms/transforms.py +95 -40
- mindspore/dataset/utils/browse_dataset.py +8 -2
- mindspore/dataset/utils/line_reader.py +17 -19
- mindspore/dataset/vision/__init__.py +3 -3
- mindspore/dataset/vision/c_transforms.py +6 -3
- mindspore/dataset/vision/transforms.py +409 -287
- mindspore/dataset/vision/utils.py +13 -14
- mindspore/dataset/vision/validators.py +11 -1
- mindspore/dnnl.dll +0 -0
- mindspore/dpcmi.dll +0 -0
- mindspore/experimental/map_parameter.py +14 -0
- mindspore/{nn/optim_ex → experimental/optim}/__init__.py +30 -29
- mindspore/{nn/optim_ex → experimental/optim}/adam.py +60 -67
- mindspore/{nn/optim_ex → experimental/optim}/adamw.py +181 -203
- mindspore/experimental/optim/lr_scheduler.py +1427 -0
- mindspore/{nn/optim_ex → experimental/optim}/optimizer.py +252 -259
- mindspore/{nn/optim_ex → experimental/optim}/sgd.py +147 -152
- mindspore/gen_ops.py +273 -0
- mindspore/include/OWNERS +0 -1
- mindspore/include/api/data_type.h +2 -1
- mindspore/include/api/graph.h +0 -15
- mindspore/include/api/kernel.h +2 -0
- mindspore/include/api/kernel_api.h +37 -12
- mindspore/include/api/model.h +17 -14
- mindspore/include/api/status.h +8 -3
- mindspore/include/api/types.h +37 -4
- mindspore/include/c_api/ms/abstract.h +67 -0
- mindspore/include/c_api/ms/attribute.h +197 -0
- mindspore/include/c_api/ms/base/handle_types.h +43 -0
- mindspore/include/c_api/ms/base/macros.h +32 -0
- mindspore/include/c_api/ms/base/status.h +33 -0
- mindspore/include/c_api/ms/base/types.h +282 -0
- mindspore/include/c_api/ms/context.h +102 -0
- mindspore/include/c_api/ms/graph.h +160 -0
- mindspore/include/c_api/ms/node.h +606 -0
- mindspore/include/c_api/ms/tensor.h +161 -0
- mindspore/include/c_api/ms/value.h +84 -0
- mindspore/include/dataset/constants.h +6 -5
- mindspore/include/dataset/execute.h +23 -13
- mindspore/include/dataset/text.h +26 -26
- mindspore/include/dataset/transforms.h +13 -13
- mindspore/include/dataset/vision.h +60 -60
- mindspore/include/dataset/vision_ascend.h +5 -6
- mindspore/include/dataset/vision_lite.h +17 -17
- mindspore/jpeg62.dll +0 -0
- mindspore/mindrecord/tools/imagenet_to_mr.py +1 -1
- mindspore/mindrecord/tools/mnist_to_mr.py +2 -2
- mindspore/mindspore_backend.dll +0 -0
- mindspore/mindspore_common.dll +0 -0
- mindspore/mindspore_core.dll +0 -0
- mindspore/mindspore_glog.dll +0 -0
- mindspore/mindspore_shared_lib.dll +0 -0
- mindspore/msobj140.dll +0 -0
- mindspore/mspdb140.dll +0 -0
- mindspore/mspdbcore.dll +0 -0
- mindspore/mspdbst.dll +0 -0
- mindspore/mspft140.dll +0 -0
- mindspore/msvcdis140.dll +0 -0
- mindspore/msvcp140_1.dll +0 -0
- mindspore/msvcp140_2.dll +0 -0
- mindspore/msvcp140_atomic_wait.dll +0 -0
- mindspore/msvcp140_codecvt_ids.dll +0 -0
- mindspore/nn/__init__.py +0 -2
- mindspore/nn/cell.py +313 -74
- mindspore/nn/dynamic_lr.py +21 -21
- mindspore/nn/layer/activation.py +22 -30
- mindspore/nn/layer/basic.py +15 -13
- mindspore/nn/layer/channel_shuffle.py +1 -1
- mindspore/nn/layer/container.py +271 -9
- mindspore/nn/layer/conv.py +323 -204
- mindspore/nn/layer/dense.py +8 -5
- mindspore/nn/layer/embedding.py +33 -27
- mindspore/nn/layer/flash_attention.py +61 -95
- mindspore/nn/layer/image.py +8 -6
- mindspore/nn/layer/math.py +16 -25
- mindspore/nn/layer/normalization.py +107 -66
- mindspore/nn/layer/padding.py +1 -1
- mindspore/nn/layer/pooling.py +131 -109
- mindspore/nn/layer/rnn_cells.py +27 -22
- mindspore/nn/layer/rnns.py +13 -16
- mindspore/nn/layer/thor_layer.py +1 -1
- mindspore/nn/layer/transformer.py +221 -154
- mindspore/nn/learning_rate_schedule.py +9 -1
- mindspore/nn/loss/loss.py +235 -174
- mindspore/nn/optim/ada_grad.py +2 -1
- mindspore/nn/optim/adadelta.py +1 -0
- mindspore/nn/optim/adafactor.py +2 -1
- mindspore/nn/optim/adam.py +7 -4
- mindspore/nn/optim/adamax.py +3 -2
- mindspore/nn/optim/adasum.py +2 -2
- mindspore/nn/optim/asgd.py +2 -3
- mindspore/nn/optim/ftrl.py +6 -5
- mindspore/nn/optim/lamb.py +7 -4
- mindspore/nn/optim/lars.py +1 -1
- mindspore/nn/optim/lazyadam.py +5 -3
- mindspore/nn/optim/momentum.py +2 -1
- mindspore/nn/optim/optimizer.py +53 -4
- mindspore/nn/optim/proximal_ada_grad.py +3 -4
- mindspore/nn/optim/rmsprop.py +4 -3
- mindspore/nn/optim/rprop.py +23 -12
- mindspore/nn/optim/sgd.py +26 -11
- mindspore/nn/optim/thor.py +9 -7
- mindspore/nn/probability/bijector/bijector.py +5 -5
- mindspore/nn/probability/bijector/power_transform.py +27 -27
- mindspore/nn/probability/bijector/softplus.py +3 -3
- mindspore/nn/probability/distribution/_utils/custom_ops.py +3 -3
- mindspore/nn/probability/distribution/bernoulli.py +5 -5
- mindspore/nn/probability/distribution/beta.py +3 -3
- mindspore/nn/probability/distribution/categorical.py +7 -7
- mindspore/nn/probability/distribution/cauchy.py +0 -1
- mindspore/nn/probability/distribution/distribution.py +3 -3
- mindspore/nn/probability/distribution/gamma.py +3 -3
- mindspore/nn/probability/distribution/geometric.py +4 -4
- mindspore/nn/probability/distribution/gumbel.py +4 -4
- mindspore/nn/probability/distribution/log_normal.py +2 -2
- mindspore/nn/probability/distribution/logistic.py +2 -2
- mindspore/nn/probability/distribution/poisson.py +4 -4
- mindspore/nn/probability/distribution/transformed_distribution.py +3 -3
- mindspore/nn/probability/distribution/uniform.py +6 -6
- mindspore/nn/wrap/__init__.py +4 -2
- mindspore/nn/wrap/cell_wrapper.py +87 -34
- mindspore/nn/wrap/grad_reducer.py +8 -5
- mindspore/nn/wrap/loss_scale.py +105 -42
- mindspore/numpy/array_creations.py +1 -2
- mindspore/numpy/array_ops.py +3 -2
- mindspore/numpy/utils_const.py +5 -5
- mindspore/opencv_core452.dll +0 -0
- mindspore/opencv_imgcodecs452.dll +0 -0
- mindspore/opencv_imgproc452.dll +0 -0
- mindspore/ops/_grad_experimental/__init__.py +0 -5
- mindspore/ops/_grad_experimental/grad_array_ops.py +2 -3
- mindspore/ops/_grad_experimental/grad_comm_ops.py +15 -2
- mindspore/ops/_grad_experimental/grad_debug_ops.py +0 -37
- mindspore/ops/_grad_experimental/grad_implementations.py +11 -1
- mindspore/ops/_grad_experimental/grad_inner_ops.py +2 -216
- mindspore/ops/_grad_experimental/grad_math_ops.py +19 -199
- mindspore/ops/_grad_experimental/grad_sparse.py +15 -0
- mindspore/ops/_grad_experimental/grad_sparse_ops.py +3 -3
- mindspore/ops/_op_impl/_custom_op/dsd_back_impl.py +1 -1
- mindspore/ops/_op_impl/aicpu/__init__.py +14 -2
- mindspore/ops/_op_impl/aicpu/add.py +3 -3
- mindspore/ops/_op_impl/aicpu/bias_add_grad.py +0 -1
- mindspore/ops/_op_impl/aicpu/count_nonzero.py +43 -0
- mindspore/ops/_op_impl/{_custom_op/flash_attention/constants.py → aicpu/eps.py} +18 -27
- mindspore/ops/_op_impl/aicpu/gamma.py +2 -2
- mindspore/ops/_op_impl/aicpu/linear_sum_assignment.py +21 -2
- mindspore/ops/_op_impl/aicpu/log_uniform_candidate_sampler.py +6 -3
- mindspore/ops/_op_impl/aicpu/lu_unpack_grad.py +0 -1
- mindspore/ops/_op_impl/aicpu/multinomial.py +3 -3
- mindspore/ops/_op_impl/aicpu/parameterized_truncated_normal.py +15 -7
- mindspore/ops/_op_impl/aicpu/random_categorical.py +39 -19
- mindspore/ops/_op_impl/aicpu/random_choice_with_mask.py +5 -2
- mindspore/ops/_op_impl/aicpu/random_poisson.py +103 -52
- mindspore/ops/_op_impl/aicpu/random_shuffle.py +17 -15
- mindspore/ops/_op_impl/aicpu/{sparseaddmm.py → sparse_addmm.py} +2 -2
- mindspore/ops/_op_impl/aicpu/{sparsesparsemaximum.py → sparse_sparse_maximum.py} +4 -4
- mindspore/ops/_op_impl/aicpu/standard_laplace.py +5 -5
- mindspore/ops/_op_impl/aicpu/standard_normal.py +5 -5
- mindspore/ops/_op_impl/aicpu/truncated_normal.py +9 -7
- mindspore/ops/_op_impl/aicpu/uniform.py +5 -3
- mindspore/ops/_op_impl/aicpu/uniform_candidate_sampler.py +8 -4
- mindspore/ops/_op_impl/aicpu/uniform_int.py +5 -5
- mindspore/ops/_op_impl/aicpu/uniform_real.py +4 -4
- mindspore/ops/_op_impl/tbe/__init__.py +4 -4
- mindspore/ops/_op_impl/tbe/inplace_index_add.py +7 -3
- mindspore/ops/_op_impl/tbe/trans_data_ds.py +2 -0
- mindspore/ops/_primitive_cache.py +1 -1
- mindspore/ops/_tracefunc.py +45 -13
- mindspore/ops/_utils/utils.py +6 -1
- mindspore/ops/_vmap/vmap_array_ops.py +3 -3
- mindspore/ops/_vmap/vmap_base.py +3 -3
- mindspore/ops/_vmap/vmap_convolution_ops.py +1 -1
- mindspore/ops/_vmap/vmap_grad_math_ops.py +6 -4
- mindspore/ops/_vmap/vmap_math_ops.py +5 -2
- mindspore/ops/_vmap/vmap_nn_ops.py +61 -7
- mindspore/ops/arg_dtype_cast.py +54 -0
- mindspore/ops/composite/base.py +37 -10
- mindspore/ops/composite/math_ops.py +5 -4
- mindspore/ops/composite/multitype_ops/_compile_utils.py +275 -73
- mindspore/ops/composite/multitype_ops/_constexpr_utils.py +16 -9
- mindspore/ops/composite/multitype_ops/add_impl.py +43 -4
- mindspore/ops/composite/multitype_ops/getitem_impl.py +42 -4
- mindspore/ops/composite/multitype_ops/ones_like_impl.py +6 -0
- mindspore/ops/composite/multitype_ops/setitem_impl.py +2 -1
- mindspore/ops/composite/multitype_ops/zeros_like_impl.py +9 -0
- mindspore/ops/deprecated.py +304 -0
- mindspore/ops/function/__init__.py +4 -1
- mindspore/ops/function/array_func.py +174 -193
- mindspore/ops/function/clip_func.py +81 -13
- mindspore/ops/function/debug_func.py +1 -1
- mindspore/ops/function/grad/grad_func.py +18 -9
- mindspore/ops/function/image_func.py +10 -4
- mindspore/ops/function/linalg_func.py +5 -5
- mindspore/ops/function/math_func.py +575 -386
- mindspore/ops/function/nn_func.py +568 -260
- mindspore/ops/function/random_func.py +88 -57
- mindspore/ops/function/sparse_func.py +1 -1
- mindspore/ops/function/sparse_unary_func.py +14 -12
- mindspore/ops/function/vmap_func.py +6 -5
- mindspore/ops/functional.py +15 -10
- mindspore/ops/op_info_register.py +244 -25
- mindspore/ops/operations/__init__.py +31 -19
- mindspore/ops/operations/_grad_ops.py +71 -7
- mindspore/ops/operations/_inner_ops.py +350 -17
- mindspore/ops/operations/_quant_ops.py +4 -8
- mindspore/ops/operations/_sequence_ops.py +42 -0
- mindspore/ops/operations/array_ops.py +68 -282
- mindspore/ops/operations/comm_ops.py +107 -59
- mindspore/ops/operations/custom_ops.py +94 -70
- mindspore/ops/operations/debug_ops.py +8 -4
- mindspore/ops/operations/image_ops.py +18 -12
- mindspore/ops/operations/inner_ops.py +26 -3
- mindspore/ops/operations/math_ops.py +192 -144
- mindspore/ops/operations/nn_ops.py +857 -489
- mindspore/ops/operations/other_ops.py +0 -22
- mindspore/ops/operations/random_ops.py +53 -111
- mindspore/ops/operations/sparse_ops.py +3 -1
- mindspore/ops/primitive.py +24 -18
- mindspore/parallel/_auto_parallel_context.py +68 -8
- mindspore/parallel/_cost_model_context.py +2 -2
- mindspore/parallel/_offload_context.py +17 -3
- mindspore/parallel/_parallel_serialization.py +12 -5
- mindspore/parallel/_ps_context.py +12 -0
- mindspore/parallel/_tensor.py +18 -13
- mindspore/parallel/_transformer/layers.py +5 -3
- mindspore/parallel/_transformer/loss.py +1 -0
- mindspore/parallel/_transformer/moe.py +2 -2
- mindspore/parallel/_transformer/op_parallel_config.py +12 -1
- mindspore/parallel/_transformer/transformer.py +23 -3
- mindspore/parallel/_utils.py +11 -7
- mindspore/parallel/algo_parameter_config.py +85 -5
- mindspore/parallel/checkpoint_transform.py +19 -12
- mindspore/parallel/shard.py +21 -14
- mindspore/pgodb140.dll +0 -0
- mindspore/pgort140.dll +0 -0
- mindspore/profiler/common/struct_type.py +3 -3
- mindspore/profiler/common/util.py +4 -2
- mindspore/profiler/envprofiling.py +1 -1
- mindspore/profiler/parser/aicpu_data_parser.py +5 -3
- mindspore/profiler/parser/ascend_flops_generator.py +2 -2
- mindspore/profiler/parser/ascend_fpbp_generator.py +1 -1
- mindspore/profiler/parser/ascend_hccl_generator.py +249 -12
- mindspore/profiler/parser/ascend_msprof_exporter.py +150 -255
- mindspore/profiler/parser/ascend_msprof_generator.py +204 -17
- mindspore/profiler/parser/ascend_op_generator.py +6 -6
- mindspore/profiler/parser/ascend_steptrace_generator.py +6 -4
- mindspore/profiler/parser/ascend_timeline_generator.py +14 -187
- mindspore/profiler/parser/base_timeline_generator.py +10 -8
- mindspore/profiler/parser/cpu_gpu_timeline_generator.py +16 -12
- mindspore/profiler/parser/flops_parser.py +15 -11
- mindspore/profiler/parser/framework_parser.py +38 -22
- mindspore/profiler/parser/hccl_parser.py +16 -12
- mindspore/profiler/parser/integrator.py +22 -11
- mindspore/profiler/parser/memory_usage_parser.py +2 -2
- mindspore/profiler/parser/minddata_analyzer.py +12 -14
- mindspore/profiler/parser/minddata_pipeline_parser.py +1 -1
- mindspore/profiler/parser/msadvisor_parser.py +8 -4
- mindspore/profiler/parser/op_intermediate_parser.py +5 -2
- mindspore/profiler/parser/optime_parser.py +1 -1
- mindspore/profiler/parser/profiler_info.py +21 -2
- mindspore/profiler/parser/step_trace_parser.py +11 -14
- mindspore/profiler/profiling.py +179 -89
- mindspore/rewrite/api/node.py +102 -19
- mindspore/rewrite/api/node_type.py +5 -1
- mindspore/rewrite/api/pattern_engine.py +1 -1
- mindspore/rewrite/api/scoped_value.py +9 -17
- mindspore/rewrite/api/symbol_tree.py +131 -47
- mindspore/rewrite/ast_helpers/__init__.py +2 -1
- mindspore/rewrite/ast_helpers/ast_finder.py +129 -0
- mindspore/rewrite/ast_helpers/ast_modifier.py +116 -104
- mindspore/rewrite/ast_transformers/flatten_recursive_stmt.py +93 -46
- mindspore/rewrite/common/rewrite_elog.py +5 -1
- mindspore/rewrite/namer.py +33 -24
- mindspore/rewrite/namespace.py +14 -5
- mindspore/{_extends/graph_kernel/expanders/complex → rewrite/node}/__init__.py +9 -9
- mindspore/rewrite/node/call_function.py +79 -0
- mindspore/rewrite/node/cell_container.py +135 -0
- mindspore/rewrite/node/control_flow.py +88 -0
- mindspore/rewrite/{node.py → node/node.py} +273 -234
- mindspore/rewrite/node/node_manager.py +254 -0
- mindspore/rewrite/{topological_manager.py → node/node_topological_manager.py} +13 -46
- mindspore/rewrite/parsers/arguments_parser.py +22 -21
- mindspore/rewrite/parsers/assign_parser.py +216 -221
- mindspore/rewrite/parsers/attribute_parser.py +9 -7
- mindspore/rewrite/parsers/class_def_parser.py +174 -113
- mindspore/rewrite/parsers/constant_parser.py +9 -6
- mindspore/rewrite/parsers/container_parser.py +9 -7
- mindspore/rewrite/parsers/for_parser.py +42 -21
- mindspore/rewrite/parsers/function_def_parser.py +24 -16
- mindspore/rewrite/parsers/if_parser.py +28 -24
- mindspore/rewrite/parsers/module_parser.py +196 -25
- mindspore/rewrite/{parser.py → parsers/parser.py} +4 -2
- mindspore/rewrite/{parser_register.py → parsers/parser_register.py} +1 -1
- mindspore/rewrite/parsers/return_parser.py +6 -6
- mindspore/rewrite/sparsify/sparse_transformer.py +12 -3
- mindspore/rewrite/sparsify/utils.py +1 -1
- mindspore/rewrite/symbol_tree.py +523 -578
- mindspore/rewrite/symbol_tree_builder.py +9 -193
- mindspore/rewrite/symbol_tree_dumper.py +2 -2
- mindspore/run_check/_check_version.py +6 -4
- mindspore/{ops/bprop_mindir → safeguard}/__init__.py +4 -3
- mindspore/safeguard/rewrite_obfuscation.py +541 -0
- mindspore/tbbmalloc.dll +0 -0
- mindspore/tinyxml2.dll +0 -0
- mindspore/train/_utils.py +7 -3
- mindspore/train/amp.py +323 -123
- mindspore/train/anf_ir_pb2.py +14 -2
- mindspore/train/callback/_backup_and_restore.py +2 -12
- mindspore/train/callback/_callback.py +29 -4
- mindspore/train/callback/_checkpoint.py +23 -8
- mindspore/train/callback/_early_stop.py +2 -2
- mindspore/train/callback/_landscape.py +4 -4
- mindspore/train/callback/_loss_monitor.py +2 -2
- mindspore/train/callback/_on_request_exit.py +2 -2
- mindspore/train/callback/_reduce_lr_on_plateau.py +3 -4
- mindspore/train/callback/_summary_collector.py +15 -8
- mindspore/train/callback/_time_monitor.py +58 -5
- mindspore/train/data_sink.py +5 -11
- mindspore/train/dataset_helper.py +84 -57
- mindspore/train/loss_scale_manager.py +2 -2
- mindspore/train/metrics/__init__.py +3 -3
- mindspore/train/metrics/cosine_similarity.py +1 -1
- mindspore/train/metrics/hausdorff_distance.py +3 -2
- mindspore/train/metrics/mean_surface_distance.py +3 -2
- mindspore/train/metrics/metric.py +39 -19
- mindspore/train/metrics/roc.py +2 -2
- mindspore/train/metrics/root_mean_square_surface_distance.py +4 -3
- mindspore/train/mind_ir_pb2.py +85 -36
- mindspore/train/model.py +187 -47
- mindspore/train/serialization.py +487 -161
- mindspore/train/summary/_summary_adapter.py +1 -1
- mindspore/train/summary/_writer_pool.py +3 -2
- mindspore/train/summary/summary_record.py +37 -17
- mindspore/train/train_thor/convert_utils.py +3 -3
- mindspore/train/train_thor/dataset_helper.py +1 -1
- mindspore/turbojpeg.dll +0 -0
- mindspore/vcmeta.dll +0 -0
- mindspore/vcruntime140.dll +0 -0
- mindspore/vcruntime140_1.dll +0 -0
- mindspore/version.py +1 -1
- {mindspore-2.1.0.dist-info → mindspore-2.2.11.dist-info}/METADATA +7 -4
- {mindspore-2.1.0.dist-info → mindspore-2.2.11.dist-info}/RECORD +429 -486
- mindspore/_extends/graph_kernel/expander.py +0 -80
- mindspore/_extends/graph_kernel/expanders/__init__.py +0 -54
- mindspore/_extends/graph_kernel/expanders/_utils.py +0 -269
- mindspore/_extends/graph_kernel/expanders/addn.py +0 -33
- mindspore/_extends/graph_kernel/expanders/batchnorm.py +0 -152
- mindspore/_extends/graph_kernel/expanders/batchnorm_grad.py +0 -105
- mindspore/_extends/graph_kernel/expanders/clip_by_norm_no_div_sum.py +0 -33
- mindspore/_extends/graph_kernel/expanders/complex/abs.py +0 -30
- mindspore/_extends/graph_kernel/expanders/complex/add.py +0 -44
- mindspore/_extends/graph_kernel/expanders/complex/div.py +0 -62
- mindspore/_extends/graph_kernel/expanders/complex/mul.py +0 -52
- mindspore/_extends/graph_kernel/expanders/complex/real_div.py +0 -62
- mindspore/_extends/graph_kernel/expanders/complex/sub.py +0 -45
- mindspore/_extends/graph_kernel/expanders/conv2d.py +0 -200
- mindspore/_extends/graph_kernel/expanders/dropout_grad.py +0 -30
- mindspore/_extends/graph_kernel/expanders/equal_count.py +0 -50
- mindspore/_extends/graph_kernel/expanders/erfc.py +0 -35
- mindspore/_extends/graph_kernel/expanders/expand_dims.py +0 -50
- mindspore/_extends/graph_kernel/expanders/fused_adam.py +0 -44
- mindspore/_extends/graph_kernel/expanders/fused_adam_weight_decay.py +0 -47
- mindspore/_extends/graph_kernel/expanders/fused_mul_add.py +0 -28
- mindspore/_extends/graph_kernel/expanders/gelu_grad.py +0 -70
- mindspore/_extends/graph_kernel/expanders/gkdropout.py +0 -40
- mindspore/_extends/graph_kernel/expanders/identity.py +0 -25
- mindspore/_extends/graph_kernel/expanders/layernorm.py +0 -93
- mindspore/_extends/graph_kernel/expanders/layernorm_grad.py +0 -113
- mindspore/_extends/graph_kernel/expanders/logsoftmax.py +0 -46
- mindspore/_extends/graph_kernel/expanders/logsoftmax_grad.py +0 -36
- mindspore/_extends/graph_kernel/expanders/matmul.py +0 -80
- mindspore/_extends/graph_kernel/expanders/maximum_grad.py +0 -59
- mindspore/_extends/graph_kernel/expanders/minimum_grad.py +0 -80
- mindspore/_extends/graph_kernel/expanders/oneslike.py +0 -26
- mindspore/_extends/graph_kernel/expanders/reduce_mean.py +0 -43
- mindspore/_extends/graph_kernel/expanders/relu_grad.py +0 -32
- mindspore/_extends/graph_kernel/expanders/sigmoid_cross_entropy_with_logits.py +0 -41
- mindspore/_extends/graph_kernel/expanders/sigmoid_cross_entropy_with_logits_grad.py +0 -35
- mindspore/_extends/graph_kernel/expanders/sigmoid_grad.py +0 -31
- mindspore/_extends/graph_kernel/expanders/slice.py +0 -35
- mindspore/_extends/graph_kernel/expanders/softmax_cross_entropy_with_logits.py +0 -42
- mindspore/_extends/graph_kernel/expanders/softmax_grad_ext.py +0 -41
- mindspore/_extends/graph_kernel/expanders/softsign.py +0 -28
- mindspore/_extends/graph_kernel/expanders/sqrt_grad.py +0 -29
- mindspore/_extends/graph_kernel/expanders/square_sum_all.py +0 -44
- mindspore/_extends/graph_kernel/expanders/square_sum_v1.py +0 -37
- mindspore/_extends/graph_kernel/expanders/squared_difference.py +0 -43
- mindspore/_extends/graph_kernel/expanders/tanh_grad.py +0 -31
- mindspore/_extends/graph_kernel/model/op_infer.py +0 -506
- mindspore/dataset/datapreprocess/__init__.py +0 -20
- mindspore/dataset/datapreprocess/preprocess_imagenet_validate_dataset.py +0 -54
- mindspore/include/api/net.h +0 -142
- mindspore/nn/lr_scheduler.py +0 -262
- mindspore/ops/_grad_experimental/grad_image_ops.py +0 -248
- mindspore/ops/_grad_experimental/grad_linalg_ops.py +0 -181
- mindspore/ops/_grad_experimental/grad_other_ops.py +0 -72
- mindspore/ops/_grad_experimental/grad_scalar_ops.py +0 -112
- mindspore/ops/_grad_experimental/grad_sequence_ops.py +0 -351
- mindspore/ops/_op_impl/_custom_op/flash_attention/__init__.py +0 -0
- mindspore/ops/_op_impl/_custom_op/flash_attention/attention.py +0 -350
- mindspore/ops/_op_impl/_custom_op/flash_attention/flash_attention_bwd.py +0 -409
- mindspore/ops/_op_impl/_custom_op/flash_attention/flash_attention_fwd.py +0 -578
- mindspore/ops/_op_impl/_custom_op/flash_attention/flash_attention_impl.py +0 -199
- mindspore/ops/_op_impl/_custom_op/flash_attention/tik_ops_utils.py +0 -446
- mindspore/ops/_op_impl/_custom_op/flash_attention/tiling_strategy/__init__.py +0 -0
- mindspore/ops/_op_impl/_custom_op/flash_attention/tiling_strategy/sparse_tiling.py +0 -45
- mindspore/ops/_op_impl/_custom_op/flash_attention/tiling_strategy/strategy.py +0 -67
- mindspore/ops/_op_impl/_custom_op/flash_attention/tiling_strategy/wukong_tiling.py +0 -62
- mindspore/ops/bprop_mindir/BNTrainingReduce_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Broadcast_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Depend_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/DepthwiseConv2dNative_bprop.mindir +0 -138
- mindspore/ops/bprop_mindir/EmbeddingLookup_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Load_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/ScatterNonAliasingAdd_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/SparseGatherV2_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/SparseSoftmaxCrossEntropyWithLogits_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Switch_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/TransShape_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/TupleGetItem_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Unique_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/Unstack_bprop.mindir +0 -0
- mindspore/ops/bprop_mindir/generate_mindir.py +0 -114
- mindspore/rewrite/node_visitor.py +0 -44
- {mindspore-2.1.0.dist-info → mindspore-2.2.11.dist-info}/WHEEL +0 -0
- {mindspore-2.1.0.dist-info → mindspore-2.2.11.dist-info}/entry_points.txt +0 -0
- {mindspore-2.1.0.dist-info → mindspore-2.2.11.dist-info}/top_level.txt +0 -0
|
@@ -34,6 +34,8 @@ Examples:
|
|
|
34
34
|
>>> import mindspore.dataset as ds
|
|
35
35
|
>>> import mindspore.dataset.vision as vision
|
|
36
36
|
>>> from mindspore.dataset.vision import Border, Inter
|
|
37
|
+
>>> import mindspore.dataset.transforms as transforms
|
|
38
|
+
>>>
|
|
37
39
|
>>> image_folder_dataset_dir = "/path/to/image_folder_dataset_directory"
|
|
38
40
|
>>> # create a dataset that reads all files in dataset_dir with 8 threads
|
|
39
41
|
>>> image_folder_dataset = ds.ImageFolderDataset(image_folder_dataset_dir,
|
|
@@ -76,7 +78,7 @@ from .validators import check_adjust_brightness, check_adjust_contrast, check_ad
|
|
|
76
78
|
check_random_select_subpolicy_op, check_random_solarize, check_range, check_rescale, check_resize, \
|
|
77
79
|
check_resize_interpolation, check_resized_crop, check_rgb_to_hsv, check_rotate, check_slice_patches, \
|
|
78
80
|
check_solarize, check_ten_crop, check_trivial_augment_wide, check_uniform_augment, check_to_tensor, \
|
|
79
|
-
FLOAT_MAX_INTEGER
|
|
81
|
+
check_device_target, FLOAT_MAX_INTEGER
|
|
80
82
|
from ..core.datatypes import mstype_to_detype, nptype_to_detype
|
|
81
83
|
from ..transforms.py_transforms_util import Implementation
|
|
82
84
|
from ..transforms.transforms import CompoundOperation, PyTensorOperation, TensorOperation, TypeCast
|
|
@@ -114,7 +116,7 @@ class AdjustBrightness(ImageTensorOperation, PyTensorOperation):
|
|
|
114
116
|
RuntimeError: If shape of the input image is not <H, W, C>.
|
|
115
117
|
|
|
116
118
|
Supported Platforms:
|
|
117
|
-
``CPU``
|
|
119
|
+
``CPU`` ``Ascend``
|
|
118
120
|
|
|
119
121
|
Examples:
|
|
120
122
|
>>> import mindspore.dataset as ds
|
|
@@ -127,7 +129,7 @@ class AdjustBrightness(ImageTensorOperation, PyTensorOperation):
|
|
|
127
129
|
|
|
128
130
|
Tutorial Examples:
|
|
129
131
|
- `Illustration of vision transforms
|
|
130
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
132
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
131
133
|
"""
|
|
132
134
|
|
|
133
135
|
@check_adjust_brightness
|
|
@@ -135,8 +137,39 @@ class AdjustBrightness(ImageTensorOperation, PyTensorOperation):
|
|
|
135
137
|
super().__init__()
|
|
136
138
|
self.brightness_factor = brightness_factor
|
|
137
139
|
|
|
140
|
+
@check_device_target
|
|
141
|
+
def device(self, device_target="CPU"):
|
|
142
|
+
"""
|
|
143
|
+
Set the device for the current operator execution.
|
|
144
|
+
|
|
145
|
+
Args:
|
|
146
|
+
device_target (str, optional): The operator will be executed on this device. Currently supports
|
|
147
|
+
``CPU`` . Default: ``CPU`` .
|
|
148
|
+
|
|
149
|
+
Raises:
|
|
150
|
+
TypeError: If `device_target` is not of type str.
|
|
151
|
+
ValueError: If `device_target` is not ``CPU`` .
|
|
152
|
+
|
|
153
|
+
Supported Platforms:
|
|
154
|
+
``CPU``
|
|
155
|
+
|
|
156
|
+
Examples:
|
|
157
|
+
>>> import mindspore.dataset as ds
|
|
158
|
+
>>> import mindspore.dataset.vision as vision
|
|
159
|
+
>>>
|
|
160
|
+
>>> image_folder_dataset = ds.ImageFolderDataset("/path/to/image_folder_dataset_directory")
|
|
161
|
+
>>> transforms_list = [vision.Decode().device("CPU"), vision.AdjustBrightness(2.0).device("Ascend")]
|
|
162
|
+
>>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list, input_columns=["image"])
|
|
163
|
+
|
|
164
|
+
Tutorial Examples:
|
|
165
|
+
- `Illustration of vision transforms
|
|
166
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
167
|
+
"""
|
|
168
|
+
self.device_target = device_target
|
|
169
|
+
return self
|
|
170
|
+
|
|
138
171
|
def parse(self):
|
|
139
|
-
return cde.AdjustBrightnessOperation(self.brightness_factor)
|
|
172
|
+
return cde.AdjustBrightnessOperation(self.brightness_factor, self.device_target)
|
|
140
173
|
|
|
141
174
|
def _execute_py(self, img):
|
|
142
175
|
"""
|
|
@@ -166,7 +199,7 @@ class AdjustContrast(ImageTensorOperation, PyTensorOperation):
|
|
|
166
199
|
RuntimeError: If shape of the input image is not <H, W, C>.
|
|
167
200
|
|
|
168
201
|
Supported Platforms:
|
|
169
|
-
``CPU``
|
|
202
|
+
``CPU`` ``Ascend``
|
|
170
203
|
|
|
171
204
|
Examples:
|
|
172
205
|
>>> import mindspore.dataset as ds
|
|
@@ -179,7 +212,7 @@ class AdjustContrast(ImageTensorOperation, PyTensorOperation):
|
|
|
179
212
|
|
|
180
213
|
Tutorial Examples:
|
|
181
214
|
- `Illustration of vision transforms
|
|
182
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
215
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
183
216
|
"""
|
|
184
217
|
|
|
185
218
|
@check_adjust_contrast
|
|
@@ -187,8 +220,39 @@ class AdjustContrast(ImageTensorOperation, PyTensorOperation):
|
|
|
187
220
|
super().__init__()
|
|
188
221
|
self.contrast_factor = contrast_factor
|
|
189
222
|
|
|
223
|
+
@check_device_target
|
|
224
|
+
def device(self, device_target="CPU"):
|
|
225
|
+
"""
|
|
226
|
+
Set the device for the current operator execution.
|
|
227
|
+
|
|
228
|
+
Args:
|
|
229
|
+
device_target (str, optional): The operator will be executed on this device. Currently supports
|
|
230
|
+
``CPU`` . Default: ``CPU`` .
|
|
231
|
+
|
|
232
|
+
Raises:
|
|
233
|
+
TypeError: If `device_target` is not of type str.
|
|
234
|
+
ValueError: If `device_target` is not ``CPU`` .
|
|
235
|
+
|
|
236
|
+
Supported Platforms:
|
|
237
|
+
``CPU``
|
|
238
|
+
|
|
239
|
+
Examples:
|
|
240
|
+
>>> import mindspore.dataset as ds
|
|
241
|
+
>>> import mindspore.dataset.vision as vision
|
|
242
|
+
>>>
|
|
243
|
+
>>> image_folder_dataset = ds.ImageFolderDataset("/path/to/image_folder_dataset_directory")
|
|
244
|
+
>>> transforms_list = [vision.Decode().device("CPU"), vision.AdjustContrast(0).device("Ascend")]
|
|
245
|
+
>>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list, input_columns=["image"])
|
|
246
|
+
|
|
247
|
+
Tutorial Examples:
|
|
248
|
+
- `Illustration of vision transforms
|
|
249
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
250
|
+
"""
|
|
251
|
+
self.device_target = device_target
|
|
252
|
+
return self
|
|
253
|
+
|
|
190
254
|
def parse(self):
|
|
191
|
-
return cde.AdjustContrastOperation(self.contrast_factor)
|
|
255
|
+
return cde.AdjustContrastOperation(self.contrast_factor, self.device_target)
|
|
192
256
|
|
|
193
257
|
def _execute_py(self, img):
|
|
194
258
|
"""
|
|
@@ -241,7 +305,7 @@ class AdjustGamma(ImageTensorOperation, PyTensorOperation):
|
|
|
241
305
|
|
|
242
306
|
Tutorial Examples:
|
|
243
307
|
- `Illustration of vision transforms
|
|
244
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
308
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
245
309
|
"""
|
|
246
310
|
|
|
247
311
|
@check_adjust_gamma
|
|
@@ -281,7 +345,7 @@ class AdjustHue(ImageTensorOperation, PyTensorOperation):
|
|
|
281
345
|
RuntimeError: If shape of the input image is not <H, W, C>.
|
|
282
346
|
|
|
283
347
|
Supported Platforms:
|
|
284
|
-
``CPU``
|
|
348
|
+
``CPU`` ``Ascend``
|
|
285
349
|
|
|
286
350
|
Examples:
|
|
287
351
|
>>> import mindspore.dataset as ds
|
|
@@ -294,7 +358,7 @@ class AdjustHue(ImageTensorOperation, PyTensorOperation):
|
|
|
294
358
|
|
|
295
359
|
Tutorial Examples:
|
|
296
360
|
- `Illustration of vision transforms
|
|
297
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
361
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
298
362
|
"""
|
|
299
363
|
|
|
300
364
|
@check_adjust_hue
|
|
@@ -302,8 +366,39 @@ class AdjustHue(ImageTensorOperation, PyTensorOperation):
|
|
|
302
366
|
super().__init__()
|
|
303
367
|
self.hue_factor = hue_factor
|
|
304
368
|
|
|
369
|
+
@check_device_target
|
|
370
|
+
def device(self, device_target="CPU"):
|
|
371
|
+
"""
|
|
372
|
+
Set the device for the current operator execution.
|
|
373
|
+
|
|
374
|
+
Args:
|
|
375
|
+
device_target (str, optional): The operator will be executed on this device. Currently supports
|
|
376
|
+
``CPU`` . Default: ``CPU`` .
|
|
377
|
+
|
|
378
|
+
Raises:
|
|
379
|
+
TypeError: If `device_target` is not of type str.
|
|
380
|
+
ValueError: If `device_target` is not ``CPU`` .
|
|
381
|
+
|
|
382
|
+
Supported Platforms:
|
|
383
|
+
``CPU``
|
|
384
|
+
|
|
385
|
+
Examples:
|
|
386
|
+
>>> import mindspore.dataset as ds
|
|
387
|
+
>>> import mindspore.dataset.vision as vision
|
|
388
|
+
>>>
|
|
389
|
+
>>> image_folder_dataset = ds.ImageFolderDataset("/path/to/image_folder_dataset_directory")
|
|
390
|
+
>>> transforms_list = [vision.Decode().device("CPU"), vision.AdjustHue(0.5).device("Ascend")]
|
|
391
|
+
>>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list, input_columns=["image"])
|
|
392
|
+
|
|
393
|
+
Tutorial Examples:
|
|
394
|
+
- `Illustration of vision transforms
|
|
395
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
396
|
+
"""
|
|
397
|
+
self.device_target = device_target
|
|
398
|
+
return self
|
|
399
|
+
|
|
305
400
|
def parse(self):
|
|
306
|
-
return cde.AdjustHueOperation(self.hue_factor)
|
|
401
|
+
return cde.AdjustHueOperation(self.hue_factor, self.device_target)
|
|
307
402
|
|
|
308
403
|
def _execute_py(self, img):
|
|
309
404
|
"""
|
|
@@ -334,7 +429,7 @@ class AdjustSaturation(ImageTensorOperation, PyTensorOperation):
|
|
|
334
429
|
RuntimeError: If channel of the input image is not 3.
|
|
335
430
|
|
|
336
431
|
Supported Platforms:
|
|
337
|
-
``CPU``
|
|
432
|
+
``CPU`` ``Ascend``
|
|
338
433
|
|
|
339
434
|
Examples:
|
|
340
435
|
>>> import mindspore.dataset as ds
|
|
@@ -347,7 +442,7 @@ class AdjustSaturation(ImageTensorOperation, PyTensorOperation):
|
|
|
347
442
|
|
|
348
443
|
Tutorial Examples:
|
|
349
444
|
- `Illustration of vision transforms
|
|
350
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
445
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
351
446
|
"""
|
|
352
447
|
|
|
353
448
|
@check_adjust_saturation
|
|
@@ -355,8 +450,39 @@ class AdjustSaturation(ImageTensorOperation, PyTensorOperation):
|
|
|
355
450
|
super().__init__()
|
|
356
451
|
self.saturation_factor = saturation_factor
|
|
357
452
|
|
|
453
|
+
@check_device_target
|
|
454
|
+
def device(self, device_target="CPU"):
|
|
455
|
+
"""
|
|
456
|
+
Set the device for the current operator execution.
|
|
457
|
+
|
|
458
|
+
Args:
|
|
459
|
+
device_target (str, optional): The operator will be executed on this device. Currently supports
|
|
460
|
+
``CPU`` . Default: ``CPU`` .
|
|
461
|
+
|
|
462
|
+
Raises:
|
|
463
|
+
TypeError: If `device_target` is not of type str.
|
|
464
|
+
ValueError: If `device_target` is not ``CPU`` .
|
|
465
|
+
|
|
466
|
+
Supported Platforms:
|
|
467
|
+
``CPU``
|
|
468
|
+
|
|
469
|
+
Examples:
|
|
470
|
+
>>> import mindspore.dataset as ds
|
|
471
|
+
>>> import mindspore.dataset.vision as vision
|
|
472
|
+
>>>
|
|
473
|
+
>>> image_folder_dataset = ds.ImageFolderDataset("/path/to/image_folder_dataset_directory")
|
|
474
|
+
>>> transforms_list = [vision.Decode().device("CPU"), vision.AdjustSaturation(2.0).device("Ascend")]
|
|
475
|
+
>>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list, input_columns=["image"])
|
|
476
|
+
|
|
477
|
+
Tutorial Examples:
|
|
478
|
+
- `Illustration of vision transforms
|
|
479
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
480
|
+
"""
|
|
481
|
+
self.device_target = device_target
|
|
482
|
+
return self
|
|
483
|
+
|
|
358
484
|
def parse(self):
|
|
359
|
-
return cde.AdjustSaturationOperation(self.saturation_factor)
|
|
485
|
+
return cde.AdjustSaturationOperation(self.saturation_factor, self.device_target)
|
|
360
486
|
|
|
361
487
|
def _execute_py(self, img):
|
|
362
488
|
"""
|
|
@@ -399,7 +525,7 @@ class AdjustSharpness(ImageTensorOperation):
|
|
|
399
525
|
|
|
400
526
|
Tutorial Examples:
|
|
401
527
|
- `Illustration of vision transforms
|
|
402
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
528
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
403
529
|
"""
|
|
404
530
|
|
|
405
531
|
@check_adjust_sharpness
|
|
@@ -423,17 +549,8 @@ class Affine(ImageTensorOperation):
|
|
|
423
549
|
shear (Union[float, Sequence[float, float]]): Shear angle value in degrees between -180 to 180.
|
|
424
550
|
If float is provided, shear along the x axis with this value, without shearing along the y axis;
|
|
425
551
|
If Sequence[float, float] is provided, shear along the x axis and y axis with these two values separately.
|
|
426
|
-
resample (Inter, optional):
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
- ``Inter.BILINEA`` , means resample method is bilinear interpolation.
|
|
430
|
-
|
|
431
|
-
- ``Inter.NEAREST`` , means resample method is nearest-neighbor interpolation.
|
|
432
|
-
|
|
433
|
-
- ``Inter.BICUBIC`` , means resample method is bicubic interpolation.
|
|
434
|
-
|
|
435
|
-
- ``Inter.AREA`` :, means resample method is pixel area interpolation.
|
|
436
|
-
|
|
552
|
+
resample (Inter, optional): Image interpolation method defined by :class:`~.vision.Inter` .
|
|
553
|
+
Default: ``Inter.NEAREST``.
|
|
437
554
|
fill_value (Union[int, tuple[int, int, int]], optional): Optional `fill_value` to fill the area
|
|
438
555
|
outside the transform in the output image. There must be three elements in tuple and the value
|
|
439
556
|
of single element is [0, 255]. Default: ``0``.
|
|
@@ -444,7 +561,7 @@ class Affine(ImageTensorOperation):
|
|
|
444
561
|
TypeError: If `scale` is not of type float.
|
|
445
562
|
ValueError: If `scale` is non positive.
|
|
446
563
|
TypeError: If `shear` is not of float or Sequence[float, float].
|
|
447
|
-
TypeError: If `resample` is not of type :class
|
|
564
|
+
TypeError: If `resample` is not of type :class:`~.vision.Inter` .
|
|
448
565
|
TypeError: If `fill_value` is not of type int or tuple[int, int, int].
|
|
449
566
|
RuntimeError: If shape of the input image is not <H, W> or <H, W, C>.
|
|
450
567
|
|
|
@@ -466,7 +583,7 @@ class Affine(ImageTensorOperation):
|
|
|
466
583
|
|
|
467
584
|
Tutorial Examples:
|
|
468
585
|
- `Illustration of vision transforms
|
|
469
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
586
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
470
587
|
"""
|
|
471
588
|
|
|
472
589
|
@check_affine
|
|
@@ -510,17 +627,8 @@ class AutoAugment(ImageTensorOperation):
|
|
|
510
627
|
|
|
511
628
|
- ``AutoAugmentPolicy.SVHN``, means to apply AutoAugment learned on SVHN dataset.
|
|
512
629
|
|
|
513
|
-
interpolation (Inter, optional): Image interpolation
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
- ``Inter.NEAREST`` : means interpolation method is nearest-neighbor interpolation.
|
|
517
|
-
|
|
518
|
-
- ``Inter.BILINEA`` : means interpolation method is bilinear interpolation.
|
|
519
|
-
|
|
520
|
-
- ``Inter.BICUBIC`` : means the interpolation method is bicubic interpolation.
|
|
521
|
-
|
|
522
|
-
- ``Inter.AREA`` : means the interpolation method is pixel area interpolation.
|
|
523
|
-
|
|
630
|
+
interpolation (Inter, optional): Image interpolation method defined by :class:`~.vision.Inter` .
|
|
631
|
+
Default: ``Inter.NEAREST``.
|
|
524
632
|
fill_value (Union[int, tuple[int]], optional): Pixel fill value for the area outside the transformed image.
|
|
525
633
|
It can be an int or a 3-tuple. If it is a 3-tuple, it is used to fill R, G, B channels respectively.
|
|
526
634
|
If it is an integer, it is used for all RGB channels. The fill_value values must be in range [0, 255].
|
|
@@ -528,7 +636,7 @@ class AutoAugment(ImageTensorOperation):
|
|
|
528
636
|
|
|
529
637
|
Raises:
|
|
530
638
|
TypeError: If `policy` is not of type :class:`mindspore.dataset.vision.AutoAugmentPolicy` .
|
|
531
|
-
TypeError: If `interpolation` is not of type :class
|
|
639
|
+
TypeError: If `interpolation` is not of type :class:`~.vision.Inter` .
|
|
532
640
|
TypeError: If `fill_value` is not an integer or a tuple of length 3.
|
|
533
641
|
RuntimeError: If given tensor shape is not <H, W, C>.
|
|
534
642
|
|
|
@@ -550,7 +658,7 @@ class AutoAugment(ImageTensorOperation):
|
|
|
550
658
|
|
|
551
659
|
Tutorial Examples:
|
|
552
660
|
- `Illustration of vision transforms
|
|
553
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
661
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
554
662
|
"""
|
|
555
663
|
|
|
556
664
|
@check_auto_augment
|
|
@@ -600,7 +708,7 @@ class AutoContrast(ImageTensorOperation, PyTensorOperation):
|
|
|
600
708
|
|
|
601
709
|
Tutorial Examples:
|
|
602
710
|
- `Illustration of vision transforms
|
|
603
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
711
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
604
712
|
"""
|
|
605
713
|
|
|
606
714
|
@check_auto_contrast
|
|
@@ -663,7 +771,7 @@ class BoundingBoxAugment(ImageTensorOperation):
|
|
|
663
771
|
|
|
664
772
|
Tutorial Examples:
|
|
665
773
|
- `Illustration of vision transforms
|
|
666
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
774
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
667
775
|
"""
|
|
668
776
|
|
|
669
777
|
@check_bounding_box_augment_cpp
|
|
@@ -717,7 +825,7 @@ class CenterCrop(ImageTensorOperation, PyTensorOperation):
|
|
|
717
825
|
|
|
718
826
|
Tutorial Examples:
|
|
719
827
|
- `Illustration of vision transforms
|
|
720
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
828
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
721
829
|
"""
|
|
722
830
|
|
|
723
831
|
@check_center_crop
|
|
@@ -815,7 +923,7 @@ class ConvertColor(ImageTensorOperation):
|
|
|
815
923
|
|
|
816
924
|
Tutorial Examples:
|
|
817
925
|
- `Illustration of vision transforms
|
|
818
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
926
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
819
927
|
"""
|
|
820
928
|
|
|
821
929
|
@check_convert_color
|
|
@@ -863,7 +971,7 @@ class Crop(ImageTensorOperation):
|
|
|
863
971
|
|
|
864
972
|
Tutorial Examples:
|
|
865
973
|
- `Illustration of vision transforms
|
|
866
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
974
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
867
975
|
"""
|
|
868
976
|
|
|
869
977
|
@check_crop
|
|
@@ -919,7 +1027,7 @@ class CutMixBatch(ImageTensorOperation):
|
|
|
919
1027
|
|
|
920
1028
|
Tutorial Examples:
|
|
921
1029
|
- `Illustration of vision transforms
|
|
922
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
1030
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
923
1031
|
"""
|
|
924
1032
|
|
|
925
1033
|
@check_cut_mix_batch_c
|
|
@@ -966,7 +1074,7 @@ class CutOut(ImageTensorOperation):
|
|
|
966
1074
|
|
|
967
1075
|
Tutorial Examples:
|
|
968
1076
|
- `Illustration of vision transforms
|
|
969
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
1077
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
970
1078
|
"""
|
|
971
1079
|
|
|
972
1080
|
@check_cutout_new
|
|
@@ -998,7 +1106,7 @@ class Decode(ImageTensorOperation, PyTensorOperation):
|
|
|
998
1106
|
RuntimeError: If the input image is already decoded.
|
|
999
1107
|
|
|
1000
1108
|
Supported Platforms:
|
|
1001
|
-
``CPU``
|
|
1109
|
+
``CPU`` ``Ascend``
|
|
1002
1110
|
|
|
1003
1111
|
Examples:
|
|
1004
1112
|
>>> import mindspore.dataset as ds
|
|
@@ -1017,7 +1125,7 @@ class Decode(ImageTensorOperation, PyTensorOperation):
|
|
|
1017
1125
|
|
|
1018
1126
|
Tutorial Examples:
|
|
1019
1127
|
- `Illustration of vision transforms
|
|
1020
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
1128
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
1021
1129
|
"""
|
|
1022
1130
|
|
|
1023
1131
|
@check_decode
|
|
@@ -1044,8 +1152,43 @@ class Decode(ImageTensorOperation, PyTensorOperation):
|
|
|
1044
1152
|
"but got {0}.".format(img.ndim))
|
|
1045
1153
|
return super().__call__(img)
|
|
1046
1154
|
|
|
1155
|
+
@check_device_target
|
|
1156
|
+
def device(self, device_target="CPU"):
|
|
1157
|
+
"""
|
|
1158
|
+
Set the device for the current operator execution.
|
|
1159
|
+
|
|
1160
|
+
Args:
|
|
1161
|
+
device_target (str, optional): The operator will be executed on this device. Currently supports
|
|
1162
|
+
``CPU`` . Default: ``CPU`` .
|
|
1163
|
+
|
|
1164
|
+
Raises:
|
|
1165
|
+
TypeError: If `device_target` is not of type str.
|
|
1166
|
+
ValueError: If `device_target` is not ``CPU`` .
|
|
1167
|
+
|
|
1168
|
+
Supported Platforms:
|
|
1169
|
+
``CPU``
|
|
1170
|
+
|
|
1171
|
+
Examples:
|
|
1172
|
+
>>> import mindspore.dataset as ds
|
|
1173
|
+
>>> import mindspore.dataset.vision as vision
|
|
1174
|
+
>>> from mindspore.dataset.vision import Inter
|
|
1175
|
+
>>>
|
|
1176
|
+
>>> decode_op = vision.Decode().device("Ascend")
|
|
1177
|
+
>>> resize_op = vision.Resize([100, 75], Inter.BICUBIC)
|
|
1178
|
+
>>> transforms_list = [decode_op, resize_op]
|
|
1179
|
+
>>> image_folder_dataset = ds.ImageFolderDataset("/path/to/image_folder_dataset_directory")
|
|
1180
|
+
>>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list,
|
|
1181
|
+
... input_columns=["image"])
|
|
1182
|
+
|
|
1183
|
+
Tutorial Examples:
|
|
1184
|
+
- `Illustration of vision transforms
|
|
1185
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
1186
|
+
"""
|
|
1187
|
+
self.device_target = device_target
|
|
1188
|
+
return self
|
|
1189
|
+
|
|
1047
1190
|
def parse(self):
|
|
1048
|
-
return cde.DecodeOperation(True)
|
|
1191
|
+
return cde.DecodeOperation(True, self.device_target)
|
|
1049
1192
|
|
|
1050
1193
|
def _execute_py(self, img):
|
|
1051
1194
|
"""
|
|
@@ -1081,7 +1224,7 @@ class Equalize(ImageTensorOperation, PyTensorOperation):
|
|
|
1081
1224
|
|
|
1082
1225
|
Tutorial Examples:
|
|
1083
1226
|
- `Illustration of vision transforms
|
|
1084
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
1227
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
1085
1228
|
"""
|
|
1086
1229
|
|
|
1087
1230
|
def __init__(self):
|
|
@@ -1147,7 +1290,7 @@ class Erase(ImageTensorOperation):
|
|
|
1147
1290
|
|
|
1148
1291
|
Tutorial Examples:
|
|
1149
1292
|
- `Illustration of vision transforms
|
|
1150
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
1293
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
1151
1294
|
"""
|
|
1152
1295
|
|
|
1153
1296
|
@check_erase
|
|
@@ -1199,7 +1342,7 @@ class FiveCrop(PyTensorOperation):
|
|
|
1199
1342
|
|
|
1200
1343
|
Tutorial Examples:
|
|
1201
1344
|
- `Illustration of vision transforms
|
|
1202
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
1345
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
1203
1346
|
"""
|
|
1204
1347
|
|
|
1205
1348
|
@check_five_crop
|
|
@@ -1223,18 +1366,22 @@ class FiveCrop(PyTensorOperation):
|
|
|
1223
1366
|
|
|
1224
1367
|
|
|
1225
1368
|
class GaussianBlur(ImageTensorOperation):
|
|
1226
|
-
"""
|
|
1369
|
+
r"""
|
|
1227
1370
|
Blur input image with the specified Gaussian kernel.
|
|
1228
1371
|
|
|
1229
1372
|
Args:
|
|
1230
|
-
kernel_size (Union[int, Sequence[int]]):
|
|
1231
|
-
If
|
|
1232
|
-
is
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
If
|
|
1237
|
-
|
|
1373
|
+
kernel_size (Union[int, Sequence[int, int]]): The size of the Gaussian kernel. Must be positive and odd.
|
|
1374
|
+
If the input type is int, the value will be used as both the width and height of the Gaussian kernel.
|
|
1375
|
+
If the input type is Sequence[int, int], the two elements will be used as the width and height of the
|
|
1376
|
+
Gaussian kernel respectively.
|
|
1377
|
+
sigma (Union[float, Sequence[float, float]], optional): The standard deviation of the Gaussian kernel.
|
|
1378
|
+
Must be positive.
|
|
1379
|
+
If the input type is float, the value will be used as the standard deviation of both the width and
|
|
1380
|
+
height of the Gaussian kernel.
|
|
1381
|
+
If the input type is Sequence[float, float], the two elements will be used as the standard deviation
|
|
1382
|
+
of the width and height of the Gaussian kernel respectively.
|
|
1383
|
+
Default: ``None`` , the standard deviation of the Gaussian kernel will be obtained by the
|
|
1384
|
+
formula :math:`((kernel\_size - 1) * 0.5 - 1) * 0.3 + 0.8` .
|
|
1238
1385
|
|
|
1239
1386
|
Raises:
|
|
1240
1387
|
TypeError: If `kernel_size` is not of type int or Sequence[int].
|
|
@@ -1257,7 +1404,7 @@ class GaussianBlur(ImageTensorOperation):
|
|
|
1257
1404
|
|
|
1258
1405
|
Tutorial Examples:
|
|
1259
1406
|
- `Illustration of vision transforms
|
|
1260
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
1407
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
1261
1408
|
"""
|
|
1262
1409
|
|
|
1263
1410
|
@check_gaussian_blur
|
|
@@ -1307,7 +1454,7 @@ class Grayscale(PyTensorOperation):
|
|
|
1307
1454
|
|
|
1308
1455
|
Tutorial Examples:
|
|
1309
1456
|
- `Illustration of vision transforms
|
|
1310
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
1457
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
1311
1458
|
"""
|
|
1312
1459
|
|
|
1313
1460
|
@check_num_channels
|
|
@@ -1351,7 +1498,7 @@ class HorizontalFlip(ImageTensorOperation):
|
|
|
1351
1498
|
|
|
1352
1499
|
Tutorial Examples:
|
|
1353
1500
|
- `Illustration of vision transforms
|
|
1354
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
1501
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
1355
1502
|
"""
|
|
1356
1503
|
|
|
1357
1504
|
def __init__(self):
|
|
@@ -1392,7 +1539,7 @@ class HsvToRgb(PyTensorOperation):
|
|
|
1392
1539
|
|
|
1393
1540
|
Tutorial Examples:
|
|
1394
1541
|
- `Illustration of vision transforms
|
|
1395
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
1542
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
1396
1543
|
"""
|
|
1397
1544
|
|
|
1398
1545
|
@check_hsv_to_rgb
|
|
@@ -1421,13 +1568,14 @@ class HWC2CHW(ImageTensorOperation):
|
|
|
1421
1568
|
If the input image is of shape <H, W>, it will remain unchanged.
|
|
1422
1569
|
|
|
1423
1570
|
Note:
|
|
1424
|
-
This operation
|
|
1571
|
+
This operation is executed on the CPU by default, but it is also supported
|
|
1572
|
+
to be executed on the GPU or Ascend via heterogeneous acceleration.
|
|
1425
1573
|
|
|
1426
1574
|
Raises:
|
|
1427
1575
|
RuntimeError: If shape of the input image is not <H, W> or <H, W, C>.
|
|
1428
1576
|
|
|
1429
1577
|
Supported Platforms:
|
|
1430
|
-
``CPU``
|
|
1578
|
+
``CPU`` ``GPU`` ``Ascend``
|
|
1431
1579
|
|
|
1432
1580
|
Examples:
|
|
1433
1581
|
>>> import mindspore.dataset as ds
|
|
@@ -1443,7 +1591,7 @@ class HWC2CHW(ImageTensorOperation):
|
|
|
1443
1591
|
|
|
1444
1592
|
Tutorial Examples:
|
|
1445
1593
|
- `Illustration of vision transforms
|
|
1446
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
1594
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
1447
1595
|
"""
|
|
1448
1596
|
|
|
1449
1597
|
def __init__(self):
|
|
@@ -1457,10 +1605,13 @@ class HWC2CHW(ImageTensorOperation):
|
|
|
1457
1605
|
|
|
1458
1606
|
class Invert(ImageTensorOperation, PyTensorOperation):
|
|
1459
1607
|
"""
|
|
1460
|
-
|
|
1608
|
+
Invert the colors of the input RGB image.
|
|
1609
|
+
|
|
1610
|
+
For each pixel in the image, if the original pixel value is `pixel`,
|
|
1611
|
+
the inverted pixel value will be `255 - pixel`.
|
|
1461
1612
|
|
|
1462
1613
|
Raises:
|
|
1463
|
-
RuntimeError: If
|
|
1614
|
+
RuntimeError: If the input image is not in shape of <H, W, C>.
|
|
1464
1615
|
|
|
1465
1616
|
Supported Platforms:
|
|
1466
1617
|
``CPU``
|
|
@@ -1476,7 +1627,7 @@ class Invert(ImageTensorOperation, PyTensorOperation):
|
|
|
1476
1627
|
|
|
1477
1628
|
Tutorial Examples:
|
|
1478
1629
|
- `Illustration of vision transforms
|
|
1479
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
1630
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
1480
1631
|
"""
|
|
1481
1632
|
|
|
1482
1633
|
def __init__(self):
|
|
@@ -1540,7 +1691,7 @@ class LinearTransformation(PyTensorOperation):
|
|
|
1540
1691
|
|
|
1541
1692
|
Tutorial Examples:
|
|
1542
1693
|
- `Illustration of vision transforms
|
|
1543
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
1694
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
1544
1695
|
"""
|
|
1545
1696
|
|
|
1546
1697
|
@check_linear_transform
|
|
@@ -1606,12 +1757,12 @@ class MixUp(PyTensorOperation):
|
|
|
1606
1757
|
>>> image_folder_dataset = image_folder_dataset.batch(batch_size=batch_size)
|
|
1607
1758
|
>>> # finally mix up the images and labels
|
|
1608
1759
|
>>> image_folder_dataset = image_folder_dataset.map(
|
|
1609
|
-
... operations=
|
|
1760
|
+
... operations=vision.MixUp(batch_size=batch_size, alpha=0.2),
|
|
1610
1761
|
... input_columns=["image", "label"])
|
|
1611
1762
|
|
|
1612
1763
|
Tutorial Examples:
|
|
1613
1764
|
- `Illustration of vision transforms
|
|
1614
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
1765
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
1615
1766
|
"""
|
|
1616
1767
|
|
|
1617
1768
|
@check_mix_up
|
|
@@ -1684,7 +1835,7 @@ class MixUpBatch(ImageTensorOperation):
|
|
|
1684
1835
|
|
|
1685
1836
|
Tutorial Examples:
|
|
1686
1837
|
- `Illustration of vision transforms
|
|
1687
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
1838
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
1688
1839
|
"""
|
|
1689
1840
|
|
|
1690
1841
|
@check_mix_up_batch_c
|
|
@@ -1703,7 +1854,8 @@ class Normalize(ImageTensorOperation):
|
|
|
1703
1854
|
the input image with: output[channel] = (input[channel] - mean[channel]) / std[channel], where channel >= 1.
|
|
1704
1855
|
|
|
1705
1856
|
Note:
|
|
1706
|
-
This operation
|
|
1857
|
+
This operation is executed on the CPU by default, but it is also supported
|
|
1858
|
+
to be executed on the GPU or Ascend via heterogeneous acceleration.
|
|
1707
1859
|
|
|
1708
1860
|
Args:
|
|
1709
1861
|
mean (sequence): List or tuple of mean values for each channel, with respect to channel order.
|
|
@@ -1722,7 +1874,7 @@ class Normalize(ImageTensorOperation):
|
|
|
1722
1874
|
RuntimeError: If given tensor format is not <H, W> or <..., H, W, C>.
|
|
1723
1875
|
|
|
1724
1876
|
Supported Platforms:
|
|
1725
|
-
``CPU``
|
|
1877
|
+
``CPU`` ``GPU`` ``Ascend``
|
|
1726
1878
|
|
|
1727
1879
|
Examples:
|
|
1728
1880
|
>>> import mindspore.dataset as ds
|
|
@@ -1737,7 +1889,7 @@ class Normalize(ImageTensorOperation):
|
|
|
1737
1889
|
|
|
1738
1890
|
Tutorial Examples:
|
|
1739
1891
|
- `Illustration of vision transforms
|
|
1740
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
1892
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
1741
1893
|
"""
|
|
1742
1894
|
|
|
1743
1895
|
@check_normalize
|
|
@@ -1749,8 +1901,45 @@ class Normalize(ImageTensorOperation):
|
|
|
1749
1901
|
self.random = False
|
|
1750
1902
|
self.implementation = Implementation.C
|
|
1751
1903
|
|
|
1904
|
+
@check_device_target
|
|
1905
|
+
def device(self, device_target="CPU"):
|
|
1906
|
+
"""
|
|
1907
|
+
Set the device for the current operator execution.
|
|
1908
|
+
|
|
1909
|
+
Args:
|
|
1910
|
+
device_target (str, optional): The operator will be executed on this device. Currently supports
|
|
1911
|
+
``CPU`` . Default: ``CPU`` .
|
|
1912
|
+
|
|
1913
|
+
Raises:
|
|
1914
|
+
TypeError: If `device_target` is not of type str.
|
|
1915
|
+
ValueError: If `device_target` is not ``CPU`` .
|
|
1916
|
+
|
|
1917
|
+
Supported Platforms:
|
|
1918
|
+
``CPU``
|
|
1919
|
+
|
|
1920
|
+
Examples:
|
|
1921
|
+
>>> import mindspore.dataset as ds
|
|
1922
|
+
>>> import mindspore.dataset.vision as vision
|
|
1923
|
+
>>> from mindspore.dataset.vision import Inter
|
|
1924
|
+
>>>
|
|
1925
|
+
>>> decode_op = vision.Decode()
|
|
1926
|
+
>>> resize_op = vision.Resize([100, 75], Inter.BICUBIC)
|
|
1927
|
+
>>> transforms_list = [decode_op, resize_op]
|
|
1928
|
+
>>> image_folder_dataset = ds.ImageFolderDataset("/path/to/image_folder_dataset_directory")
|
|
1929
|
+
>>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list,
|
|
1930
|
+
... input_columns=["image"])
|
|
1931
|
+
>>> normalize_op = vision.Normalize(mean=[121.0, 115.0, 100.0], std=[70.0, 68.0, 71.0]).device("Ascend")
|
|
1932
|
+
>>> image_folder_dataset = image_folder_dataset.map(operations=normalize_op, input_columns=["image"])
|
|
1933
|
+
|
|
1934
|
+
Tutorial Examples:
|
|
1935
|
+
- `Illustration of vision transforms
|
|
1936
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
1937
|
+
"""
|
|
1938
|
+
self.device_target = device_target
|
|
1939
|
+
return self
|
|
1940
|
+
|
|
1752
1941
|
def parse(self):
|
|
1753
|
-
return cde.NormalizeOperation(self.mean, self.std, self.is_hwc)
|
|
1942
|
+
return cde.NormalizeOperation(self.mean, self.std, self.is_hwc, self.device_target)
|
|
1754
1943
|
|
|
1755
1944
|
|
|
1756
1945
|
class NormalizePad(ImageTensorOperation):
|
|
@@ -1857,7 +2046,7 @@ class Pad(ImageTensorOperation, PyTensorOperation):
|
|
|
1857
2046
|
|
|
1858
2047
|
Tutorial Examples:
|
|
1859
2048
|
- `Illustration of vision transforms
|
|
1860
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
2049
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
1861
2050
|
"""
|
|
1862
2051
|
|
|
1863
2052
|
@check_pad
|
|
@@ -1935,7 +2124,7 @@ class PadToSize(ImageTensorOperation):
|
|
|
1935
2124
|
|
|
1936
2125
|
Tutorial Examples:
|
|
1937
2126
|
- `Illustration of vision transforms
|
|
1938
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
2127
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
1939
2128
|
"""
|
|
1940
2129
|
|
|
1941
2130
|
@check_pad_to_size
|
|
@@ -1965,23 +2154,13 @@ class Perspective(ImageTensorOperation, PyTensorOperation):
|
|
|
1965
2154
|
end_points (Sequence[Sequence[int, int]]): Sequence of the ending point coordinates, containing four
|
|
1966
2155
|
two-element subsequences, corresponding to [top-left, top-right, bottom-right, bottom-left] of the
|
|
1967
2156
|
quadrilateral in the target image.
|
|
1968
|
-
interpolation (Inter, optional):
|
|
1969
|
-
``Inter.NEAREST``, ``Inter.AREA``, ``Inter.PILCUBIC``, ``Inter.CUBIC`` or ``Inter.BICUBIC``.
|
|
2157
|
+
interpolation (Inter, optional): Image interpolation method defined by :class:`~.vision.Inter` .
|
|
1970
2158
|
Default: ``Inter.BILINEAR``.
|
|
1971
2159
|
|
|
1972
|
-
- ``Inter.BILINEA`` , bilinear interpolation.
|
|
1973
|
-
- ``Inter.LINEAR`` , linear interpolation, the same as Inter.BILINEAR.
|
|
1974
|
-
- ``Inter.NEAREST`` , nearest-neighbor interpolation.
|
|
1975
|
-
- ``Inter.BICUBIC`` , bicubic interpolation.
|
|
1976
|
-
- ``Inter.CUBIC`` , cubic interpolation, the same as Inter.BICUBIC.
|
|
1977
|
-
- ``Inter.PILCUBIC`` , cubic interpolation based on the implementation of Pillow,
|
|
1978
|
-
only numpy.ndarray input is supported.
|
|
1979
|
-
- ``Inter.AREA`` :, pixel area interpolation, only numpy.ndarray input is supported.
|
|
1980
|
-
|
|
1981
2160
|
Raises:
|
|
1982
2161
|
TypeError: If `start_points` is not of type Sequence[Sequence[int, int]].
|
|
1983
2162
|
TypeError: If `end_points` is not of type Sequence[Sequence[int, int]].
|
|
1984
|
-
TypeError: If `interpolation` is not of type :class
|
|
2163
|
+
TypeError: If `interpolation` is not of type :class:`~.vision.Inter` .
|
|
1985
2164
|
RuntimeError: If shape of the input image is not <H, W> or <H, W, C>.
|
|
1986
2165
|
|
|
1987
2166
|
Supported Platforms:
|
|
@@ -2004,7 +2183,7 @@ class Perspective(ImageTensorOperation, PyTensorOperation):
|
|
|
2004
2183
|
|
|
2005
2184
|
Tutorial Examples:
|
|
2006
2185
|
- `Illustration of vision transforms
|
|
2007
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
2186
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
2008
2187
|
"""
|
|
2009
2188
|
|
|
2010
2189
|
@check_perspective
|
|
@@ -2063,7 +2242,7 @@ class Posterize(ImageTensorOperation):
|
|
|
2063
2242
|
|
|
2064
2243
|
Tutorial Examples:
|
|
2065
2244
|
- `Illustration of vision transforms
|
|
2066
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
2245
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
2067
2246
|
"""
|
|
2068
2247
|
|
|
2069
2248
|
@check_posterize
|
|
@@ -2090,14 +2269,8 @@ class RandAugment(ImageTensorOperation):
|
|
|
2090
2269
|
`num_magnitude_bins`. Default: ``9``.
|
|
2091
2270
|
num_magnitude_bins (int, optional): The number of different magnitude values,
|
|
2092
2271
|
must be no less than 2. Default: ``31``.
|
|
2093
|
-
interpolation (Inter, optional): Image interpolation method
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
- ``Inter.NEAREST`` , nearest-neighbor interpolation.
|
|
2097
|
-
- ``Inter.BILINEA`` , bilinear interpolation.
|
|
2098
|
-
- ``Inter.BICUBIC`` , bicubic interpolation.
|
|
2099
|
-
- ``Inter.AREA`` :, pixel area interpolation.
|
|
2100
|
-
|
|
2272
|
+
interpolation (Inter, optional): Image interpolation method defined by :class:`~.vision.Inter` .
|
|
2273
|
+
Default: ``Inter.NEAREST``.
|
|
2101
2274
|
fill_value (Union[int, tuple[int, int, int]], optional): Pixel fill value for the area outside the
|
|
2102
2275
|
transformed image, must be in range of [0, 255]. Default: ``0``.
|
|
2103
2276
|
If int is provided, pad all RGB channels with this value.
|
|
@@ -2110,7 +2283,7 @@ class RandAugment(ImageTensorOperation):
|
|
|
2110
2283
|
ValueError: If `magnitude` is not positive.
|
|
2111
2284
|
TypeError: If `num_magnitude_bins` is not of type int.
|
|
2112
2285
|
ValueError: If `num_magnitude_bins` is less than 2.
|
|
2113
|
-
TypeError: If `interpolation` not of type :class
|
|
2286
|
+
TypeError: If `interpolation` not of type :class:`~.vision.Inter` .
|
|
2114
2287
|
TypeError: If `fill_value` is not of type int or tuple[int, int, int].
|
|
2115
2288
|
ValueError: If `fill_value` is not in range of [0, 255].
|
|
2116
2289
|
RuntimeError: If shape of the input image is not <H, W, C>.
|
|
@@ -2128,7 +2301,7 @@ class RandAugment(ImageTensorOperation):
|
|
|
2128
2301
|
|
|
2129
2302
|
Tutorial Examples:
|
|
2130
2303
|
- `Illustration of vision transforms
|
|
2131
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
2304
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
2132
2305
|
"""
|
|
2133
2306
|
|
|
2134
2307
|
@check_rand_augment
|
|
@@ -2180,7 +2353,7 @@ class RandomAdjustSharpness(ImageTensorOperation):
|
|
|
2180
2353
|
|
|
2181
2354
|
Tutorial Examples:
|
|
2182
2355
|
- `Illustration of vision transforms
|
|
2183
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
2356
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
2184
2357
|
"""
|
|
2185
2358
|
|
|
2186
2359
|
@check_random_adjust_sharpness
|
|
@@ -2223,17 +2396,8 @@ class RandomAffine(ImageTensorOperation, PyTensorOperation):
|
|
|
2223
2396
|
If Sequence[float, float, float, float] is provided, a shearing parallel to X axis with a factor selected
|
|
2224
2397
|
from ( `shear` [0], `shear` [1]) and a shearing parallel to Y axis with a factor selected from
|
|
2225
2398
|
( `shear` [2], `shear` [3]) will be applied. Default: ``None``, means no shearing.
|
|
2226
|
-
resample (Inter, optional):
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
- ``Inter.BILINEA`` , means resample method is bilinear interpolation.
|
|
2230
|
-
|
|
2231
|
-
- ``Inter.NEAREST`` , means resample method is nearest-neighbor interpolation.
|
|
2232
|
-
|
|
2233
|
-
- ``Inter.BICUBIC`` , means resample method is bicubic interpolation.
|
|
2234
|
-
|
|
2235
|
-
- ``Inter.AREA`` :, means resample method is pixel area interpolation.
|
|
2236
|
-
|
|
2399
|
+
resample (Inter, optional): Image interpolation method defined by :class:`~.vision.Inter` .
|
|
2400
|
+
Default: ``Inter.NEAREST``.
|
|
2237
2401
|
fill_value (Union[int, tuple[int]], optional): Optional fill_value to fill the area outside the transform
|
|
2238
2402
|
in the output image. There must be three elements in tuple and the value of single element is [0, 255].
|
|
2239
2403
|
Default: ``0``, filling is performed.
|
|
@@ -2243,7 +2407,7 @@ class RandomAffine(ImageTensorOperation, PyTensorOperation):
|
|
|
2243
2407
|
TypeError: If `translate` is not of type sequence.
|
|
2244
2408
|
TypeError: If `scale` is not of type sequence.
|
|
2245
2409
|
TypeError: If `shear` is not of type int, float or sequence.
|
|
2246
|
-
TypeError: If `resample` is not of type :class
|
|
2410
|
+
TypeError: If `resample` is not of type :class:`~.vision.Inter` .
|
|
2247
2411
|
TypeError: If `fill_value` is not of type int or tuple[int].
|
|
2248
2412
|
ValueError: If `degrees` is negative.
|
|
2249
2413
|
ValueError: If `translate` is not in range [-1.0, 1.0].
|
|
@@ -2271,7 +2435,7 @@ class RandomAffine(ImageTensorOperation, PyTensorOperation):
|
|
|
2271
2435
|
|
|
2272
2436
|
Tutorial Examples:
|
|
2273
2437
|
- `Illustration of vision transforms
|
|
2274
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
2438
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
2275
2439
|
"""
|
|
2276
2440
|
|
|
2277
2441
|
@check_random_affine
|
|
@@ -2378,7 +2542,7 @@ class RandomAutoContrast(ImageTensorOperation):
|
|
|
2378
2542
|
|
|
2379
2543
|
Tutorial Examples:
|
|
2380
2544
|
- `Illustration of vision transforms
|
|
2381
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
2545
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
2382
2546
|
"""
|
|
2383
2547
|
|
|
2384
2548
|
@check_random_auto_contrast
|
|
@@ -2426,7 +2590,7 @@ class RandomColor(ImageTensorOperation, PyTensorOperation):
|
|
|
2426
2590
|
|
|
2427
2591
|
Tutorial Examples:
|
|
2428
2592
|
- `Illustration of vision transforms
|
|
2429
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
2593
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
2430
2594
|
"""
|
|
2431
2595
|
|
|
2432
2596
|
@check_positive_degrees
|
|
@@ -2456,7 +2620,8 @@ class RandomColorAdjust(ImageTensorOperation, PyTensorOperation):
|
|
|
2456
2620
|
Randomly adjust the brightness, contrast, saturation, and hue of the input image.
|
|
2457
2621
|
|
|
2458
2622
|
Note:
|
|
2459
|
-
This operation
|
|
2623
|
+
This operation is executed on the CPU by default, but it is also supported
|
|
2624
|
+
to be executed on the GPU or Ascend via heterogeneous acceleration.
|
|
2460
2625
|
|
|
2461
2626
|
Args:
|
|
2462
2627
|
brightness (Union[float, Sequence[float]], optional): Brightness adjustment factor. Default: ``(1, 1)``.
|
|
@@ -2487,7 +2652,7 @@ class RandomColorAdjust(ImageTensorOperation, PyTensorOperation):
|
|
|
2487
2652
|
RuntimeError: If given tensor shape is not <H, W, C>.
|
|
2488
2653
|
|
|
2489
2654
|
Supported Platforms:
|
|
2490
|
-
``CPU``
|
|
2655
|
+
``CPU`` ``GPU`` ``Ascend``
|
|
2491
2656
|
|
|
2492
2657
|
Examples:
|
|
2493
2658
|
>>> import mindspore.dataset as ds
|
|
@@ -2504,7 +2669,7 @@ class RandomColorAdjust(ImageTensorOperation, PyTensorOperation):
|
|
|
2504
2669
|
|
|
2505
2670
|
Tutorial Examples:
|
|
2506
2671
|
- `Illustration of vision transforms
|
|
2507
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
2672
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
2508
2673
|
"""
|
|
2509
2674
|
|
|
2510
2675
|
@check_random_color_adjust
|
|
@@ -2614,7 +2779,7 @@ class RandomCrop(ImageTensorOperation, PyTensorOperation):
|
|
|
2614
2779
|
|
|
2615
2780
|
Tutorial Examples:
|
|
2616
2781
|
- `Illustration of vision transforms
|
|
2617
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
2782
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
2618
2783
|
"""
|
|
2619
2784
|
|
|
2620
2785
|
@check_random_crop
|
|
@@ -2666,20 +2831,8 @@ class RandomCropDecodeResize(ImageTensorOperation):
|
|
|
2666
2831
|
original size to be cropped, which must be non-negative. Default: ``(0.08, 1.0)``.
|
|
2667
2832
|
ratio (Union[list, tuple], optional): Range [min, max) of aspect ratio to be
|
|
2668
2833
|
cropped, which must be non-negative. Default: ``(3. / 4., 4. / 3.)``.
|
|
2669
|
-
interpolation (Inter, optional): Image interpolation
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
- ``Inter.BILINEA`` , means interpolation method is bilinear interpolation.
|
|
2673
|
-
|
|
2674
|
-
- ``Inter.NEAREST`` , means interpolation method is nearest-neighbor interpolation.
|
|
2675
|
-
|
|
2676
|
-
- ``Inter.BICUBIC`` , means interpolation method is bicubic interpolation.
|
|
2677
|
-
|
|
2678
|
-
- ``Inter.AREA`` :, means interpolation method is pixel area interpolation.
|
|
2679
|
-
|
|
2680
|
-
- ``Inter.PILCUBIC`` , means interpolation method is bicubic interpolation like implemented in pillow, input
|
|
2681
|
-
should be in 3 channels format.
|
|
2682
|
-
|
|
2834
|
+
interpolation (Inter, optional): Image interpolation method defined by :class:`~.vision.Inter` .
|
|
2835
|
+
Default: ``Inter.BILINEAR``.
|
|
2683
2836
|
max_attempts (int, optional): The maximum number of attempts to propose a valid crop_area. Default: ``10``.
|
|
2684
2837
|
If exceeded, fall back to use center_crop instead. The `max_attempts` value must be positive.
|
|
2685
2838
|
|
|
@@ -2687,7 +2840,7 @@ class RandomCropDecodeResize(ImageTensorOperation):
|
|
|
2687
2840
|
TypeError: If `size` is not of type int or Sequence[int].
|
|
2688
2841
|
TypeError: If `scale` is not of type tuple.
|
|
2689
2842
|
TypeError: If `ratio` is not of type tuple.
|
|
2690
|
-
TypeError: If `interpolation` is not of type :class
|
|
2843
|
+
TypeError: If `interpolation` is not of type :class:`~.vision.Inter` .
|
|
2691
2844
|
TypeError: If `max_attempts` is not of type integer.
|
|
2692
2845
|
ValueError: If `size` is not positive.
|
|
2693
2846
|
ValueError: If `scale` is negative.
|
|
@@ -2714,7 +2867,7 @@ class RandomCropDecodeResize(ImageTensorOperation):
|
|
|
2714
2867
|
|
|
2715
2868
|
Tutorial Examples:
|
|
2716
2869
|
- `Illustration of vision transforms
|
|
2717
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
2870
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
2718
2871
|
"""
|
|
2719
2872
|
|
|
2720
2873
|
@check_random_resize_crop
|
|
@@ -2807,7 +2960,7 @@ class RandomCropWithBBox(ImageTensorOperation):
|
|
|
2807
2960
|
|
|
2808
2961
|
Tutorial Examples:
|
|
2809
2962
|
- `Illustration of vision transforms
|
|
2810
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
2963
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
2811
2964
|
"""
|
|
2812
2965
|
|
|
2813
2966
|
@check_random_crop
|
|
@@ -2863,7 +3016,7 @@ class RandomEqualize(ImageTensorOperation):
|
|
|
2863
3016
|
|
|
2864
3017
|
Tutorial Examples:
|
|
2865
3018
|
- `Illustration of vision transforms
|
|
2866
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
3019
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
2867
3020
|
"""
|
|
2868
3021
|
|
|
2869
3022
|
@check_prob
|
|
@@ -2930,7 +3083,7 @@ class RandomErasing(PyTensorOperation):
|
|
|
2930
3083
|
|
|
2931
3084
|
Tutorial Examples:
|
|
2932
3085
|
- `Illustration of vision transforms
|
|
2933
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
3086
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
2934
3087
|
"""
|
|
2935
3088
|
|
|
2936
3089
|
@check_random_erasing
|
|
@@ -2992,7 +3145,7 @@ class RandomGrayscale(PyTensorOperation):
|
|
|
2992
3145
|
|
|
2993
3146
|
Tutorial Examples:
|
|
2994
3147
|
- `Illustration of vision transforms
|
|
2995
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
3148
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
2996
3149
|
"""
|
|
2997
3150
|
|
|
2998
3151
|
@check_prob
|
|
@@ -3050,7 +3203,7 @@ class RandomHorizontalFlip(ImageTensorOperation, PyTensorOperation):
|
|
|
3050
3203
|
|
|
3051
3204
|
Tutorial Examples:
|
|
3052
3205
|
- `Illustration of vision transforms
|
|
3053
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
3206
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
3054
3207
|
"""
|
|
3055
3208
|
|
|
3056
3209
|
@check_prob
|
|
@@ -3076,7 +3229,7 @@ class RandomHorizontalFlip(ImageTensorOperation, PyTensorOperation):
|
|
|
3076
3229
|
|
|
3077
3230
|
class RandomHorizontalFlipWithBBox(ImageTensorOperation):
|
|
3078
3231
|
"""
|
|
3079
|
-
|
|
3232
|
+
Randomly flip the input image and its bounding box horizontally with a given probability.
|
|
3080
3233
|
|
|
3081
3234
|
Args:
|
|
3082
3235
|
prob (float, optional): Probability of the image being flipped,
|
|
@@ -3101,7 +3254,7 @@ class RandomHorizontalFlipWithBBox(ImageTensorOperation):
|
|
|
3101
3254
|
|
|
3102
3255
|
Tutorial Examples:
|
|
3103
3256
|
- `Illustration of vision transforms
|
|
3104
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
3257
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
3105
3258
|
"""
|
|
3106
3259
|
|
|
3107
3260
|
@check_prob
|
|
@@ -3141,7 +3294,7 @@ class RandomInvert(ImageTensorOperation):
|
|
|
3141
3294
|
|
|
3142
3295
|
Tutorial Examples:
|
|
3143
3296
|
- `Illustration of vision transforms
|
|
3144
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
3297
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
3145
3298
|
"""
|
|
3146
3299
|
|
|
3147
3300
|
@check_prob
|
|
@@ -3181,7 +3334,7 @@ class RandomLighting(ImageTensorOperation, PyTensorOperation):
|
|
|
3181
3334
|
|
|
3182
3335
|
Tutorial Examples:
|
|
3183
3336
|
- `Illustration of vision transforms
|
|
3184
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
3337
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
3185
3338
|
"""
|
|
3186
3339
|
|
|
3187
3340
|
@check_alpha
|
|
@@ -3214,17 +3367,13 @@ class RandomPerspective(PyTensorOperation):
|
|
|
3214
3367
|
distortion_scale (float, optional): Scale of distortion, in range of [0.0, 1.0]. Default: ``0.5``.
|
|
3215
3368
|
prob (float, optional): Probability of performing perspective transformation, which
|
|
3216
3369
|
must be in range of [0.0, 1.0]. Default: ``0.5``.
|
|
3217
|
-
interpolation (Inter, optional):
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
- ``Inter.BILINEA`` , bilinear interpolation.
|
|
3221
|
-
- ``Inter.NEAREST`` , nearest-neighbor interpolation.
|
|
3222
|
-
- ``Inter.BICUBIC`` , bicubic interpolation.
|
|
3370
|
+
interpolation (Inter, optional): Image interpolation method defined by :class:`~.vision.Inter` .
|
|
3371
|
+
Default: ``Inter.BICUBIC``.
|
|
3223
3372
|
|
|
3224
3373
|
Raises:
|
|
3225
3374
|
TypeError: If `distortion_scale` is not of type float.
|
|
3226
3375
|
TypeError: If `prob` is not of type float.
|
|
3227
|
-
TypeError: If `interpolation` is not of type :class
|
|
3376
|
+
TypeError: If `interpolation` is not of type :class:`~.vision.Inter` .
|
|
3228
3377
|
ValueError: If `distortion_scale` is not in range of [0.0, 1.0].
|
|
3229
3378
|
ValueError: If `prob` is not in range of [0.0, 1.0].
|
|
3230
3379
|
|
|
@@ -3246,7 +3395,7 @@ class RandomPerspective(PyTensorOperation):
|
|
|
3246
3395
|
|
|
3247
3396
|
Tutorial Examples:
|
|
3248
3397
|
- `Illustration of vision transforms
|
|
3249
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
3398
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
3250
3399
|
"""
|
|
3251
3400
|
|
|
3252
3401
|
@check_random_perspective
|
|
@@ -3309,7 +3458,7 @@ class RandomPosterize(ImageTensorOperation):
|
|
|
3309
3458
|
|
|
3310
3459
|
Tutorial Examples:
|
|
3311
3460
|
- `Illustration of vision transforms
|
|
3312
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
3461
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
3313
3462
|
"""
|
|
3314
3463
|
|
|
3315
3464
|
@check_random_posterize
|
|
@@ -3328,7 +3477,7 @@ class RandomPosterize(ImageTensorOperation):
|
|
|
3328
3477
|
class RandomResizedCrop(ImageTensorOperation, PyTensorOperation):
|
|
3329
3478
|
"""
|
|
3330
3479
|
This operation will crop the input image randomly,
|
|
3331
|
-
and resize the cropped image using a selected interpolation mode :class
|
|
3480
|
+
and resize the cropped image using a selected interpolation mode :class:`~.vision.Inter` .
|
|
3332
3481
|
|
|
3333
3482
|
Note:
|
|
3334
3483
|
If the input image is more than one, then make sure that the image size is the same.
|
|
@@ -3341,22 +3490,8 @@ class RandomResizedCrop(ImageTensorOperation, PyTensorOperation):
|
|
|
3341
3490
|
size to be cropped, which must be non-negative. Default: ``(0.08, 1.0)``.
|
|
3342
3491
|
ratio (Union[list, tuple], optional): Range [min, max) of aspect ratio to be
|
|
3343
3492
|
cropped, which must be non-negative. Default: ``(3. / 4., 4. / 3.)``.
|
|
3344
|
-
interpolation (Inter, optional):
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
- ``Inter.BILINEA`` , means interpolation method is bilinear interpolation.
|
|
3348
|
-
|
|
3349
|
-
- ``Inter.NEAREST`` , means interpolation method is nearest-neighbor interpolation.
|
|
3350
|
-
|
|
3351
|
-
- ``Inter.BICUBIC`` , means interpolation method is bicubic interpolation.
|
|
3352
|
-
|
|
3353
|
-
- ``Inter.AREA`` :, means interpolation method is pixel area interpolation.
|
|
3354
|
-
|
|
3355
|
-
- ``Inter.PILCUBIC`` , means interpolation method is bicubic interpolation like implemented in pillow, input
|
|
3356
|
-
should be in 3 channels format.
|
|
3357
|
-
|
|
3358
|
-
- ``Inter.ANTIALIAS`` , means the interpolation method is antialias interpolation.
|
|
3359
|
-
|
|
3493
|
+
interpolation (Inter, optional): Image interpolation method defined by :class:`~.vision.Inter` .
|
|
3494
|
+
Default: ``Inter.BILINEAR``.
|
|
3360
3495
|
max_attempts (int, optional): The maximum number of attempts to propose a valid
|
|
3361
3496
|
crop_area. Default: ``10``. If exceeded, fall back to use center_crop instead.
|
|
3362
3497
|
|
|
@@ -3364,7 +3499,7 @@ class RandomResizedCrop(ImageTensorOperation, PyTensorOperation):
|
|
|
3364
3499
|
TypeError: If `size` is not of type int or Sequence[int].
|
|
3365
3500
|
TypeError: If `scale` is not of type tuple or list.
|
|
3366
3501
|
TypeError: If `ratio` is not of type tuple or list.
|
|
3367
|
-
TypeError: If `interpolation` is not of type :class
|
|
3502
|
+
TypeError: If `interpolation` is not of type :class:`~.vision.Inter` .
|
|
3368
3503
|
TypeError: If `max_attempts` is not of type int.
|
|
3369
3504
|
ValueError: If `size` is not positive.
|
|
3370
3505
|
ValueError: If `scale` is negative.
|
|
@@ -3389,7 +3524,7 @@ class RandomResizedCrop(ImageTensorOperation, PyTensorOperation):
|
|
|
3389
3524
|
|
|
3390
3525
|
Tutorial Examples:
|
|
3391
3526
|
- `Illustration of vision transforms
|
|
3392
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
3527
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
3393
3528
|
"""
|
|
3394
3529
|
|
|
3395
3530
|
@check_random_resize_crop
|
|
@@ -3442,15 +3577,8 @@ class RandomResizedCropWithBBox(ImageTensorOperation):
|
|
|
3442
3577
|
size to be cropped, which must be non-negative. Default: ``(0.08, 1.0)``.
|
|
3443
3578
|
ratio (Union[list, tuple], optional): Range (min, max) of aspect ratio to be
|
|
3444
3579
|
cropped, which must be non-negative. Default: ``(3. / 4., 4. / 3.)``.
|
|
3445
|
-
interpolation (Inter, optional): Image interpolation
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
- ``Inter.BILINEA`` , means interpolation method is bilinear interpolation.
|
|
3449
|
-
|
|
3450
|
-
- ``Inter.NEAREST`` , means interpolation method is nearest-neighbor interpolation.
|
|
3451
|
-
|
|
3452
|
-
- ``Inter.BICUBIC`` , means interpolation method is bicubic interpolation.
|
|
3453
|
-
|
|
3580
|
+
interpolation (Inter, optional): Image interpolation method defined by :class:`~.vision.Inter` .
|
|
3581
|
+
Default: ``Inter.BILINEAR``.
|
|
3454
3582
|
max_attempts (int, optional): The maximum number of attempts to propose a valid
|
|
3455
3583
|
crop area. Default: ``10``. If exceeded, fall back to use center crop instead.
|
|
3456
3584
|
|
|
@@ -3483,7 +3611,7 @@ class RandomResizedCropWithBBox(ImageTensorOperation):
|
|
|
3483
3611
|
|
|
3484
3612
|
Tutorial Examples:
|
|
3485
3613
|
- `Illustration of vision transforms
|
|
3486
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
3614
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
3487
3615
|
"""
|
|
3488
3616
|
|
|
3489
3617
|
@check_random_resize_crop
|
|
@@ -3506,7 +3634,7 @@ class RandomResizedCropWithBBox(ImageTensorOperation):
|
|
|
3506
3634
|
|
|
3507
3635
|
class RandomResize(ImageTensorOperation):
|
|
3508
3636
|
"""
|
|
3509
|
-
Resize the input image using :class
|
|
3637
|
+
Resize the input image using :class:`~.vision.Inter` , a randomly selected interpolation mode.
|
|
3510
3638
|
|
|
3511
3639
|
Args:
|
|
3512
3640
|
size (Union[int, Sequence[int]]): The output size of the resized image. The size value(s) must be positive.
|
|
@@ -3538,7 +3666,7 @@ class RandomResize(ImageTensorOperation):
|
|
|
3538
3666
|
|
|
3539
3667
|
Tutorial Examples:
|
|
3540
3668
|
- `Illustration of vision transforms
|
|
3541
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
3669
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
3542
3670
|
"""
|
|
3543
3671
|
|
|
3544
3672
|
@check_resize
|
|
@@ -3557,7 +3685,7 @@ class RandomResize(ImageTensorOperation):
|
|
|
3557
3685
|
class RandomResizeWithBBox(ImageTensorOperation):
|
|
3558
3686
|
"""
|
|
3559
3687
|
Tensor operation to resize the input image
|
|
3560
|
-
using a randomly selected interpolation mode :class
|
|
3688
|
+
using a randomly selected interpolation mode :class:`~.vision.Inter` and adjust
|
|
3561
3689
|
bounding boxes accordingly.
|
|
3562
3690
|
|
|
3563
3691
|
Args:
|
|
@@ -3592,7 +3720,7 @@ class RandomResizeWithBBox(ImageTensorOperation):
|
|
|
3592
3720
|
|
|
3593
3721
|
Tutorial Examples:
|
|
3594
3722
|
- `Illustration of vision transforms
|
|
3595
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
3723
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
3596
3724
|
"""
|
|
3597
3725
|
|
|
3598
3726
|
@check_resize
|
|
@@ -3616,17 +3744,8 @@ class RandomRotation(ImageTensorOperation, PyTensorOperation):
|
|
|
3616
3744
|
degrees (Union[int, float, sequence]): Range of random rotation degrees.
|
|
3617
3745
|
If `degrees` is a number, the range will be converted to (-degrees, degrees).
|
|
3618
3746
|
If `degrees` is a sequence, it should be (min, max).
|
|
3619
|
-
resample (Inter, optional):
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
- ``Inter.BILINEA`` , means resample method is bilinear interpolation.
|
|
3623
|
-
|
|
3624
|
-
- ``Inter.NEAREST`` , means resample method is nearest-neighbor interpolation.
|
|
3625
|
-
|
|
3626
|
-
- ``Inter.BICUBIC`` , means resample method is bicubic interpolation.
|
|
3627
|
-
|
|
3628
|
-
- ``Inter.AREA`` :, means the interpolation method is pixel area interpolation.
|
|
3629
|
-
|
|
3747
|
+
resample (Inter, optional): Image interpolation method defined by :class:`~.vision.Inter` .
|
|
3748
|
+
Default: ``Inter.NEAREST``.
|
|
3630
3749
|
expand (bool, optional): Optional expansion flag. Default: ``False``. If set to ``True``,
|
|
3631
3750
|
expand the output image to make it large enough to hold the entire rotated image.
|
|
3632
3751
|
If set to ``False`` or omitted, make the output image the same size as the input.
|
|
@@ -3665,7 +3784,7 @@ class RandomRotation(ImageTensorOperation, PyTensorOperation):
|
|
|
3665
3784
|
|
|
3666
3785
|
Tutorial Examples:
|
|
3667
3786
|
- `Illustration of vision transforms
|
|
3668
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
3787
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
3669
3788
|
"""
|
|
3670
3789
|
|
|
3671
3790
|
@check_random_rotation
|
|
@@ -3750,7 +3869,7 @@ class RandomSelectSubpolicy(ImageTensorOperation):
|
|
|
3750
3869
|
|
|
3751
3870
|
Tutorial Examples:
|
|
3752
3871
|
- `Illustration of vision transforms
|
|
3753
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
3872
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
3754
3873
|
"""
|
|
3755
3874
|
|
|
3756
3875
|
@check_random_select_subpolicy_op
|
|
@@ -3801,7 +3920,7 @@ class RandomSharpness(ImageTensorOperation, PyTensorOperation):
|
|
|
3801
3920
|
|
|
3802
3921
|
Tutorial Examples:
|
|
3803
3922
|
- `Illustration of vision transforms
|
|
3804
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
3923
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
3805
3924
|
"""
|
|
3806
3925
|
|
|
3807
3926
|
@check_positive_degrees
|
|
@@ -3855,7 +3974,7 @@ class RandomSolarize(ImageTensorOperation):
|
|
|
3855
3974
|
|
|
3856
3975
|
Tutorial Examples:
|
|
3857
3976
|
- `Illustration of vision transforms
|
|
3858
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
3977
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
3859
3978
|
"""
|
|
3860
3979
|
|
|
3861
3980
|
@check_random_solarize
|
|
@@ -3895,7 +4014,7 @@ class RandomVerticalFlip(ImageTensorOperation, PyTensorOperation):
|
|
|
3895
4014
|
|
|
3896
4015
|
Tutorial Examples:
|
|
3897
4016
|
- `Illustration of vision transforms
|
|
3898
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
4017
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
3899
4018
|
"""
|
|
3900
4019
|
|
|
3901
4020
|
@check_prob
|
|
@@ -3946,7 +4065,7 @@ class RandomVerticalFlipWithBBox(ImageTensorOperation):
|
|
|
3946
4065
|
|
|
3947
4066
|
Tutorial Examples:
|
|
3948
4067
|
- `Illustration of vision transforms
|
|
3949
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
4068
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
3950
4069
|
"""
|
|
3951
4070
|
|
|
3952
4071
|
@check_prob
|
|
@@ -3965,7 +4084,8 @@ class Rescale(ImageTensorOperation):
|
|
|
3965
4084
|
with: output = image * rescale + shift.
|
|
3966
4085
|
|
|
3967
4086
|
Note:
|
|
3968
|
-
This operation
|
|
4087
|
+
This operation is executed on the CPU by default, but it is also supported
|
|
4088
|
+
to be executed on the GPU or Ascend via heterogeneous acceleration.
|
|
3969
4089
|
|
|
3970
4090
|
Args:
|
|
3971
4091
|
rescale (float): Rescale factor.
|
|
@@ -3976,7 +4096,7 @@ class Rescale(ImageTensorOperation):
|
|
|
3976
4096
|
TypeError: If `shift` is not of type float.
|
|
3977
4097
|
|
|
3978
4098
|
Supported Platforms:
|
|
3979
|
-
``
|
|
4099
|
+
``CPU`` ``GPU`` ``Ascend``
|
|
3980
4100
|
|
|
3981
4101
|
Examples:
|
|
3982
4102
|
>>> import mindspore.dataset as ds
|
|
@@ -3989,7 +4109,7 @@ class Rescale(ImageTensorOperation):
|
|
|
3989
4109
|
|
|
3990
4110
|
Tutorial Examples:
|
|
3991
4111
|
- `Illustration of vision transforms
|
|
3992
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
4112
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
3993
4113
|
"""
|
|
3994
4114
|
|
|
3995
4115
|
@check_rescale
|
|
@@ -4005,34 +4125,24 @@ class Rescale(ImageTensorOperation):
|
|
|
4005
4125
|
|
|
4006
4126
|
class Resize(ImageTensorOperation, PyTensorOperation):
|
|
4007
4127
|
"""
|
|
4008
|
-
Resize the input image to the given size with a given interpolation mode :class
|
|
4128
|
+
Resize the input image to the given size with a given interpolation mode :class:`~.vision.Inter` .
|
|
4009
4129
|
|
|
4010
4130
|
Args:
|
|
4011
4131
|
size (Union[int, Sequence[int]]): The output size of the resized image. The size value(s) must be positive.
|
|
4012
4132
|
If size is an integer, the smaller edge of the image will be resized to this value with
|
|
4013
4133
|
the same image aspect ratio.
|
|
4014
4134
|
If size is a sequence of length 2, it should be (height, width).
|
|
4015
|
-
interpolation (Inter, optional): Image interpolation
|
|
4016
|
-
|
|
4017
|
-
``Inter.PILCUBIC``, ``Inter.ANTIALIAS``.
|
|
4018
|
-
|
|
4019
|
-
- ``Inter.BILINEAR``, bilinear interpolation.
|
|
4020
|
-
- ``Inter.LINEAR``, bilinear interpolation, here is the same as Inter.BILINEAR.
|
|
4021
|
-
- ``Inter.NEAREST``, nearest-neighbor interpolation.
|
|
4022
|
-
- ``Inter.BICUBIC``, bicubic interpolation.
|
|
4023
|
-
- ``Inter.AREA``, pixel area interpolation.
|
|
4024
|
-
- ``Inter.PILCUBIC``, bicubic interpolation like implemented in Pillow, only valid when the input is
|
|
4025
|
-
a 3-channel image in the numpy.ndarray format.
|
|
4026
|
-
- ``Inter.ANTIALIAS``, antialias interpolation.
|
|
4135
|
+
interpolation (Inter, optional): Image interpolation method defined by :class:`~.vision.Inter` .
|
|
4136
|
+
Default: ``Inter.LINEAR``.
|
|
4027
4137
|
|
|
4028
4138
|
Raises:
|
|
4029
4139
|
TypeError: If `size` is not of type int or Sequence[int].
|
|
4030
|
-
TypeError: If `interpolation` is not of type :class
|
|
4140
|
+
TypeError: If `interpolation` is not of type :class:`~.vision.Inter` .
|
|
4031
4141
|
ValueError: If `size` is not positive.
|
|
4032
4142
|
RuntimeError: If given tensor shape is not <H, W> or <H, W, C>.
|
|
4033
4143
|
|
|
4034
4144
|
Supported Platforms:
|
|
4035
|
-
``CPU``
|
|
4145
|
+
``CPU`` ``Ascend``
|
|
4036
4146
|
|
|
4037
4147
|
Examples:
|
|
4038
4148
|
>>> import mindspore.dataset as ds
|
|
@@ -4048,7 +4158,7 @@ class Resize(ImageTensorOperation, PyTensorOperation):
|
|
|
4048
4158
|
|
|
4049
4159
|
Tutorial Examples:
|
|
4050
4160
|
- `Illustration of vision transforms
|
|
4051
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
4161
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
4052
4162
|
"""
|
|
4053
4163
|
|
|
4054
4164
|
@check_resize_interpolation
|
|
@@ -4065,10 +4175,48 @@ class Resize(ImageTensorOperation, PyTensorOperation):
|
|
|
4065
4175
|
self.implementation = Implementation.PY
|
|
4066
4176
|
self.random = False
|
|
4067
4177
|
|
|
4178
|
+
@check_device_target
|
|
4179
|
+
def device(self, device_target="CPU"):
|
|
4180
|
+
"""
|
|
4181
|
+
Set the device for the current operator execution.
|
|
4182
|
+
|
|
4183
|
+
Args:
|
|
4184
|
+
device_target (str, optional): The operator will be executed on this device. Currently supports
|
|
4185
|
+
``CPU`` . Default: ``CPU`` .
|
|
4186
|
+
|
|
4187
|
+
Raises:
|
|
4188
|
+
TypeError: If `device_target` is not of type str.
|
|
4189
|
+
ValueError: If `device_target` is not ``CPU`` .
|
|
4190
|
+
|
|
4191
|
+
Supported Platforms:
|
|
4192
|
+
``CPU``
|
|
4193
|
+
|
|
4194
|
+
Examples:
|
|
4195
|
+
>>> import mindspore.dataset as ds
|
|
4196
|
+
>>> import mindspore.dataset.vision as vision
|
|
4197
|
+
>>> from mindspore.dataset.vision import Inter
|
|
4198
|
+
>>>
|
|
4199
|
+
>>> decode_op = vision.Decode()
|
|
4200
|
+
>>> resize_op = vision.Resize([100, 75], Inter.BICUBIC).device("Ascend")
|
|
4201
|
+
>>> transforms_list = [decode_op, resize_op]
|
|
4202
|
+
>>> image_folder_dataset = ds.ImageFolderDataset("/path/to/image_folder_dataset_directory")
|
|
4203
|
+
>>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list,
|
|
4204
|
+
... input_columns=["image"])
|
|
4205
|
+
|
|
4206
|
+
Tutorial Examples:
|
|
4207
|
+
- `Illustration of vision transforms
|
|
4208
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
4209
|
+
"""
|
|
4210
|
+
self.device_target = device_target
|
|
4211
|
+
if self.interpolation == Inter.ANTIALIAS and self.device_target == "Ascend":
|
|
4212
|
+
raise ValueError("The current InterpolationMode is not supported by DVPP. It is {}."
|
|
4213
|
+
.format(self.interpolation))
|
|
4214
|
+
return self
|
|
4215
|
+
|
|
4068
4216
|
def parse(self):
|
|
4069
4217
|
if self.interpolation == Inter.ANTIALIAS:
|
|
4070
|
-
raise TypeError("
|
|
4071
|
-
return cde.ResizeOperation(self.c_size, Inter.to_c_type(self.interpolation))
|
|
4218
|
+
raise TypeError("The current InterpolationMode is not supported with NumPy input.")
|
|
4219
|
+
return cde.ResizeOperation(self.c_size, Inter.to_c_type(self.interpolation), self.device_target)
|
|
4072
4220
|
|
|
4073
4221
|
def _execute_py(self, img):
|
|
4074
4222
|
"""
|
|
@@ -4098,14 +4246,8 @@ class ResizedCrop(ImageTensorOperation):
|
|
|
4098
4246
|
If int is provided, the smaller edge of the image will be resized to this value,
|
|
4099
4247
|
keeping the image aspect ratio the same.
|
|
4100
4248
|
If Sequence[int, int] is provided, it should be (height, width).
|
|
4101
|
-
interpolation (Inter, optional): Image interpolation method
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
- ``Inter.LINEAR`` , bilinear interpolation.
|
|
4105
|
-
- ``Inter.NEAREST`` , nearest-neighbor interpolation.
|
|
4106
|
-
- ``Inter.BICUBIC`` , bicubic interpolation.
|
|
4107
|
-
- ``Inter.AREA`` :, pixel area interpolation.
|
|
4108
|
-
- ``Inter.PILCUBIC`` , cubic interpolation based on the implementation of Pillow
|
|
4249
|
+
interpolation (Inter, optional): Image interpolation method defined by :class:`~.vision.Inter` .
|
|
4250
|
+
Default: ``Inter.BILINEAR``.
|
|
4109
4251
|
|
|
4110
4252
|
Raises:
|
|
4111
4253
|
TypeError: If `top` is not of type int.
|
|
@@ -4118,7 +4260,7 @@ class ResizedCrop(ImageTensorOperation):
|
|
|
4118
4260
|
ValueError: If `width` is not positive.
|
|
4119
4261
|
TypeError: If `size` is not of type int or Sequence[int, int].
|
|
4120
4262
|
ValueError: If `size` is not posotive.
|
|
4121
|
-
TypeError: If `interpolation` is not of type :class
|
|
4263
|
+
TypeError: If `interpolation` is not of type :class:`~.vision.Inter` .
|
|
4122
4264
|
RuntimeError: If shape of the input image is not <H, W> or <H, W, C>.
|
|
4123
4265
|
|
|
4124
4266
|
Supported Platforms:
|
|
@@ -4136,7 +4278,7 @@ class ResizedCrop(ImageTensorOperation):
|
|
|
4136
4278
|
|
|
4137
4279
|
Tutorial Examples:
|
|
4138
4280
|
- `Illustration of vision transforms
|
|
4139
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
4281
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
4140
4282
|
"""
|
|
4141
4283
|
|
|
4142
4284
|
@check_resized_crop
|
|
@@ -4167,18 +4309,12 @@ class ResizeWithBBox(ImageTensorOperation):
|
|
|
4167
4309
|
If size is an integer, smaller edge of the image will be resized to this value with
|
|
4168
4310
|
the same image aspect ratio.
|
|
4169
4311
|
If size is a sequence of length 2, it should be (height, width).
|
|
4170
|
-
interpolation (Inter, optional): Image interpolation
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
- ``Inter.LINEAR`` , means interpolation method is bilinear interpolation.
|
|
4174
|
-
|
|
4175
|
-
- ``Inter.NEAREST`` , means interpolation method is nearest-neighbor interpolation.
|
|
4176
|
-
|
|
4177
|
-
- ``Inter.BICUBIC`` , means interpolation method is bicubic interpolation.
|
|
4312
|
+
interpolation (Inter, optional): Image interpolation method defined by :class:`~.vision.Inter` .
|
|
4313
|
+
Default: ``Inter.LINEAR``.
|
|
4178
4314
|
|
|
4179
4315
|
Raises:
|
|
4180
4316
|
TypeError: If `size` is not of type int or Sequence[int].
|
|
4181
|
-
TypeError: If `interpolation` is not of type :class
|
|
4317
|
+
TypeError: If `interpolation` is not of type :class:`~.vision.Inter` .
|
|
4182
4318
|
ValueError: If `size` is not positive.
|
|
4183
4319
|
RuntimeError: If given tensor shape is not <H, W> or <H, W, C>.
|
|
4184
4320
|
|
|
@@ -4199,7 +4335,7 @@ class ResizeWithBBox(ImageTensorOperation):
|
|
|
4199
4335
|
|
|
4200
4336
|
Tutorial Examples:
|
|
4201
4337
|
- `Illustration of vision transforms
|
|
4202
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
4338
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
4203
4339
|
"""
|
|
4204
4340
|
|
|
4205
4341
|
@check_resize_interpolation
|
|
@@ -4246,7 +4382,7 @@ class RgbToHsv(PyTensorOperation):
|
|
|
4246
4382
|
|
|
4247
4383
|
Tutorial Examples:
|
|
4248
4384
|
- `Illustration of vision transforms
|
|
4249
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
4385
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
4250
4386
|
"""
|
|
4251
4387
|
|
|
4252
4388
|
@check_rgb_to_hsv
|
|
@@ -4275,14 +4411,8 @@ class Rotate(ImageTensorOperation):
|
|
|
4275
4411
|
|
|
4276
4412
|
Args:
|
|
4277
4413
|
degrees (Union[int, float]): Rotation degrees.
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
It can be ``Inter.BILINEAR``, ``Inter.NEAREST``, ``Inter.BICUBIC``.
|
|
4281
|
-
|
|
4282
|
-
- ``Inter.BILINEA`` , means resample method is bilinear interpolation.
|
|
4283
|
-
- ``Inter.NEAREST`` , means resample method is nearest-neighbor interpolation.
|
|
4284
|
-
- ``Inter.BICUBIC`` , means resample method is bicubic interpolation.
|
|
4285
|
-
|
|
4414
|
+
resample (Inter, optional): Image interpolation method defined by :class:`~.vision.Inter` .
|
|
4415
|
+
Default: ``Inter.NEAREST``.
|
|
4286
4416
|
expand (bool, optional): Optional expansion flag. Default: ``False``. If set to ``True``,
|
|
4287
4417
|
expand the output image to make it large enough to hold the entire rotated image.
|
|
4288
4418
|
If set to ``False`` or omitted, make the output image the same size as the input.
|
|
@@ -4296,7 +4426,7 @@ class Rotate(ImageTensorOperation):
|
|
|
4296
4426
|
|
|
4297
4427
|
Raises:
|
|
4298
4428
|
TypeError: If `degrees` is not of type integer, float or sequence.
|
|
4299
|
-
TypeError: If `resample` is not of type :class
|
|
4429
|
+
TypeError: If `resample` is not of type :class:`~.vision.Inter` .
|
|
4300
4430
|
TypeError: If `expand` is not of type bool.
|
|
4301
4431
|
TypeError: If `center` is not of type tuple.
|
|
4302
4432
|
TypeError: If `fill_value` is not of type int or tuple[int].
|
|
@@ -4321,7 +4451,7 @@ class Rotate(ImageTensorOperation):
|
|
|
4321
4451
|
|
|
4322
4452
|
Tutorial Examples:
|
|
4323
4453
|
- `Illustration of vision transforms
|
|
4324
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
4454
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
4325
4455
|
"""
|
|
4326
4456
|
|
|
4327
4457
|
@check_rotate
|
|
@@ -4394,7 +4524,7 @@ class SlicePatches(ImageTensorOperation):
|
|
|
4394
4524
|
|
|
4395
4525
|
Tutorial Examples:
|
|
4396
4526
|
- `Illustration of vision transforms
|
|
4397
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
4527
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
4398
4528
|
"""
|
|
4399
4529
|
|
|
4400
4530
|
@check_slice_patches
|
|
@@ -4438,7 +4568,7 @@ class Solarize(ImageTensorOperation):
|
|
|
4438
4568
|
|
|
4439
4569
|
Tutorial Examples:
|
|
4440
4570
|
- `Illustration of vision transforms
|
|
4441
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
4571
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
4442
4572
|
"""
|
|
4443
4573
|
|
|
4444
4574
|
@check_solarize
|
|
@@ -4489,7 +4619,7 @@ class TenCrop(PyTensorOperation):
|
|
|
4489
4619
|
|
|
4490
4620
|
Tutorial Examples:
|
|
4491
4621
|
- `Illustration of vision transforms
|
|
4492
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
4622
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
4493
4623
|
"""
|
|
4494
4624
|
|
|
4495
4625
|
@check_ten_crop
|
|
@@ -4540,7 +4670,7 @@ class ToNumpy(PyTensorOperation):
|
|
|
4540
4670
|
|
|
4541
4671
|
Tutorial Examples:
|
|
4542
4672
|
- `Illustration of vision transforms
|
|
4543
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
4673
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
4544
4674
|
"""
|
|
4545
4675
|
|
|
4546
4676
|
def __init__(self):
|
|
@@ -4566,9 +4696,6 @@ class ToPIL(PyTensorOperation):
|
|
|
4566
4696
|
"""
|
|
4567
4697
|
Convert the input decoded numpy.ndarray image to PIL Image.
|
|
4568
4698
|
|
|
4569
|
-
Note:
|
|
4570
|
-
The conversion mode will be determined by the data type using `PIL.Image.fromarray` .
|
|
4571
|
-
|
|
4572
4699
|
Raises:
|
|
4573
4700
|
TypeError: If the input image is not of type :class:`numpy.ndarray` or `PIL.Image.Image` .
|
|
4574
4701
|
|
|
@@ -4591,7 +4718,7 @@ class ToPIL(PyTensorOperation):
|
|
|
4591
4718
|
|
|
4592
4719
|
Tutorial Examples:
|
|
4593
4720
|
- `Illustration of vision transforms
|
|
4594
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
4721
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
4595
4722
|
"""
|
|
4596
4723
|
|
|
4597
4724
|
def __init__(self):
|
|
@@ -4644,7 +4771,7 @@ class ToTensor(ImageTensorOperation):
|
|
|
4644
4771
|
|
|
4645
4772
|
Tutorial Examples:
|
|
4646
4773
|
- `Illustration of vision transforms
|
|
4647
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
4774
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
4648
4775
|
"""
|
|
4649
4776
|
|
|
4650
4777
|
@check_to_tensor
|
|
@@ -4669,7 +4796,8 @@ class ToType(TypeCast):
|
|
|
4669
4796
|
It is the same as that of :class:`mindspore.dataset.transforms.TypeCast` .
|
|
4670
4797
|
|
|
4671
4798
|
Note:
|
|
4672
|
-
This operation
|
|
4799
|
+
This operation is executed on the CPU by default, but it is also supported
|
|
4800
|
+
to be executed on the GPU or Ascend via heterogeneous acceleration.
|
|
4673
4801
|
|
|
4674
4802
|
Args:
|
|
4675
4803
|
data_type (Union[mindspore.dtype, numpy.dtype]): The desired data type of the output image,
|
|
@@ -4679,7 +4807,7 @@ class ToType(TypeCast):
|
|
|
4679
4807
|
TypeError: If `data_type` is not of type :class:`mindspore.dtype` or :class:`numpy.dtype` .
|
|
4680
4808
|
|
|
4681
4809
|
Supported Platforms:
|
|
4682
|
-
``
|
|
4810
|
+
``CPU`` ``GPU`` ``Ascend``
|
|
4683
4811
|
|
|
4684
4812
|
Examples:
|
|
4685
4813
|
>>> import mindspore.dataset as ds
|
|
@@ -4698,7 +4826,7 @@ class ToType(TypeCast):
|
|
|
4698
4826
|
|
|
4699
4827
|
Tutorial Examples:
|
|
4700
4828
|
- `Illustration of vision transforms
|
|
4701
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
4829
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
4702
4830
|
"""
|
|
4703
4831
|
|
|
4704
4832
|
|
|
@@ -4714,14 +4842,8 @@ class TrivialAugmentWide(ImageTensorOperation):
|
|
|
4714
4842
|
Args:
|
|
4715
4843
|
num_magnitude_bins (int, optional): The number of different magnitude values,
|
|
4716
4844
|
must be greater than or equal to 2. Default: ``31``.
|
|
4717
|
-
interpolation (Inter, optional): Image interpolation method
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
- ``Inter.NEAREST`` , nearest-neighbor interpolation.
|
|
4721
|
-
- ``Inter.BILINEA`` , bilinear interpolation.
|
|
4722
|
-
- ``Inter.BICUBIC`` , bicubic interpolation.
|
|
4723
|
-
- ``Inter.AREA`` :, pixel area interpolation.
|
|
4724
|
-
|
|
4845
|
+
interpolation (Inter, optional): Image interpolation method defined by :class:`~.vision.Inter` .
|
|
4846
|
+
Default: ``Inter.NEAREST``.
|
|
4725
4847
|
fill_value (Union[int, tuple[int, int, int]], optional): Pixel fill value for the area outside the
|
|
4726
4848
|
transformed image, must be in range of [0, 255]. Default: ``0``.
|
|
4727
4849
|
If int is provided, pad all RGB channels with this value.
|
|
@@ -4730,7 +4852,7 @@ class TrivialAugmentWide(ImageTensorOperation):
|
|
|
4730
4852
|
Raises:
|
|
4731
4853
|
TypeError: If `num_magnitude_bins` is not of type int.
|
|
4732
4854
|
ValueError: If `num_magnitude_bins` is less than 2.
|
|
4733
|
-
TypeError: If `interpolation` not of type :class
|
|
4855
|
+
TypeError: If `interpolation` not of type :class:`~.vision.Inter` .
|
|
4734
4856
|
TypeError: If `fill_value` is not of type int or tuple[int, int, int].
|
|
4735
4857
|
ValueError: If `fill_value` is not in range of [0, 255].
|
|
4736
4858
|
RuntimeError: If shape of the input image is not <H, W, C>.
|
|
@@ -4752,7 +4874,7 @@ class TrivialAugmentWide(ImageTensorOperation):
|
|
|
4752
4874
|
|
|
4753
4875
|
Tutorial Examples:
|
|
4754
4876
|
- `Illustration of vision transforms
|
|
4755
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
4877
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
4756
4878
|
"""
|
|
4757
4879
|
|
|
4758
4880
|
@check_trivial_augment_wide
|
|
@@ -4811,7 +4933,7 @@ class UniformAugment(CompoundOperation):
|
|
|
4811
4933
|
|
|
4812
4934
|
Tutorial Examples:
|
|
4813
4935
|
- `Illustration of vision transforms
|
|
4814
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
4936
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
4815
4937
|
"""
|
|
4816
4938
|
|
|
4817
4939
|
@check_uniform_augment
|
|
@@ -4858,7 +4980,7 @@ class VerticalFlip(ImageTensorOperation):
|
|
|
4858
4980
|
|
|
4859
4981
|
Tutorial Examples:
|
|
4860
4982
|
- `Illustration of vision transforms
|
|
4861
|
-
<https://www.mindspore.cn/docs/en/r2.
|
|
4983
|
+
<https://www.mindspore.cn/docs/en/r2.2/api_python/samples/dataset/vision_gallery.html>`_
|
|
4862
4984
|
"""
|
|
4863
4985
|
|
|
4864
4986
|
def __init__(self):
|