From 672565a8ed7833833dd2a335682f80213fc01fb3 Mon Sep 17 00:00:00 2001 From: Svetlana Dolinina Date: Wed, 8 Dec 2021 17:38:46 +0300 Subject: [PATCH] deprecate mean_file option in Caffe (#8707) * deprecate mean_file option * add deprecation warning even if error happens * removed Suppress for now deprecated options * review fixes * added dot --- .../convert_model/Convert_Model_From_Caffe.md | 4 ++-- .../convert_model/Convert_Model_From_Paddle.md | 2 +- .../convert_model/Converting_Model.md | 2 +- .../convert_model/Converting_Model_General.md | 2 +- tools/mo/openvino/tools/mo/utils/cli_parser.py | 14 +++++++++----- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/docs/MO_DG/prepare_model/convert_model/Convert_Model_From_Caffe.md b/docs/MO_DG/prepare_model/convert_model/Convert_Model_From_Caffe.md index d72addcf4d3..7e7cbb38305 100644 --- a/docs/MO_DG/prepare_model/convert_model/Convert_Model_From_Caffe.md +++ b/docs/MO_DG/prepare_model/convert_model/Convert_Model_From_Caffe.md @@ -63,10 +63,10 @@ Caffe*-specific parameters: -k K Path to CustomLayersMapping.xml to register custom layers --mean_file MEAN_FILE, -mf MEAN_FILE - Mean image to be used for the input. Should be a + [DEPRECATED] Mean image to be used for the input. Should be a binaryproto file --mean_file_offsets MEAN_FILE_OFFSETS, -mo MEAN_FILE_OFFSETS - Mean image offsets to be used for the input + [DEPRECATED] Mean image offsets to be used for the input binaryproto file. When the mean image is bigger than the expected input, it is cropped. By default, centers of the input image and the mean image are the same and diff --git a/docs/MO_DG/prepare_model/convert_model/Convert_Model_From_Paddle.md b/docs/MO_DG/prepare_model/convert_model/Convert_Model_From_Paddle.md index 09c58d646ca..4b44d418a05 100644 --- a/docs/MO_DG/prepare_model/convert_model/Convert_Model_From_Paddle.md +++ b/docs/MO_DG/prepare_model/convert_model/Convert_Model_From_Paddle.md @@ -42,7 +42,7 @@ To convert a Paddle\* model: Parameters to convert your model: * [Framework-agnostic parameters](Converting_Model_General.md): These parameters are used to convert a model trained with any supported framework. -> **NOTE:** `--scale`, `--scale_values`, `--mean_values`, `--mean_file` are not supported in the current version of mo_paddle. +> **NOTE:** `--scale`, `--scale_values`, `--mean_values` are not supported in the current version of mo_paddle. ### Example of Converting a Paddle* Model Below is the example command to convert yolo v3 Paddle\* network to OpenVINO IR network with Model Optimizer. diff --git a/docs/MO_DG/prepare_model/convert_model/Converting_Model.md b/docs/MO_DG/prepare_model/convert_model/Converting_Model.md index 2859033c3ca..a66cba7a8fd 100644 --- a/docs/MO_DG/prepare_model/convert_model/Converting_Model.md +++ b/docs/MO_DG/prepare_model/convert_model/Converting_Model.md @@ -6,7 +6,7 @@ mo --input_model INPUT_MODEL --output_dir ``` You need to have have write permissions for an output directory. -> **NOTE**: Some models require using additional arguments to specify conversion parameters, such as `--input_shape`, `--scale`, `--scale_values`, `--mean_values`, `--mean_file`. To learn about when you need to use these parameters, refer to [Converting a Model Using General Conversion Parameters](Converting_Model_General.md). +> **NOTE**: Some models require using additional arguments to specify conversion parameters, such as `--input_shape`, `--scale`, `--scale_values`, `--mean_values`. To learn about when you need to use these parameters, refer to [Converting a Model Using General Conversion Parameters](Converting_Model_General.md). To adjust the conversion process, you may use general parameters defined in the [Converting a Model Using General Conversion Parameters](Converting_Model_General.md) and Framework-specific parameters for: diff --git a/docs/MO_DG/prepare_model/convert_model/Converting_Model_General.md b/docs/MO_DG/prepare_model/convert_model/Converting_Model_General.md index 1572d0623b2..2e708e1eaa1 100644 --- a/docs/MO_DG/prepare_model/convert_model/Converting_Model_General.md +++ b/docs/MO_DG/prepare_model/convert_model/Converting_Model_General.md @@ -151,7 +151,7 @@ Usually neural network models are trained with the normalized input data. This m In the first case, the Model Optimizer generates the IR with required pre-processing layers and Inference Engine samples may be used to infer the model. -In the second case, information about mean/scale values should be provided to the Model Optimizer to embed it to the generated IR. Model Optimizer provides a number of command line parameters to specify them: `--scale`, `--scale_values`, `--mean_values`, `--mean_file`. +In the second case, information about mean/scale values should be provided to the Model Optimizer to embed it to the generated IR. Model Optimizer provides a number of command line parameters to specify them: `--scale`, `--scale_values`, `--mean_values`. If both mean and scale values are specified, the mean is subtracted first and then scale is applied. Input values are *divided* by the scale value(s). diff --git a/tools/mo/openvino/tools/mo/utils/cli_parser.py b/tools/mo/openvino/tools/mo/utils/cli_parser.py index 2bbb54b6f8f..7ad9a8b4edf 100644 --- a/tools/mo/openvino/tools/mo/utils/cli_parser.py +++ b/tools/mo/openvino/tools/mo/utils/cli_parser.py @@ -124,12 +124,14 @@ class CanonicalizePathCheckExistenceIfNeededAction(CanonicalizePathCheckExistenc class DeprecatedCanonicalizePathCheckExistenceAction(CanonicalizePathCheckExistenceAction): def __call__(self, parser, namespace, values, option_string=None): - super().__call__(parser, namespace, values, option_string) dep_msg = "Use of deprecated cli option {} detected. Option use in the following releases will be fatal. ".format( option_string) if 'tensorflow_use_custom_operations_config' in option_string: dep_msg += 'Please use --transformations_config cli option instead' + if 'mean_file' in option_string or 'mean_offset' in option_string: + dep_msg += 'Please use --mean_values cli option instead.' log.error(dep_msg, extra={'is_warning': True}) + super().__call__(parser, namespace, values, option_string) def readable_file(path: str): @@ -377,7 +379,7 @@ def get_common_cli_parser(parser: argparse.ArgumentParser = None): 'the Inference Engine API in runtime may fail for such an IR.', action='store_true', default=False) common_group.add_argument('--keep_shape_ops', - help='The option is ignored. Expected behavior is enabled by default.', + help=argparse.SUPPRESS, action=IgnoredAction, default=True) common_group.add_argument('--disable_weights_compression', help='Disable compression and store weights with original precision.', @@ -524,11 +526,13 @@ def get_caffe_cli_parser(parser: argparse.ArgumentParser = None): 'CustomLayersMapping.xml'), action=CanonicalizePathCheckExistenceAction) caffe_group.add_argument('--mean_file', '-mf', - help='Mean image to be used for the input. Should be a binaryproto file', + help='[DEPRECATED] ' + + 'Mean image to be used for the input. Should be a binaryproto file', default=None, - action=CanonicalizePathCheckExistenceAction) + action=DeprecatedCanonicalizePathCheckExistenceAction) caffe_group.add_argument('--mean_file_offsets', '-mo', - help='Mean image offsets to be used for the input binaryproto file. ' + + help='[DEPRECATED] ' + + 'Mean image offsets to be used for the input binaryproto file. ' + 'When the mean image is bigger than the expected input, it is cropped. By default, centers ' + 'of the input image and the mean image are the same and the mean image is cropped by ' + 'dimensions of the input image. The format to pass this option is the following: "-mo (x,y)". In this ' +