* Extensibility guide with FE extensions and remove OV_FRAMEWORK_MAP from docs * Rework of Extensibility Intro, adopted examples to missing OPENVINO_FRAMEWORK_MAP * Removed OPENVINO_FRAMEWORK_MAP reference * Frontend extension detailed documentation * Fixed distributed snippets * Fixed snippet inclusion in FE extension document and chapter headers * Fixed wrong name in a snippet reference * Fixed test for template extension due to changed number of loaded extensions * Update docs/Extensibility_UG/frontend_extensions.md Co-authored-by: Ivan Tikhonov <ivan.tikhonov@intel.com> * Minor fixes in extension snippets * Small grammar fix Co-authored-by: Ivan Tikhonov <ivan.tikhonov@intel.com> Co-authored-by: Ivan Tikhonov <ivan.tikhonov@intel.com> * DOCS: transition banner (#10973) * transition banner * minor fix * update transition banner * updates * update custom.js * updates * updates * Documentation fixes (#11044) * Benchmark app usage * Fixed link to the devices * More fixes * Update docs/OV_Runtime_UG/multi_device.md Co-authored-by: Sergey Lyubimtsev <sergey.lyubimtsev@intel.com> * Removed several hardcoded links Co-authored-by: Sergey Lyubimtsev <sergey.lyubimtsev@intel.com> * Updated documentation for compile_tool (#11049) * Added deployment guide (#11060) * Added deployment guide * Added local distribution * Updates * Fixed more indentations * Removed obsolete code snippets (#11061) * Removed obsolete code snippets * NCC style * Fixed NCC for BA * Add a troubleshooting issue for PRC installation (#11074) * updates * adding gna to linux * add missing reference * update * Update docs/install_guides/installing-model-dev-tools.md Co-authored-by: Sergey Lyubimtsev <sergey.lyubimtsev@intel.com> * Update docs/install_guides/installing-model-dev-tools.md Co-authored-by: Sergey Lyubimtsev <sergey.lyubimtsev@intel.com> * Update docs/install_guides/installing-model-dev-tools.md Co-authored-by: Sergey Lyubimtsev <sergey.lyubimtsev@intel.com> * Update docs/install_guides/installing-model-dev-tools.md Co-authored-by: Sergey Lyubimtsev <sergey.lyubimtsev@intel.com> * Update docs/install_guides/installing-model-dev-tools.md Co-authored-by: Sergey Lyubimtsev <sergey.lyubimtsev@intel.com> * update * minor updates * add gna item to yum and apt * add gna to get started page * update reference formatting * merge commit * add a troubleshooting issue * update * update * fix CVS-71846 Co-authored-by: Sergey Lyubimtsev <sergey.lyubimtsev@intel.com> * DOCS: fixed hardcoded links (#11100) * Fixes * Use links * applying reviewers comments to the Opt Guide (#11093) * applying reviewrs comments * fixed refs, more structuring (bold, bullets, etc) * refactoring tput/latency sections * next iteration (mostly latency), also brushed the auto-batching and other sections * updates sync/async images * common opts brushed * WIP tput redesigned * minor brushing of common and auto-batching * Tput fully refactored * fixed doc name in the link * moved int8 perf counters to the right section * fixed links * fixed broken quotes * fixed more links * add ref to the internals to the TOC * Added a note on the batch size Co-authored-by: Andrey Zaytsev <andrey.zaytsev@intel.com> * [80085] New images for docs (#11114) * change doc structure * fix manager tools * fix manager tools 3 step * fix manager tools 3 step * new img * new img for OV Runtime * fix steps * steps * fix intendents * change list * fix space * fix space * code snippets fix * change display * Benchmarks 2022 1 (#11130) * Minor fixes * Updates for 2022.1 * Edits according to the review * Edits according to review comments * Edits according to review comments * Edits according to review comments * Fixed table * Edits according to review comments * Removed config for Intel® Core™ i7-11850HE * Removed forward-tacotron-duration-prediction-241 graph * Added resnet-18-pytorch * Add info about Docker images in Deployment guide (#11136) * Renamed user guides (#11137) * fix screenshot (#11140) * More conservative recommendations on dynamic shapes usage in docs (#11161) * More conservative recommendations about using dynamic shapes * Duplicated statement from C++ part to Python part of reshape doc (no semantical changes) * Update ShapeInference.md (#11168) * Benchmarks 2022 1 updates (#11180) * Updated graphs * Quick fix for TODO in Dynamic Shapes article * Anchor link fixes * Fixed DM config (#11199) * DOCS: doxy sphinxtabs (#11027) * initial implementation of doxy sphinxtabs * fixes * fixes * fixes * fixes * fixes * WA for ignored visibility attribute * Fixes Co-authored-by: Sergey Lyalin <sergey.lyalin@intel.com> Co-authored-by: Ivan Tikhonov <ivan.tikhonov@intel.com> Co-authored-by: Nikolay Tyukaev <nikolay.tyukaev@intel.com> Co-authored-by: Sergey Lyubimtsev <sergey.lyubimtsev@intel.com> Co-authored-by: Yuan Xu <yuan1.xu@intel.com> Co-authored-by: Maxim Shevtsov <maxim.y.shevtsov@intel.com> Co-authored-by: Andrey Zaytsev <andrey.zaytsev@intel.com> Co-authored-by: Tatiana Savina <tatiana.savina@intel.com> Co-authored-by: Ilya Naumov <ilya.naumov@intel.com> Co-authored-by: Evgenya Stepyreva <evgenya.stepyreva@intel.com>
6.9 KiB
Convert model with Model Optimizer
@sphinxdirective
.. _deep learning model optimizer:
.. toctree:: :maxdepth: 1 :hidden:
openvino_docs_MO_DG_prepare_model_convert_model_Converting_Model openvino_docs_MO_DG_prepare_model_convert_model_Cutting_Model openvino_docs_MO_DG_Additional_Optimization_Use_Cases openvino_docs_MO_DG_FP16_Compression openvino_docs_MO_DG_prepare_model_convert_model_Convert_Model_From_TensorFlow openvino_docs_MO_DG_prepare_model_convert_model_Convert_Model_From_ONNX openvino_docs_MO_DG_prepare_model_convert_model_Convert_Model_From_PyTorch openvino_docs_MO_DG_prepare_model_convert_model_Convert_Model_From_Paddle openvino_docs_MO_DG_prepare_model_convert_model_Convert_Model_From_MxNet openvino_docs_MO_DG_prepare_model_convert_model_Convert_Model_From_Caffe openvino_docs_MO_DG_prepare_model_convert_model_Convert_Model_From_Kaldi openvino_docs_MO_DG_prepare_model_convert_model_tutorials openvino_docs_MO_DG_prepare_model_Model_Optimizer_FAQ
@endsphinxdirective
Introduction
Model Optimizer is a cross-platform command-line tool that facilitates the transition between training and deployment environments, performs static model analysis, and adjusts deep learning models for optimal execution on end-point target devices.
Using Model Optimizer tool assumes you already have a deep learning model trained using one of the supported frameworks: TensorFlow, PyTorch, PaddlePaddle, MXNet, Caffe, Kaldi, or represented in ONNX* format. Model Optimizer produces an Intermediate Representation (IR) of the model, which can be inferred with OpenVINO™ Runtime.
Note
: Model Optimizer does not infer models. Model Optimizer is an offline tool that converts a model into IR and optimizes before the inference takes place.
The scheme below illustrates the typical workflow for deploying a trained deep learning model:
The IR is a pair of files describing the model:
-
.xml- Describes the network topology -
.bin- Contains the weights and biases binary data.
Note
: The generated IR can be additionally optimized for inference by Post-training Optimization tool that applies post-training quantization methods.
Tip
: You also can work with the Model Optimizer inside the OpenVINO™ Deep Learning Workbench (DL Workbench). DL Workbench is a web-based graphical environment that enables you to optimize, fine-tune, analyze, visualize, and compare performance of deep learning models.
Run Model Optimizer
To convert the model to IR, run Model Optimizer:
mo --input_model INPUT_MODEL
If out-of-the-box conversion (only the --input_model parameter is specified) is not succeed,
try to use parameters for overriding input shapes and cutting the model, mentioned below.
To override original input shapes for model conversion, Model Optimizer provides two parameters: --input and --input_shape.
For more information about these parameters, refer to Setting Input Shapes.
To cut off unwanted parts of a model, such as unsupported operations and training sub-graphs,
the --input and --output parameters can be used, defining new inputs and outputs of the converted model.
For a more detailed description, refer to Cutting Off Parts of a Model.
Also, you can insert additional input pre-processing sub-graphs into the converted model using
the --mean_values, scales_values, --layout, and other parameters described
in Embedding Preprocessing Computation.
Model Optimizer's compression parameter --data_type allows to generate IR of the FP16 data type. For more details,
please refer to Compression of a Model to FP16.
To get the full list of conversion parameters available in Model Optimizer, run the following command:
mo --help
Examples of CLI Commands
Below is a list of separate examples for different frameworks and Model Optimizer parameters.
- Launch Model Optimizer for a TensorFlow MobileNet model in the binary protobuf format.
mo --input_model MobileNet.pb
Launch Model Optimizer for a TensorFlow BERT model in the SavedModel format, with three inputs. Explicitly specify input shapes where the batch size and the sequence length equal 2 and 30 respectively.
mo --saved_model_dir BERT --input mask,word_ids,type_ids --input_shape [2,30],[2,30],[2,30]
For more information on TensorFlow model conversion, refer to Converting a TensorFlow Model.
- Launch Model Optimizer for an ONNX OCR model and explicitly specify new output.
mo --input_model ocr.onnx --output probabilities
For more information on ONNX model conversion, please refer to Converting an ONNX Model. Note that PyTorch models must be exported to the ONNX format before its conversion into IR. More details can be found in Converting a PyTorch Model.
- Launch Model Optimizer for a PaddlePaddle UNet model and apply mean-scale normalization to the input.
mo --input_model unet.pdmodel --mean_values [123,117,104] --scale 255
For more information on PaddlePaddle model conversion, please refer to Converting a PaddlePaddle Model.
- Launch Model Optimizer for an MXNet SSD Inception V3 model and specify first-channel layout for the input.
mo --input_model ssd_inception_v3-0000.params --layout NCHW
For more information on MXNet models conversion, please refer to Converting an MXNet Model.
- Launch Model Optimizer for a Caffe AlexNet model with input channels in the RGB format, which needs to be reversed.
mo --input_model alexnet.caffemodel --reverse_input_channels
For more information on Caffe model conversion, please refer to Converting a Caffe Model.
- Launch Model Optimizer for a Kaldi LibriSpeech nnet2 model.
mo --input_model librispeech_nnet2.mdl --input_shape [1,140]
For more information on Kaldi model conversion, refer to Converting a Kaldi Model.
To get conversion recipes for specific TensorFlow, ONNX, PyTorch, MXNet, and Kaldi models, refer to Model Conversion Tutorials.