[MO] Align MO namespaces (#7708)
* Moved and merged mo/ and extensions/ into openvino/tools/mo
* edited imports
* edited docs to use mo script from entry_point
* edited MO transformations list loading and setup.py
* changed full path -> 'mo' entry point in docs (leftovers)
* corrected package_BOM
* updated resolving --transformation_config in cli_parser.py
* pkgutil-style __init__.py, added summarize_graph into entry points
* updated DOCs for the new --transformations_config
* fix select
* updated install instructions, fixed setup.py for windows and python_version < 3.8
* fixed typo in requirements.txt
* resolved conflicts
* removed creating custom __init__.py from setup.py
* corrected folder with caffe proto
* corrected loading user defined extensions
* fix openvino.tools.mo import in serialize.py
* corrected layer tests for new namespace
* fix in get_testdata.py
* moved model-optimizer into tools/
* renamed import in POT
* corrected mo.yml
* correct CMakeLists.txt for the newest tools/mo
* corrected find_ie_version.py
* docs and openvino-dev setup.py update for the newest tools/mo
* miscellaneous leftovers and fixes
* corrected CI files, pybind11_add_module in CMakeLists.txt and use of tools/mo path instead of tools/model_optimizer
* add_subdirectory pybind11 for tools/mo
* POT path fix
* updated setupvars.sh setupvars.bat
* Revert "updated setupvars.sh setupvars.bat"
This reverts commit c011142340.
* removed model-optimizer env variables from setupvars
* updated CMakeLists.txt to pack MO properly with tests component
* corrected left imports, corrected loading requirements for layer tests
* mo doc typo correction
* minor corrections in docs; removed summarize_graph from entry_points
* get_started_windows.md, MonoDepth_how_to.md corrections, mo path corrections
This commit is contained in:
parent
d502208f6e
commit
980904c9ec
|
|
@ -121,8 +121,8 @@ jobs:
|
|||
# For running ONNX frontend unit tests
|
||||
python3 -m pip install -r $(REPO_DIR)/src/core/tests/requirements_test_onnx.txt
|
||||
# For MO unit tests
|
||||
python3 -m pip install -r $(REPO_DIR)/model-optimizer/requirements.txt
|
||||
python3 -m pip install -r $(REPO_DIR)/model-optimizer/requirements_dev.txt
|
||||
python3 -m pip install -r $(REPO_DIR)/tools/mo/requirements.txt
|
||||
python3 -m pip install -r $(REPO_DIR)/tools/mo/requirements_dev.txt
|
||||
# Speed up build
|
||||
wget https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-linux.zip
|
||||
unzip ninja-linux.zip
|
||||
|
|
|
|||
|
|
@ -90,8 +90,8 @@ jobs:
|
|||
# For running ONNX frontend unit tests
|
||||
python3 -m pip install -r $(REPO_DIR)/src/core/tests/requirements_test_onnx.txt
|
||||
# For MO unit tests
|
||||
python3 -m pip install -r $(REPO_DIR)/model-optimizer/requirements.txt
|
||||
python3 -m pip install -r $(REPO_DIR)/model-optimizer/requirements_dev.txt
|
||||
python3 -m pip install -r $(REPO_DIR)/tools/mo/requirements.txt
|
||||
python3 -m pip install -r $(REPO_DIR)/tools/mo/requirements_dev.txt
|
||||
# Speed up build
|
||||
wget https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-linux.zip
|
||||
unzip ninja-linux.zip
|
||||
|
|
|
|||
|
|
@ -114,8 +114,8 @@ jobs:
|
|||
rem For running ONNX frontend unit tests
|
||||
python -m pip install -r $(REPO_DIR)\src\core\tests\requirements_test_onnx.txt
|
||||
rem For MO unit tests
|
||||
python -m pip install -r $(REPO_DIR)\model-optimizer\requirements.txt
|
||||
python -m pip install -r $(REPO_DIR)\model-optimizer\requirements_dev.txt
|
||||
python -m pip install -r $(REPO_DIR)\tools\mo\requirements.txt
|
||||
python -m pip install -r $(REPO_DIR)\tools\mo\requirements_dev.txt
|
||||
rem Speed up build
|
||||
certutil -urlcache -split -f https://github.com/Kitware/CMake/releases/download/v$(CMAKE_VERSION)/cmake-$(CMAKE_VERSION)-windows-x86_64.zip cmake-$(CMAKE_VERSION)-windows-x86_64.zip
|
||||
powershell -command "Expand-Archive -Force cmake-$(CMAKE_VERSION)-windows-x86_64.zip"
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@ name: MO
|
|||
on:
|
||||
push:
|
||||
paths:
|
||||
- 'model-optimizer/**'
|
||||
- 'openvino/tools/mo/**'
|
||||
pull_request:
|
||||
paths:
|
||||
- 'model-optimizer/**'
|
||||
- 'openvino/tools/mo/**'
|
||||
|
||||
jobs:
|
||||
Pylint-UT:
|
||||
|
|
@ -24,7 +24,7 @@ jobs:
|
|||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ~/.cache/pip
|
||||
key: ${{ runner.os }}-pip-${{ hashFiles('model-optimizer/requirements*.txt') }}
|
||||
key: ${{ runner.os }}-pip-${{ hashFiles('openvino/tools/mo/requirements*.txt') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pip-
|
||||
${{ runner.os }}-
|
||||
|
|
@ -43,11 +43,11 @@ jobs:
|
|||
# requrements for CMake
|
||||
sudo apt update
|
||||
sudo apt --assume-yes install libusb-1.0-0-dev
|
||||
working-directory: model-optimizer
|
||||
working-directory: openvino/tools/mo
|
||||
|
||||
- name: Pylint
|
||||
run: pylint -d C,R,W mo/ mo.py extensions/
|
||||
working-directory: model-optimizer
|
||||
run: pylint -d C,R,W openvino/tools/mo/ openvino/tools/mo/mo.py
|
||||
working-directory: openvino/tools/mo
|
||||
|
||||
- name: CMake
|
||||
run: |
|
||||
|
|
@ -62,5 +62,4 @@ jobs:
|
|||
env
|
||||
mkdir ../mo-ut-logs
|
||||
python3 -m xmlrunner discover -p *_test.py --output=../mo-ut-logs
|
||||
working-directory: model-optimizer
|
||||
|
||||
working-directory: openvino/tools/mo
|
||||
|
|
|
|||
|
|
@ -48,14 +48,14 @@ __pycache__
|
|||
*pylint_report_comments.txt
|
||||
|
||||
# Artifacts
|
||||
/model-optimizer/*.bin
|
||||
/model-optimizer/*.xml
|
||||
/model-optimizer/*.json
|
||||
/model-optimizer/*.so
|
||||
/model-optimizer/*.txt
|
||||
/model-optimizer/*.pb
|
||||
/model-optimizer/*.pbtxt
|
||||
/model-optimizer/!CMakeLists.txt
|
||||
/model-optimizer/*.mapping
|
||||
/model-optimizer/*.dat
|
||||
/model-optimizer/*.svg
|
||||
/tools/mo/*.bin
|
||||
/tools/mo/*.xml
|
||||
/tools/mo/*.json
|
||||
/tools/mo/*.so
|
||||
/tools/mo/*.txt
|
||||
/tools/mo/*.pb
|
||||
/tools/mo/*.pbtxt
|
||||
/tools/mo/!CMakeLists.txt
|
||||
/tools/mo/*.mapping
|
||||
/tools/mo/*.dat
|
||||
/tools/mo/*.svg
|
||||
|
|
|
|||
|
|
@ -96,7 +96,6 @@ add_subdirectory(src)
|
|||
add_subdirectory(samples)
|
||||
add_subdirectory(inference-engine)
|
||||
include(cmake/extra_modules.cmake)
|
||||
add_subdirectory(model-optimizer)
|
||||
add_subdirectory(docs)
|
||||
add_subdirectory(tools)
|
||||
add_subdirectory(scripts)
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ azure-pipelines.yml @openvinotoolkit/openvino-admins
|
|||
/inference-engine/tests/functional/inference_engine/transformations/ @openvinotoolkit/openvino-ie-tests-maintainers @openvinotoolkit/openvino-ngraph-maintainers
|
||||
|
||||
# MO:
|
||||
/model-optimizer/ @openvinotoolkit/openvino-mo-maintainers
|
||||
/tools/mo/ @openvinotoolkit/openvino-mo-maintainers
|
||||
|
||||
# nGraph:
|
||||
/src/core/ @openvinotoolkit/openvino-ngraph-maintainers
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ and [Convert Your TensorFlow* Model](../MO_DG/prepare_model/convert_model/Conver
|
|||
for more details and command line parameters used for the model conversion.
|
||||
|
||||
```bash
|
||||
./<MO_INSTALL_DIR>/mo.py --input_model <PATH_TO_MODEL>/wnet_20.pb -b 1
|
||||
mo --input_model <PATH_TO_MODEL>/wnet_20.pb -b 1
|
||||
```
|
||||
> **NOTE:** This conversion guide is applicable for the 2021.3 release of OpenVINO and that starting from 2021.4
|
||||
> the OpenVINO supports this model out of the box.
|
||||
|
|
@ -258,7 +258,7 @@ The implementation should be saved to the file `mo_extensions/front/tf/ComplexAb
|
|||
|
||||
Now it is possible to convert the model using the following command line:
|
||||
```bash
|
||||
./<MO_INSTALL_DIR>/mo.py --input_model <PATH_TO_MODEL>/wnet_20.pb -b 1 --extensions mo_extensions/
|
||||
mo --input_model <PATH_TO_MODEL>/wnet_20.pb -b 1 --extensions mo_extensions/
|
||||
```
|
||||
|
||||
The sub-graph corresponding to the originally non-supported one is depicted in the image below:
|
||||
|
|
@ -322,7 +322,7 @@ The result of this command is a compiled shared library (`.so` or `.dll`). It sh
|
|||
application using `Core` class instance method `AddExtension` like this
|
||||
`core.AddExtension(std::make_shared<Extension>(compiled_library_file_name), "CPU");`.
|
||||
|
||||
To test that the extension is implemented correctly we can run the "mri_reconstruction_demo.py" with the following content:
|
||||
To test that the extension is implemented correctly we can run the "mri_reconstruction_demo" with the following content:
|
||||
|
||||
@snippet mri_reconstruction_demo.py mri_demo:demo
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ The IR is a pair of files describing the model:
|
|||
Below is a simple command running Model Optimizer to generate an IR for the input model:
|
||||
|
||||
```sh
|
||||
python3 mo.py --input_model INPUT_MODEL
|
||||
mo --input_model INPUT_MODEL
|
||||
```
|
||||
To learn about all Model Optimizer parameters and conversion technics, see the [Converting a Model to IR](prepare_model/convert_model/Converting_Model.md) page.
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ For example, to add the description of the `CustomReshape` layer, which is an ar
|
|||
|
||||
2. Generate a new parser:
|
||||
```shell
|
||||
cd <INSTALL_DIR>/tools/model_optimizer/mo/front/caffe/proto
|
||||
cd <SITE_PACKAGES_WITH_INSTALLED_OPENVINO>/openvino/tools/mo/front/caffe/proto
|
||||
python3 generate_caffe_pb2.py --input_proto <PATH_TO_CUSTOM_CAFFE>/src/caffe/proto/caffe.proto
|
||||
```
|
||||
where `PATH_TO_CUSTOM_CAFFE` is the path to the root directory of custom Caffe\*.
|
||||
|
|
@ -66,7 +66,7 @@ The mean file that you provide for the Model Optimizer must be in a `.binaryprot
|
|||
|
||||
#### 7. What does the message "Invalid proto file: there is neither 'layer' nor 'layers' top-level messages" mean? <a name="question-7"></a>
|
||||
|
||||
The structure of any Caffe\* topology is described in the `caffe.proto` file of any Caffe version. For example, in the Model Optimizer, you can find the following proto file, used by default: `<INSTALL_DIR>/tools/model_optimizer/mo/front/caffe/proto/my_caffe.proto`. There you can find the structure:
|
||||
The structure of any Caffe\* topology is described in the `caffe.proto` file of any Caffe version. For example, in the Model Optimizer, you can find the following proto file, used by default: `mo/front/caffe/proto/my_caffe.proto`. There you can find the structure:
|
||||
```
|
||||
message NetParameter {
|
||||
// ... some other parameters
|
||||
|
|
@ -81,7 +81,7 @@ This means that any topology should contain layers as top-level structures in `p
|
|||
|
||||
#### 8. What does the message "Old-style inputs (via 'input_dims') are not supported. Please specify inputs via 'input_shape'" mean? <a name="question-8"></a>
|
||||
|
||||
The structure of any Caffe\* topology is described in the `caffe.proto` file for any Caffe version. For example, in the Model Optimizer you can find the following `.proto` file, used by default: `<INSTALL_DIR>/tools/model_optimizer/mo/front/caffe/proto/my_caffe.proto`. There you can find the structure:
|
||||
The structure of any Caffe\* topology is described in the `caffe.proto` file for any Caffe version. For example, in the Model Optimizer you can find the following `.proto` file, used by default: `mo/front/caffe/proto/my_caffe.proto`. There you can find the structure:
|
||||
```sh
|
||||
message NetParameter {
|
||||
|
||||
|
|
@ -350,15 +350,15 @@ The specified input shape cannot be parsed. Please, define it in one of the foll
|
|||
|
||||
*
|
||||
```shell
|
||||
python3 mo.py --input_model <INPUT_MODEL>.caffemodel --input_shape (1,3,227,227)
|
||||
mo --input_model <INPUT_MODEL>.caffemodel --input_shape (1,3,227,227)
|
||||
```
|
||||
*
|
||||
```shell
|
||||
python3 mo.py --input_model <INPUT_MODEL>.caffemodel --input_shape [1,3,227,227]
|
||||
mo --input_model <INPUT_MODEL>.caffemodel --input_shape [1,3,227,227]
|
||||
```
|
||||
* In case of multi input topology you should also specify inputs:
|
||||
```shell
|
||||
python3 mo.py --input_model /path-to/your-model.caffemodel --input data,rois --input_shape (1,3,227,227),(1,6,1,1)
|
||||
mo --input_model /path-to/your-model.caffemodel --input data,rois --input_shape (1,3,227,227),(1,6,1,1)
|
||||
```
|
||||
|
||||
Keep in mind that there is no space between and inside the brackets for input shapes.
|
||||
|
|
|
|||
|
|
@ -39,9 +39,9 @@ A summary of the steps for optimizing and deploying a model that was trained wit
|
|||
To convert a Caffe\* model:
|
||||
|
||||
1. Go to the `$INTEL_OPENVINO_DIR/tools/model_optimizer` directory.
|
||||
2. Use the `mo.py` script to simply convert a model, specifying the path to the input model `.caffemodel` file and the path to an output directory with write permissions:
|
||||
2. Use the `mo` script to simply convert a model, specifying the path to the input model `.caffemodel` file and the path to an output directory with write permissions:
|
||||
```sh
|
||||
python3 mo.py --input_model <INPUT_MODEL>.caffemodel --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model <INPUT_MODEL>.caffemodel --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
|
||||
Two groups of parameters are available to convert your model:
|
||||
|
|
@ -94,13 +94,13 @@ Caffe*-specific parameters:
|
|||
* Launching the Model Optimizer for the [bvlc_alexnet.caffemodel](https://github.com/BVLC/caffe/tree/master/models/bvlc_alexnet) with a specified `prototxt` file. This is needed when the name of the Caffe\* model and the `.prototxt` file are different or are placed in different directories. Otherwise, it is enough to provide only the path to the input `model.caffemodel` file. You must have write permissions for the output directory.
|
||||
|
||||
```sh
|
||||
python3 mo.py --input_model bvlc_alexnet.caffemodel --input_proto bvlc_alexnet.prototxt --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model bvlc_alexnet.caffemodel --input_proto bvlc_alexnet.prototxt --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
|
||||
* Launching the Model Optimizer for the [bvlc_alexnet.caffemodel](https://github.com/BVLC/caffe/tree/master/models/bvlc_alexnet) with a specified `CustomLayersMapping` file. This is the legacy method of quickly enabling model conversion if your model has custom layers. This requires the Caffe\* system on the computer. To read more about this, see [Legacy Mode for Caffe* Custom Layers](../customize_model_optimizer/Legacy_Mode_for_Caffe_Custom_Layers.md).
|
||||
Optional parameters without default values and not specified by the user in the `.prototxt` file are removed from the Intermediate Representation, and nested parameters are flattened:
|
||||
```sh
|
||||
python3 mo.py --input_model bvlc_alexnet.caffemodel -k CustomLayersMapping.xml --disable_omitting_optional --enable_flattening_nested_params --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model bvlc_alexnet.caffemodel -k CustomLayersMapping.xml --disable_omitting_optional --enable_flattening_nested_params --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
This example shows a multi-input model with input layers: `data`, `rois`
|
||||
```
|
||||
|
|
@ -124,7 +124,7 @@ layer {
|
|||
|
||||
* Launching the Model Optimizer for a multi-input model with two inputs and providing a new shape for each input in the order they are passed to the Model Optimizer along with a writable output directory. In particular, for data, set the shape to `1,3,227,227`. For rois, set the shape to `1,6,1,1`:
|
||||
```sh
|
||||
python3 mo.py --input_model /path-to/your-model.caffemodel --input data,rois --input_shape (1,3,227,227),[1,6,1,1] --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model /path-to/your-model.caffemodel --input data,rois --input_shape (1,3,227,227),[1,6,1,1] --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
|
||||
## Custom Layer Definition
|
||||
|
|
|
|||
|
|
@ -34,9 +34,9 @@ A summary of the steps for optimizing and deploying a model that was trained wit
|
|||
To convert a Kaldi\* model:
|
||||
|
||||
1. Go to the `<INSTALL_DIR>/tools/model_optimizer` directory.
|
||||
2. Use the `mo.py` script to simply convert a model with the path to the input model `.nnet` or `.mdl` file and to an output directory where you have write permissions:
|
||||
2. Use the `mo` script to simply convert a model with the path to the input model `.nnet` or `.mdl` file and to an output directory where you have write permissions:
|
||||
```sh
|
||||
python3 mo.py --input_model <INPUT_MODEL>.nnet --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model <INPUT_MODEL>.nnet --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
|
||||
Two groups of parameters are available to convert your model:
|
||||
|
|
@ -60,12 +60,12 @@ Kaldi-specific parameters:
|
|||
|
||||
* To launch the Model Optimizer for the wsj_dnn5b_smbr model with the specified `.nnet` file and an output directory where you have write permissions:
|
||||
```sh
|
||||
python3 mo.py --input_model wsj_dnn5b_smbr.nnet --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model wsj_dnn5b_smbr.nnet --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
|
||||
* To launch the Model Optimizer for the wsj_dnn5b_smbr model with existing file that contains counts for the last layer with biases and a writable output directory:
|
||||
```sh
|
||||
python3 mo.py --input_model wsj_dnn5b_smbr.nnet --counts wsj_dnn5b_smbr.counts --output_dir <OUTPUT_MODEL_DIR>_
|
||||
mo --input_model wsj_dnn5b_smbr.nnet --counts wsj_dnn5b_smbr.counts --output_dir <OUTPUT_MODEL_DIR>_
|
||||
```
|
||||
* The Model Optimizer normalizes сounts in the following way:
|
||||
\f[
|
||||
|
|
@ -83,7 +83,7 @@ python3 mo.py --input_model wsj_dnn5b_smbr.nnet --counts wsj_dnn5b_smbr.counts -
|
|||
* If you want to remove the last SoftMax layer in the topology, launch the Model Optimizer with the
|
||||
`--remove_output_softmax` flag.
|
||||
```sh
|
||||
python3 mo.py --input_model wsj_dnn5b_smbr.nnet --counts wsj_dnn5b_smbr.counts --remove_output_softmax --output_dir <OUTPUT_MODEL_DIR>_
|
||||
mo --input_model wsj_dnn5b_smbr.nnet --counts wsj_dnn5b_smbr.counts --remove_output_softmax --output_dir <OUTPUT_MODEL_DIR>_
|
||||
```
|
||||
The Model Optimizer finds the last layer of the topology and removes this layer only if it is a SoftMax layer.
|
||||
|
||||
|
|
|
|||
|
|
@ -44,9 +44,9 @@ A summary of the steps for optimizing and deploying a model that was trained wit
|
|||
To convert an MXNet\* model:
|
||||
|
||||
1. Go to the `<INSTALL_DIR>/tools/model_optimizer` directory.
|
||||
2. To convert an MXNet\* model contained in a `model-file-symbol.json` and `model-file-0000.params`, run the Model Optimizer launch script `mo.py`, specifying a path to the input model file and a path to an output directory with write permissions:
|
||||
2. To convert an MXNet\* model contained in a `model-file-symbol.json` and `model-file-0000.params`, run the Model Optimizer launch script `mo`, specifying a path to the input model file and a path to an output directory with write permissions:
|
||||
```sh
|
||||
python3 mo_mxnet.py --input_model model-file-0000.params --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model model-file-0000.params --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
|
||||
Two groups of parameters are available to convert your model:
|
||||
|
|
|
|||
|
|
@ -60,9 +60,9 @@ The Model Optimizer process assumes you have an ONNX model that was directly dow
|
|||
To convert an ONNX\* model:
|
||||
|
||||
1. Go to the `<INSTALL_DIR>/tools/model_optimizer` directory.
|
||||
2. Use the `mo.py` script to simply convert a model with the path to the input model `.nnet` file and an output directory where you have write permissions:
|
||||
2. Use the `mo` script to simply convert a model with the path to the input model `.nnet` file and an output directory where you have write permissions:
|
||||
```sh
|
||||
python3 mo.py --input_model <INPUT_MODEL>.onnx --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model <INPUT_MODEL>.onnx --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
|
||||
There are no ONNX\* specific parameters, so only [framework-agnostic parameters](Converting_Model_General.md) are available to convert your model.
|
||||
|
|
|
|||
|
|
@ -33,10 +33,10 @@ A summary of the steps for optimizing and deploying a model trained with Paddle\
|
|||
|
||||
To convert a Paddle\* model:
|
||||
|
||||
1. Go to the `$INTEL_OPENVINO_DIR/tools/model_optimizer` directory.
|
||||
2. Use the `mo.py` script to simply convert a model, specifying the framework, the path to the input model `.pdmodel` file and the path to an output directory with write permissions:
|
||||
1. Activate environment with installed OpenVINO if needed
|
||||
2. Use the `mo` script to simply convert a model, specifying the framework, the path to the input model `.pdmodel` file and the path to an output directory with write permissions:
|
||||
```sh
|
||||
python3 mo.py --input_model <INPUT_MODEL>.pdmodel --output_dir <OUTPUT_MODEL_DIR> --framework=paddle
|
||||
mo --input_model <INPUT_MODEL>.pdmodel --output_dir <OUTPUT_MODEL_DIR> --framework=paddle
|
||||
```
|
||||
|
||||
Parameters to convert your model:
|
||||
|
|
@ -47,7 +47,7 @@ Parameters to convert your model:
|
|||
### Example of Converting a Paddle* Model
|
||||
Below is the example command to convert yolo v3 Paddle\* network to OpenVINO IR network with Model Optimizer.
|
||||
```sh
|
||||
python3 mo.py --model_name yolov3_darknet53_270e_coco --output_dir <OUTPUT_MODEL_DIR> --framework=paddle --data_type=FP32 --reverse_input_channels --input_shape=[1,3,608,608],[1,2],[1,2] --input=image,im_shape,scale_factor --output=save_infer_model/scale_0.tmp_1,save_infer_model/scale_1.tmp_1 --input_model=yolov3.pdmodel
|
||||
mo --model_name yolov3_darknet53_270e_coco --output_dir <OUTPUT_MODEL_DIR> --framework=paddle --data_type=FP32 --reverse_input_channels --input_shape=[1,3,608,608],[1,2],[1,2] --input=image,im_shape,scale_factor --output=save_infer_model/scale_0.tmp_1,save_infer_model/scale_1.tmp_1 --input_model=yolov3.pdmodel
|
||||
```
|
||||
|
||||
## Supported Paddle\* Layers
|
||||
|
|
|
|||
|
|
@ -179,15 +179,15 @@ There are three ways to store non-frozen TensorFlow models and load them to the
|
|||
To convert such a TensorFlow model:
|
||||
|
||||
1. Go to the `<INSTALL_DIR>/tools/model_optimizer` directory
|
||||
2. Run the `mo_tf.py` script with the path to the checkpoint file to convert a model and an output directory where you have write permissions:
|
||||
2. Run the `mo` script with the path to the checkpoint file to convert a model and an output directory where you have write permissions:
|
||||
|
||||
* If input model is in `.pb` format:<br>
|
||||
```sh
|
||||
python3 mo_tf.py --input_model <INFERENCE_GRAPH>.pb --input_checkpoint <INPUT_CHECKPOINT> --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model <INFERENCE_GRAPH>.pb --input_checkpoint <INPUT_CHECKPOINT> --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
* If input model is in `.pbtxt` format:<br>
|
||||
```sh
|
||||
python3 mo_tf.py --input_model <INFERENCE_GRAPH>.pbtxt --input_checkpoint <INPUT_CHECKPOINT> --input_model_is_text --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model <INFERENCE_GRAPH>.pbtxt --input_checkpoint <INPUT_CHECKPOINT> --input_model_is_text --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
|
||||
2. MetaGraph:
|
||||
|
|
@ -201,9 +201,9 @@ python3 mo_tf.py --input_model <INFERENCE_GRAPH>.pbtxt --input_checkpoint <INPUT
|
|||
To convert such TensorFlow model:
|
||||
|
||||
1. Go to the `<INSTALL_DIR>/tools/model_optimizer` directory
|
||||
2. Run the `mo_tf.py` script with a path to the MetaGraph `.meta` file and a writable output directory to convert a model:<br>
|
||||
2. Run the `mo` script with a path to the MetaGraph `.meta` file and a writable output directory to convert a model:<br>
|
||||
```sh
|
||||
python3 mo_tf.py --input_meta_graph <INPUT_META_GRAPH>.meta --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_meta_graph <INPUT_META_GRAPH>.meta --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
|
||||
3. SavedModel format of TensorFlow 1.x and 2.x versions:
|
||||
|
|
@ -213,9 +213,9 @@ python3 mo_tf.py --input_meta_graph <INPUT_META_GRAPH>.meta --output_dir <OUTPUT
|
|||
To convert such TensorFlow model:
|
||||
|
||||
1. Go to the `<INSTALL_DIR>/tools/model_optimizer` directory
|
||||
2. Run the `mo_tf.py` script with a path to the SavedModel directory and a writable output directory to convert a model:<br>
|
||||
2. Run the `mo` script with a path to the SavedModel directory and a writable output directory to convert a model:<br>
|
||||
```sh
|
||||
python3 mo_tf.py --saved_model_dir <SAVED_MODEL_DIRECTORY> --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --saved_model_dir <SAVED_MODEL_DIRECTORY> --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
|
||||
You can convert TensorFlow 1.x SavedModel format in the environment that has a 1.x or 2.x version of TensorFlow. However, TensorFlow 2.x SavedModel format strictly requires the 2.x version of TensorFlow.
|
||||
|
|
@ -252,9 +252,9 @@ Where:
|
|||
To convert a TensorFlow model:
|
||||
|
||||
1. Go to the `<INSTALL_DIR>/tools/model_optimizer` directory
|
||||
2. Use the `mo_tf.py` script to simply convert a model with the path to the input model `.pb` file and a writable output directory:
|
||||
2. Use the `mo` script to simply convert a model with the path to the input model `.pb` file and a writable output directory:
|
||||
```sh
|
||||
python3 mo_tf.py --input_model <INPUT_MODEL>.pb --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model <INPUT_MODEL>.pb --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
|
||||
Two groups of parameters are available to convert your model:
|
||||
|
|
@ -310,27 +310,27 @@ TensorFlow*-specific parameters:
|
|||
|
||||
* Launching the Model Optimizer for Inception V1 frozen model when model file is a plain text protobuf, specifying a writable output directory:
|
||||
```sh
|
||||
python3 mo_tf.py --input_model inception_v1.pbtxt --input_model_is_text -b 1 --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model inception_v1.pbtxt --input_model_is_text -b 1 --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
|
||||
* Launching the Model Optimizer for Inception V1 frozen model and update custom sub-graph replacement file `transform.json` with information about input and output nodes of the matched sub-graph, specifying a writable output directory. For more information about this feature, refer to [Sub-Graph Replacement in the Model Optimizer](../customize_model_optimizer/Subgraph_Replacement_Model_Optimizer.md).
|
||||
```sh
|
||||
python3 mo_tf.py --input_model inception_v1.pb -b 1 --tensorflow_custom_operations_config_update transform.json --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model inception_v1.pb -b 1 --tensorflow_custom_operations_config_update transform.json --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
|
||||
* Launching the Model Optimizer for Inception V1 frozen model and use custom sub-graph replacement file `transform.json` for model conversion. For more information about this feature, refer to [Sub-Graph Replacement in the Model Optimizer](../customize_model_optimizer/Subgraph_Replacement_Model_Optimizer.md).
|
||||
```sh
|
||||
python3 mo_tf.py --input_model inception_v1.pb -b 1 --transformations_config transform.json --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model inception_v1.pb -b 1 --transformations_config transform.json --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
|
||||
* Launching the Model Optimizer for Inception V1 frozen model and dump information about the graph to TensorBoard log dir `/tmp/log_dir`
|
||||
```sh
|
||||
python3 mo_tf.py --input_model inception_v1.pb -b 1 --tensorboard_logdir /tmp/log_dir --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model inception_v1.pb -b 1 --tensorboard_logdir /tmp/log_dir --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
|
||||
* Launching the Model Optimizer for a model with custom TensorFlow operations (refer to the [TensorFlow* documentation](https://www.tensorflow.org/extend/adding_an_op)) implemented in C++ and compiled into the shared library `my_custom_op.so`. Model Optimizer falls back to TensorFlow to infer output shape of operations implemented in the library if a custom TensorFlow operation library is provided. If it is not provided, a custom operation with an inference function is needed. For more information about custom operations, refer to the [Extending the Model Optimizer with New Primitives](../customize_model_optimizer/Extending_Model_Optimizer_with_New_Primitives.md).
|
||||
```sh
|
||||
python3 mo_tf.py --input_model custom_model.pb --tensorflow_custom_layer_libraries ./my_custom_op.so --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model custom_model.pb --tensorflow_custom_layer_libraries ./my_custom_op.so --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
|
||||
|
||||
|
|
@ -345,9 +345,9 @@ Below are the instructions on how to convert each of them.
|
|||
A model in the SavedModel format consists of a directory with a `saved_model.pb` file and two subfolders: `variables` and `assets`.
|
||||
To convert such a model:
|
||||
1. Go to the `<INSTALL_DIR>/tools/model_optimizer` directory.
|
||||
2. Run the `mo_tf.py` script with a path to the SavedModel directory and a writable output directory:
|
||||
2. Run the `mo` script with a path to the SavedModel directory and a writable output directory:
|
||||
```sh
|
||||
python3 mo_tf.py --saved_model_dir <SAVED_MODEL_DIRECTORY> --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --saved_model_dir <SAVED_MODEL_DIRECTORY> --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
|
||||
TensorFlow* 2 SavedModel format strictly requires the 2.x version of TensorFlow installed in the
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
# Converting a Model to Intermediate Representation (IR) {#openvino_docs_MO_DG_prepare_model_convert_model_Converting_Model}
|
||||
|
||||
Use the <code>mo.py</code> script from the `<INSTALL_DIR>/tools/model_optimizer` directory to run the Model Optimizer and convert the model to the Intermediate Representation (IR):
|
||||
Use the <code>mo</code> script to run the Model Optimizer and convert the model to the Intermediate Representation (IR):
|
||||
```sh
|
||||
python3 mo.py --input_model INPUT_MODEL --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model INPUT_MODEL --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
You need to have have write permissions for an output directory.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
# Converting a Model Using General Conversion Parameters {#openvino_docs_MO_DG_prepare_model_convert_model_Converting_Model_General}
|
||||
|
||||
To simply convert a model trained by any supported framework, run the Model Optimizer launch script ``mo.py`` specifying a path to the input model file and an output directory where you have write permissions:
|
||||
To simply convert a model trained by any supported framework, run the Model Optimizer launch script ``mo`` specifying a path to the input model file and an output directory where you have write permissions:
|
||||
```sh
|
||||
python3 mo.py --input_model INPUT_MODEL --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model INPUT_MODEL --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
|
||||
The script is in `$INTEL_OPENVINO_DIR/tools/model_optimizer/`. The output directory must have write permissions, so you can run mo.py from the output directory or specify an output path with the `--output_dir` option.
|
||||
The script is in `$INTEL_OPENVINO_DIR/tools/model_optimizer/`. The output directory must have write permissions, so you can run mo from the output directory or specify an output path with the `--output_dir` option.
|
||||
|
||||
> **NOTE:** The color channel order (RGB or BGR) of an input data should match the channel order of the model training dataset. If they are different, perform the `RGB<->BGR` conversion specifying the command-line parameter: `--reverse_input_channels`. Otherwise, inference results may be incorrect. For details, refer to [When to Reverse Input Channels](#when_to_reverse_input_channels).
|
||||
|
||||
|
|
@ -174,54 +174,54 @@ Resulting Intermediate Representation will not be resizable with the help of Inf
|
|||
|
||||
Launch the Model Optimizer for the Caffe bvlc_alexnet model with debug log level:
|
||||
```sh
|
||||
python3 mo.py --input_model bvlc_alexnet.caffemodel --log_level DEBUG --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model bvlc_alexnet.caffemodel --log_level DEBUG --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
|
||||
Launch the Model Optimizer for the Caffe bvlc_alexnet model with the output IR called `result.*` in the specified `output_dir`:
|
||||
```sh
|
||||
python3 mo.py --input_model bvlc_alexnet.caffemodel --model_name result --output_dir /../../models/
|
||||
mo --input_model bvlc_alexnet.caffemodel --model_name result --output_dir /../../models/
|
||||
```
|
||||
|
||||
Launch the Model Optimizer for the Caffe bvlc_alexnet model with one input with scale values:
|
||||
```sh
|
||||
python3 mo.py --input_model bvlc_alexnet.caffemodel --scale_values [59,59,59] --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model bvlc_alexnet.caffemodel --scale_values [59,59,59] --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
|
||||
Launch the Model Optimizer for the Caffe bvlc_alexnet model with multiple inputs with scale values:
|
||||
```sh
|
||||
python3 mo.py --input_model bvlc_alexnet.caffemodel --input data,rois --scale_values [59,59,59],[5,5,5] --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model bvlc_alexnet.caffemodel --input data,rois --scale_values [59,59,59],[5,5,5] --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
|
||||
Launch the Model Optimizer for the Caffe bvlc_alexnet model with multiple inputs with scale and mean values specified for the particular nodes:
|
||||
```sh
|
||||
python3 mo.py --input_model bvlc_alexnet.caffemodel --input data,rois --mean_values data[59,59,59] --scale_values rois[5,5,5] --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model bvlc_alexnet.caffemodel --input data,rois --mean_values data[59,59,59] --scale_values rois[5,5,5] --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
|
||||
Launch the Model Optimizer for the Caffe bvlc_alexnet model with specified input layer, overridden input shape, scale 5, batch 8 and specified name of an output operation:
|
||||
```sh
|
||||
python3 mo.py --input_model bvlc_alexnet.caffemodel --input "data[1 3 224 224]" --output pool5 -s 5 -b 8 --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model bvlc_alexnet.caffemodel --input "data[1 3 224 224]" --output pool5 -s 5 -b 8 --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
|
||||
Launch the Model Optimizer for the Caffe bvlc_alexnet model with disabled fusing for linear operations to Convolution and grouped convolutions:
|
||||
```sh
|
||||
python3 mo.py --input_model bvlc_alexnet.caffemodel --disable_fusing --disable_gfusing --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model bvlc_alexnet.caffemodel --disable_fusing --disable_gfusing --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
|
||||
Launch the Model Optimizer for the Caffe bvlc_alexnet model with reversed input channels order between RGB and BGR, specified mean values to be used for the input image per channel and specified data type for input tensor values:
|
||||
```sh
|
||||
python3 mo.py --input_model bvlc_alexnet.caffemodel --reverse_input_channels --mean_values [255,255,255] --data_type FP16 --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model bvlc_alexnet.caffemodel --reverse_input_channels --mean_values [255,255,255] --data_type FP16 --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
|
||||
Launch the Model Optimizer for the Caffe bvlc_alexnet model with extensions listed in specified directories, specified mean_images binaryproto file. For more information about extensions, please refer to [this](../customize_model_optimizer/Extending_Model_Optimizer_with_New_Primitives.md) page.
|
||||
```sh
|
||||
python3 mo.py --input_model bvlc_alexnet.caffemodel --extensions /home/,/some/other/path/ --mean_file /path/to/binaryproto --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model bvlc_alexnet.caffemodel --extensions /home/,/some/other/path/ --mean_file /path/to/binaryproto --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
|
||||
Launch the Model Optimizer for TensorFlow* FaceNet* model with a placeholder freezing value.
|
||||
It replaces the placeholder with a constant layer that contains the passed value.
|
||||
For more information about FaceNet conversion, please refer to [this](tf_specific/Convert_FaceNet_From_Tensorflow.md) page
|
||||
```sh
|
||||
python3 mo.py --input_model FaceNet.pb --input "phase_train->False" --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model FaceNet.pb --input "phase_train->False" --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
|
||||
Launch the Model Optimizer for any model with a placeholder freezing tensor of values.
|
||||
|
|
@ -231,5 +231,5 @@ Tensor here is represented in square brackets with each value separated from ano
|
|||
If data type is set in the model, this tensor will be reshaped to a placeholder shape and casted to placeholder data type.
|
||||
Otherwise, it will be casted to data type passed to `--data_type` parameter (by default, it is FP32).
|
||||
```sh
|
||||
python3 mo.py --input_model FaceNet.pb --input "placeholder_layer_name->[0.1 1.2 2.3]" --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model FaceNet.pb --input "placeholder_layer_name->[0.1 1.2 2.3]" --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ In the TensorBoard, it looks the following way together with some predecessors:
|
|||
Convert this model and put the results in a writable output directory:
|
||||
```sh
|
||||
${INTEL_OPENVINO_DIR}/tools/model_optimizer
|
||||
python3 mo.py --input_model inception_v1.pb -b 1 --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model inception_v1.pb -b 1 --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
(The other examples on this page assume that you first cd to the `model_optimizer` directory and add the `--output_dir` argument with a directory where you have write permissions.)
|
||||
|
||||
|
|
@ -81,9 +81,9 @@ The last layer in the model is `InceptionV1/Logits/Predictions/Reshape_1`, which
|
|||
```
|
||||
Due to automatic identification of inputs and outputs, you do not need to provide the `--input` and `--output` options to convert the whole model. The following commands are equivalent for the Inception V1 model:
|
||||
```sh
|
||||
python3 mo.py --input_model inception_v1.pb -b 1 --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model inception_v1.pb -b 1 --output_dir <OUTPUT_MODEL_DIR>
|
||||
|
||||
python3 mo.py --input_model inception_v1.pb -b 1 --input input --output InceptionV1/Logits/Predictions/Reshape_1 --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model inception_v1.pb -b 1 --input input --output InceptionV1/Logits/Predictions/Reshape_1 --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
The Intermediate Representations are identical for both conversions. The same is true if the model has multiple inputs and/or outputs.
|
||||
|
||||
|
|
@ -99,7 +99,7 @@ If you want to cut your model at the end, you have the following options:
|
|||
|
||||
1. The following command cuts off the rest of the model after the `InceptionV1/InceptionV1/Conv2d_1a_7x7/Relu`, making this node the last in the model:
|
||||
```sh
|
||||
python3 mo.py --input_model inception_v1.pb -b 1 --output=InceptionV1/InceptionV1/Conv2d_1a_7x7/Relu --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model inception_v1.pb -b 1 --output=InceptionV1/InceptionV1/Conv2d_1a_7x7/Relu --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
The resulting Intermediate Representation has three layers:
|
||||
```xml
|
||||
|
|
@ -143,7 +143,7 @@ python3 mo.py --input_model inception_v1.pb -b 1 --output=InceptionV1/InceptionV
|
|||
|
||||
2. The following command cuts the edge that comes from 0 output port of the `InceptionV1/InceptionV1/Conv2d_1a_7x7/Relu` and the rest of the model, making this node the last one in the model:
|
||||
```sh
|
||||
python3 mo.py --input_model inception_v1.pb -b 1 --output InceptionV1/InceptionV1/Conv2d_1a_7x7/Relu:0 --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model inception_v1.pb -b 1 --output InceptionV1/InceptionV1/Conv2d_1a_7x7/Relu:0 --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
The resulting Intermediate Representation has three layers, which are the same as in the previous case:
|
||||
```xml
|
||||
|
|
@ -187,7 +187,7 @@ python3 mo.py --input_model inception_v1.pb -b 1 --output InceptionV1/InceptionV
|
|||
|
||||
3. The following command cuts the edge that comes to 0 input port of the `InceptionV1/InceptionV1/Conv2d_1a_7x7/Relu` and the rest of the model including `InceptionV1/InceptionV1/Conv2d_1a_7x7/Relu`, deleting this node and making the previous node `InceptionV1/InceptionV1/Conv2d_1a_7x7/Conv2D` the last in the model:
|
||||
```sh
|
||||
python3 mo.py --input_model inception_v1.pb -b 1 --output=0:InceptionV1/InceptionV1/Conv2d_1a_7x7/Relu --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model inception_v1.pb -b 1 --output=0:InceptionV1/InceptionV1/Conv2d_1a_7x7/Relu --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
The resulting Intermediate Representation has two layers, which are the same as the first two layers in the previous case:
|
||||
```xml
|
||||
|
|
@ -225,7 +225,7 @@ If you want to go further and cut the beginning of the model, leaving only the `
|
|||
|
||||
1. You can use the following command line, where `--input` and `--output` specify the same node in the graph:
|
||||
```sh
|
||||
python3 mo.py --input_model=inception_v1.pb -b 1 --output InceptionV1/InceptionV1/Conv2d_1a_7x7/Relu --input InceptionV1/InceptionV1/Conv2d_1a_7x7/Relu --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model=inception_v1.pb -b 1 --output InceptionV1/InceptionV1/Conv2d_1a_7x7/Relu --input InceptionV1/InceptionV1/Conv2d_1a_7x7/Relu --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
The resulting Intermediate Representation looks as follows:
|
||||
```xml
|
||||
|
|
@ -257,7 +257,7 @@ Even though `--input_shape` is not specified in the command line, the shapes for
|
|||
2. You can cut edge incoming to layer by port number. To specify incoming port use notation `--input=port:input_node`.
|
||||
So, to cut everything before `ReLU` layer, cut edge incoming in port 0 of `InceptionV1/InceptionV1/Conv2d_1a_7x7/Relu` node:
|
||||
```sh
|
||||
python3 mo.py --input_model inception_v1.pb -b 1 --input 0:InceptionV1/InceptionV1/Conv2d_1a_7x7/Relu --output InceptionV1/InceptionV1/Conv2d_1a_7x7/Relu --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model inception_v1.pb -b 1 --input 0:InceptionV1/InceptionV1/Conv2d_1a_7x7/Relu --output InceptionV1/InceptionV1/Conv2d_1a_7x7/Relu --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
The resulting Intermediate Representation looks as follows:
|
||||
```xml
|
||||
|
|
@ -289,7 +289,7 @@ Even though `--input_shape` is not specified in the command line, the shapes for
|
|||
3. You can cut edge outcoming from layer by port number. To specify outcoming port use notation `--input=input_node:port`.
|
||||
So, to cut everything before `ReLU` layer, cut edge from `InceptionV1/InceptionV1/Conv2d_1a_7x7/BatchNorm/batchnorm/add_1` node to `ReLU`:
|
||||
```sh
|
||||
python3 mo.py --input_model inception_v1.pb -b 1 --input InceptionV1/InceptionV1/Conv2d_1a_7x7/BatchNorm/batchnorm/add_1:0 --output InceptionV1/InceptionV1/Conv2d_1a_7x7/Relu --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model inception_v1.pb -b 1 --input InceptionV1/InceptionV1/Conv2d_1a_7x7/BatchNorm/batchnorm/add_1:0 --output InceptionV1/InceptionV1/Conv2d_1a_7x7/Relu --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
The resulting Intermediate Representation looks as follows:
|
||||
```xml
|
||||
|
|
@ -320,7 +320,7 @@ python3 mo.py --input_model inception_v1.pb -b 1 --input InceptionV1/InceptionV1
|
|||
|
||||
The input shape can be overridden with `--input_shape`. In this case, the shape is applied to the node referenced in `--input`, not to the original `Placeholder` in the model. For example, this command line
|
||||
```sh
|
||||
python3 mo.py --input_model inception_v1.pb --input_shape=[1,5,10,20] --output InceptionV1/InceptionV1/Conv2d_1a_7x7/Relu --input InceptionV1/InceptionV1/Conv2d_1a_7x7/Relu --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model inception_v1.pb --input_shape=[1,5,10,20] --output InceptionV1/InceptionV1/Conv2d_1a_7x7/Relu --input InceptionV1/InceptionV1/Conv2d_1a_7x7/Relu --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
|
||||
gives the following shapes in the `Input` and `ReLU` layers:
|
||||
|
|
@ -369,14 +369,14 @@ There are operations that contain more than one input ports. In the example cons
|
|||
Following this behavior, the Model Optimizer creates an `Input` layer for port 0 only, leaving port 1 as a constant. So the result of:
|
||||
|
||||
```sh
|
||||
python3 mo.py --input_model inception_v1.pb -b 1 --input InceptionV1/InceptionV1/Conv2d_1a_7x7/convolution --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model inception_v1.pb -b 1 --input InceptionV1/InceptionV1/Conv2d_1a_7x7/convolution --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
|
||||
is identical to the result of conversion of the model as a whole, because this convolution is the first executable operation in Inception V1.
|
||||
|
||||
Different behavior occurs when `--input_shape` is also used as an attempt to override the input shape:
|
||||
```sh
|
||||
python3 mo.py --input_model inception_v1.pb--input=InceptionV1/InceptionV1/Conv2d_1a_7x7/convolution --input_shape [1,224,224,3] --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model inception_v1.pb--input=InceptionV1/InceptionV1/Conv2d_1a_7x7/convolution --input_shape [1,224,224,3] --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
An error occurs (for more information, see <a href="MO_FAQ.html#FAQ30">FAQ #30</a>):
|
||||
```sh
|
||||
|
|
@ -388,5 +388,5 @@ In this case, when `--input_shape` is specified and the node contains multiple i
|
|||
|
||||
The correct command line is:
|
||||
```sh
|
||||
python3 mo.py --input_model inception_v1.pb --input 0:InceptionV1/InceptionV1/Conv2d_1a_7x7/convolution --input_shape=[1,224,224,3] --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model inception_v1.pb --input 0:InceptionV1/InceptionV1/Conv2d_1a_7x7/convolution --input_shape=[1,224,224,3] --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ for the ASpIRE Chain Time Delay Neural Network (TDNN) from the Kaldi* project of
|
|||
|
||||
To generate the Intermediate Representation (IR) of the model, run the Model Optimizer with the following parameters:
|
||||
```sh
|
||||
python3 ./mo_kaldi.py --input_model exp/chain/tdnn_7b/final.mdl --output output
|
||||
mo --input_model exp/chain/tdnn_7b/final.mdl --output output
|
||||
```
|
||||
|
||||
The IR will have two inputs: `input` for data and `ivector` for ivectors.
|
||||
|
|
|
|||
|
|
@ -13,14 +13,14 @@ As a result, you will get an MXNet model representation in `ssd_512_mobilenet1.0
|
|||
2. Run the Model Optimizer tool specifying the `--enable_ssd_gluoncv` option. Make sure the `--input_shape` parameter is set to the input shape layout of your model (NHWC or NCHW). The examples below illustrates running the Model Optimizer for the SSD and YOLO-v3 models trained with the NHWC layout and located in the `<model_directory>`:
|
||||
* **For GluonCV SSD topologies:**
|
||||
```sh
|
||||
python3 mo_mxnet.py --input_model <model_directory>/ssd_512_mobilenet1.0.params --enable_ssd_gluoncv --input_shape [1,512,512,3] --input data --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model <model_directory>/ssd_512_mobilenet1.0.params --enable_ssd_gluoncv --input_shape [1,512,512,3] --input data --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
* **For YOLO-v3 topology:**
|
||||
* To convert the model:
|
||||
```sh
|
||||
python3 mo_mxnet.py --input_model <model_directory>/yolo3_mobilenet1.0_voc-0000.params --input_shape [1,255,255,3] --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model <model_directory>/yolo3_mobilenet1.0_voc-0000.params --input_shape [1,255,255,3] --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
* To convert the model with replacing the subgraph with RegionYolo layers:
|
||||
```sh
|
||||
python3 mo_mxnet.py --input_model <model_directory>/models/yolo3_mobilenet1.0_voc-0000.params --input_shape [1,255,255,3] --transformations_config "mo/extensions/front/mxnet/yolo_v3_mobilenet1_voc.json" --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model <model_directory>/models/yolo3_mobilenet1.0_voc-0000.params --input_shape [1,255,255,3] --transformations_config "front/mxnet/yolo_v3_mobilenet1_voc.json" --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
|
|
|
|||
|
|
@ -112,6 +112,6 @@ cp models/13_decoder_auxs.nd nst_model
|
|||
|
||||
3. Run the Model Optimizer for MXNet. Use the `--nd_prefix_name` option to specify the decoder prefix and `--input_shape` to specify input shapes in [N,C,W,H] order. For example:<br>
|
||||
```sh
|
||||
python3 mo.py --input_symbol <path/to/nst_model>/nst_vgg19-symbol.json --framework mxnet --output_dir <path/to/output_dir> --input_shape [1,3,224,224] --nd_prefix_name 13_decoder --pretrained_model <path/to/nst_model>/vgg19-0000.params
|
||||
mo --input_symbol <path/to/nst_model>/nst_vgg19-symbol.json --framework mxnet --output_dir <path/to/output_dir> --input_shape [1,3,224,224] --nd_prefix_name 13_decoder --pretrained_model <path/to/nst_model>/vgg19-0000.params
|
||||
```
|
||||
4. The IR is generated (`.bin`, `.xml` and `.mapping` files) in the specified output directory and ready to be consumed by the Inference Engine.
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ If you train the model using the [script provided in model repository](https://g
|
|||
|
||||
**Step 2**. To generate the Intermediate Representation (IR) of the model, change your current working directory to the Model Optimizer installation directory and run the Model Optimizer with the following parameters:
|
||||
```sh
|
||||
python3 ./mo.py --input_model dlrm_s_pytorch.onnx
|
||||
mo --input_model dlrm_s_pytorch.onnx
|
||||
```
|
||||
|
||||
Note that Pytorch model uses operation `torch.nn.EmbeddingBag`. This operation converts to onnx as custom `ATen` layer and not directly supported by OpenVINO*, but it is possible to convert this operation to:
|
||||
|
|
|
|||
|
|
@ -6,12 +6,12 @@ These instructions are applicable only to the Faster R-CNN model converted to th
|
|||
|
||||
**Step 2**. To generate the Intermediate Representation (IR) of the model, change your current working directory to the Model Optimizer installation directory and run the Model Optimizer with the following parameters:
|
||||
```sh
|
||||
python3 ./mo_onnx.py
|
||||
mo
|
||||
--input_model FasterRCNN-10.onnx \
|
||||
--input_shape [1,3,800,800] \
|
||||
--input 0:2 \
|
||||
--mean_values [102.9801,115.9465,122.7717] \
|
||||
--transformations_config ./extensions/front/onnx/faster_rcnn.json
|
||||
--transformations_config front/onnx/faster_rcnn.json
|
||||
```
|
||||
|
||||
Note that the height and width specified with the `input_shape` command line parameter could be different. Refer to the [documentation](https://github.com/onnx/models/tree/master/vision/object_detection_segmentation/faster-rcnn) for more information about supported input image dimensions and required pre- and post-processing steps.
|
||||
|
|
|
|||
|
|
@ -13,5 +13,5 @@ To download the model and sample test data, click **Download** on [https://githu
|
|||
|
||||
To generate the Intermediate Representation (IR) of the model GPT-2, run the Model Optimizer with the following parameters:
|
||||
```sh
|
||||
python3 mo.py --input_model gpt2-10.onnx --input_shape [X,Y,Z] --output_dir <OUTPUT_MODEL_DIR>
|
||||
mo --input_model gpt2-10.onnx --input_shape [X,Y,Z] --output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
|
|
|
|||
|
|
@ -6,12 +6,12 @@ These instructions are applicable only to the [Mask R-CNN model](https://onnxzoo
|
|||
|
||||
**Step 2**. To generate the Intermediate Representation (IR) of the model, change your current working directory to the Model Optimizer installation directory and run the Model Optimizer with the following parameters:
|
||||
```sh
|
||||
python3 ./mo_onnx.py
|
||||
mo
|
||||
--input_model mask_rcnn_R_50_FPN_1x.onnx \
|
||||
--input "0:2" \
|
||||
--input_shape [1,3,800,800] \
|
||||
--mean_values [102.9801,115.9465,122.7717] \
|
||||
--transformations_config ./extensions/front/onnx/mask_rcnn.json
|
||||
--transformations_config front/onnx/mask_rcnn.json
|
||||
```
|
||||
|
||||
Note that the height and width specified with the `input_shape` command line parameter could be different. Refer to the [documentation](https://github.com/onnx/models/tree/master/vision/object_detection_segmentation/mask-rcnn) for more information about supported input image dimensions and required pre- and post-processing steps.
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ The script generates ONNX* model file `bert-ner.onnx`.
|
|||
## Convert ONNX* BERT-NER model to IR
|
||||
|
||||
```bash
|
||||
python mo.py --input_model bert-ner.onnx --input "input_mask[1 128],segment_ids[1 128],input_ids[1 128]"
|
||||
mo --input_model bert-ner.onnx --input "input_mask[1 128],segment_ids[1 128],input_ids[1 128]"
|
||||
```
|
||||
|
||||
where `1` is `batch_size` and `128` is `sequence_length`.
|
||||
|
|
@ -28,5 +28,5 @@ The script generates the ONNX\* model file `f3net.onnx`. This model conversion w
|
|||
## Convert ONNX* F3Net Model to IR
|
||||
|
||||
```sh
|
||||
./mo.py --input_model <MODEL_DIR>/f3net.onnx
|
||||
mo --input_model <MODEL_DIR>/f3net.onnx
|
||||
```
|
||||
|
|
|
|||
|
|
@ -29,12 +29,12 @@ They are `decoder`, `encoder` and a combined `decoder(encoder(x))` models, respe
|
|||
|
||||
If using a combined model:
|
||||
```sh
|
||||
./mo.py --input_model <MODEL_DIR>/qt.onnx --input_shape [B,64,X]
|
||||
mo --input_model <MODEL_DIR>/qt.onnx --input_shape [B,64,X]
|
||||
```
|
||||
If using separate models:
|
||||
```sh
|
||||
./mo.py --input_model <MODEL_DIR>/encoder_qt.onnx --input_shape [B,64,X]
|
||||
./mo.py --input_model <MODEL_DIR>/decoder_qt.onnx --input_shape [B,1024,Y]
|
||||
mo --input_model <MODEL_DIR>/encoder_qt.onnx --input_shape [B,64,X]
|
||||
mo --input_model <MODEL_DIR>/decoder_qt.onnx --input_shape [B,1024,Y]
|
||||
```
|
||||
|
||||
Where shape is determined by the audio file Mel-Spectrogram length: B - batch dimension, X - dimension based on the input length, Y - determined by encoder output, usually `X / 2`.
|
||||
|
|
|
|||
|
|
@ -27,5 +27,5 @@ The script generates the ONNX\* model file RCAN.onnx. You can find more informat
|
|||
## Convert ONNX* RCAN Model to IR
|
||||
|
||||
```sh
|
||||
./mo.py --input_model RCAN.onnx
|
||||
mo --input_model RCAN.onnx
|
||||
```
|
||||
|
|
|
|||
|
|
@ -99,9 +99,9 @@ After completing this step, the files `rnnt_encoder.onnx`, `rnnt_prediction.onnx
|
|||
**Step 6**. Run the conversion command:
|
||||
|
||||
```bash
|
||||
python3 {path_to_openvino}/mo.py --input_model rnnt_encoder.onnx --input "input[157 1 240],feature_length->157"
|
||||
python3 {path_to_openvino}/mo.py --input_model rnnt_prediction.onnx --input "symbol[1 1],hidden_in_1[2 1 320],hidden_in_2[2 1 320]"
|
||||
python3 {path_to_openvino}/mo.py --input_model rnnt_joint.onnx --input "0[1 1 1024],1[1 1 320]"
|
||||
mo --input_model rnnt_encoder.onnx --input "input[157 1 240],feature_length->157"
|
||||
mo --input_model rnnt_prediction.onnx --input "symbol[1 1],hidden_in_1[2 1 320],hidden_in_2[2 1 320]"
|
||||
mo --input_model rnnt_joint.onnx --input "0[1 1 1024],1[1 1 320]"
|
||||
```
|
||||
Please note that hardcoded value for sequence length = 157 was taken from the MLCommons but conversion to IR preserves
|
||||
network [reshapeability](../../../../IE_DG/ShapeInference.md), this means you can change input shapes manually to any value either during conversion or
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ python3 eval.py \
|
|||
**Step 4**. Convert the model to the IR:
|
||||
|
||||
```sh
|
||||
python path/to/model_optimizer/mo.py --input_model /path/to/yolact.onnx
|
||||
mo --input_model /path/to/yolact.onnx
|
||||
```
|
||||
|
||||
**Step 4**. Embed input preprocessing into the IR:
|
||||
|
|
@ -173,7 +173,7 @@ To get performance gain by offloading to the OpenVINO application of mean/scale
|
|||
* If the backbone of the model is Resnet50-FPN or Resnet101-FPN, use the following MO command line:
|
||||
|
||||
```sh
|
||||
python path/to/model_optimizer/mo.py \
|
||||
mo \
|
||||
--input_model /path/to/yolact.onnx \
|
||||
--reverse_input_channels \
|
||||
--mean_values "[123.68, 116.78, 103.94]" \
|
||||
|
|
@ -183,7 +183,7 @@ python path/to/model_optimizer/mo.py \
|
|||
* If the backbone of the model is Darknet53-FPN, use the following MO command line:
|
||||
|
||||
```sh
|
||||
python path/to/model_optimizer/mo.py \
|
||||
mo \
|
||||
--input_model /path/to/yolact.onnx \
|
||||
--reverse_input_channels \
|
||||
--scale 255
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ The original AOCR model contains data preprocessing which consists of the follow
|
|||
|
||||
After that, the resized image is sent to the convolution neural network (CNN). The Model Optimizer does not support image decoding so you should cut of preprocessing part of the model using '--input' command line parameter.
|
||||
```sh
|
||||
python3 path/to/model_optimizer/mo_tf.py \
|
||||
mo \
|
||||
--input_model=model/path/frozen_graph.pb \
|
||||
--input="map/TensorArrayStack/TensorArrayGatherV3:0[1 32 86 1]" \
|
||||
--output "transpose_1,transpose_2" \
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ Pre-trained model meta-graph files are `bert_model.ckpt.*`.
|
|||
|
||||
To generate the BERT Intermediate Representation (IR) of the model, run the Model Optimizer with the following parameters:
|
||||
```sh
|
||||
python3 ./mo_tf.py
|
||||
mo \
|
||||
--input_meta_graph uncased_L-12_H-768_A-12/bert_model.ckpt.meta \
|
||||
--output bert/pooler/dense/Tanh \
|
||||
--input Placeholder{i32},Placeholder_1{i32},Placeholder_2{i32}
|
||||
|
|
@ -109,9 +109,9 @@ python3 run_classifier.py \
|
|||
|
||||
Run the Model Optimizer with the following command line parameters to generate reshape-able BERT Intermediate Representation (IR):
|
||||
```sh
|
||||
python3 ./mo_tf.py \
|
||||
--input_model inference_graph.pb \
|
||||
--input "IteratorGetNext:0{i32}[1 128],IteratorGetNext:1{i32}[1 128],IteratorGetNext:4{i32}[1 128]"
|
||||
mo \
|
||||
--input_model inference_graph.pb \
|
||||
--input "IteratorGetNext:0{i32}[1 128],IteratorGetNext:1{i32}[1 128],IteratorGetNext:4{i32}[1 128]"
|
||||
```
|
||||
For other applicable parameters, refer to [Convert Model from TensorFlow](../Convert_Model_From_TensorFlow.md).
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ python tools/test_shadownet.py --image_path data/test_images/test_01.jpg --weigh
|
|||
|
||||
**Step 4.** Convert the model into IR:
|
||||
```sh
|
||||
python3 path/to/model_optimizer/mo_tf.py --input_model path/to/your/CRNN_Tensorflow/frozen_graph.pb
|
||||
mo --input_model path/to/your/CRNN_Tensorflow/frozen_graph.pb
|
||||
```
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -68,8 +68,8 @@ There are certain limitations for the model conversion:
|
|||
|
||||
To generate the IR, run the Model Optimizer with the following parameters:
|
||||
```sh
|
||||
python3 {path_to_mo}/mo_tf.py \
|
||||
--input_model output_graph.pb \
|
||||
mo \
|
||||
--input_model output_graph.pb \
|
||||
--input "input_lengths->[16],input_node[1 16 19 26],previous_state_h[1 2048],previous_state_c[1 2048]" \
|
||||
--output "cudnn_lstm/rnn/multi_rnn_cell/cell_0/cudnn_compatible_lstm_cell/GatherNd_1,cudnn_lstm/rnn/multi_rnn_cell/cell_0/cudnn_compatible_lstm_cell/GatherNd,logits"
|
||||
```
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ tar zxvf efficientdet-d4.tar.gz
|
|||
```
|
||||
5. Freeze the model:<br>
|
||||
```sh
|
||||
python3 model_inspect.py --runmode=saved_model --model_name=efficientdet-d4 --ckpt_path=efficientdet-d4 --saved_model_dir=savedmodeldir
|
||||
mo --runmode=saved_model --model_name=efficientdet-d4 --ckpt_path=efficientdet-d4 --saved_model_dir=savedmodeldir
|
||||
```
|
||||
As a result the frozen model file `savedmodeldir/efficientdet-d4_frozen.pb` will be generated.
|
||||
|
||||
|
|
@ -47,9 +47,9 @@ As a result the frozen model file `savedmodeldir/efficientdet-d4_frozen.pb` will
|
|||
|
||||
To generate the IR of the EfficientDet TensorFlow model, run:<br>
|
||||
```sh
|
||||
python3 $INTEL_OPENVINO_DIR/tools/model_optimizer/mo.py \
|
||||
mo \
|
||||
--input_model savedmodeldir/efficientdet-d4_frozen.pb \
|
||||
--transformations_config $INTEL_OPENVINO_DIR/tools/model_optimizer/extensions/front/tf/automl_efficientdet.json \
|
||||
--transformations_config front/tf/automl_efficientdet.json \
|
||||
--input_shape [1,$IMAGE_SIZE,$IMAGE_SIZE,3] \
|
||||
--reverse_input_channels
|
||||
```
|
||||
|
|
@ -61,7 +61,7 @@ The attribute `image_size` specifies the shape to be specified for the model con
|
|||
|
||||
The `transformations_config` command line parameter specifies the configuration json file containing hints
|
||||
to the Model Optimizer on how to convert the model and trigger transformations implemented in the
|
||||
`$MO_ROOT/extensions/front/tf/AutomlEfficientDet.py`. The json file contains some parameters which must be changed if you
|
||||
`<PYTHON_SITE_PACKAGES>/openvino/tools/mo/front/tf/AutomlEfficientDet.py`. The json file contains some parameters which must be changed if you
|
||||
train the model yourself and modified the `hparams_config` file or the parameters are different from the ones used for EfficientDet-D4.
|
||||
The attribute names are self-explanatory or match the name in the `hparams_config` file.
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ There are two inputs in this network: boolean `phase_train` which manages state
|
|||
|
||||
To generate FaceNet IR provide TensorFlow FaceNet model to Model Optimizer with parameters:
|
||||
```sh
|
||||
python3 ./mo_tf.py
|
||||
mo
|
||||
--input_model path_to_model/model_name.pb \
|
||||
--freeze_placeholder_with_value "phase_train->False"
|
||||
```
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ tgt_vocab_size -= 1
|
|||
**Step 4**. Convert the model to the IR:
|
||||
|
||||
```sh
|
||||
python3 path/to/model_optimizer/mo_tf.py
|
||||
mo
|
||||
--input_model /path/to/dump/model/frozen_GNMT_inference_graph.pb
|
||||
--input "IteratorGetNext:1{i32}[1],IteratorGetNext:0{i32}[1 50],dynamic_seq2seq/hash_table_Lookup_1:0[1]->[2],dynamic_seq2seq/hash_table_Lookup:0[1]->[1]"
|
||||
--output dynamic_seq2seq/decoder/decoder/GatherTree
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ it has one input that is split into four `ResourceGather` layers. (Click image t
|
|||
But as the Model Optimizer does not support such data feeding, you should skip it. Cut
|
||||
the edges incoming in `ResourceGather`s port 1:
|
||||
```sh
|
||||
python3 mo_tf.py --input_model inference_graph.pb \
|
||||
mo --input_model inference_graph.pb \
|
||||
--input 1:embedding/embedding_lookup,1:embedding_1/embedding_lookup, \
|
||||
1:embedding_2/embedding_lookup,1:embedding_3/embedding_lookup \
|
||||
--input_shape [256],[256],[256],[256] \
|
||||
|
|
@ -40,7 +40,7 @@ In the `input_shape` parameter, 256 specifies the `batch_size` for your model.
|
|||
|
||||
Alternatively, you can do steps 2 and 3 in one command line:
|
||||
```sh
|
||||
python3 mo_tf.py --input_meta_graph /path/to/model/model.meta \
|
||||
mo --input_meta_graph /path/to/model/model.meta \
|
||||
--input 1:embedding/embedding_lookup,1:embedding_1/embedding_lookup, \
|
||||
1:embedding_2/embedding_lookup,1:embedding_3/embedding_lookup \
|
||||
--input_shape [256],[256],[256],[256] --output rating/BiasAdd \
|
||||
|
|
|
|||
|
|
@ -11,10 +11,10 @@ You can download TensorFlow\* Object Detection API models from the <a href="http
|
|||
|
||||
<strong>NOTE</strong>: Before converting, make sure you have configured the Model Optimizer. For configuration steps, refer to [Configuring the Model Optimizer](../../Config_Model_Optimizer.md).
|
||||
|
||||
To convert a TensorFlow\* Object Detection API model, go to the `<INSTALL_DIR>/tools/model_optimizer` directory and run the `mo_tf.py` script with the following required parameters:
|
||||
To convert a TensorFlow\* Object Detection API model, go to the `<INSTALL_DIR>/tools/model_optimizer` directory and run the `mo` script with the following required parameters:
|
||||
|
||||
* `--input_model <path_to_frozen.pb>` --- File with a pre-trained model (binary or text .pb file after freezing) OR `--saved_model_dir <path_to_saved_model>` for the TensorFlow\* 2 models
|
||||
* `--transformations_config <path_to_subgraph_replacement_configuration_file.json>` --- A subgraph replacement configuration file with transformations description. For the models downloaded from the TensorFlow\* Object Detection API zoo, you can find the configuration files in the `<INSTALL_DIR>/tools/model_optimizer/extensions/front/tf` directory. Use:
|
||||
* `--transformations_config <path_to_subgraph_replacement_configuration_file.json>` --- A subgraph replacement configuration file with transformations description. For the models downloaded from the TensorFlow\* Object Detection API zoo, you can find the configuration files in the `<PYTHON_SITE_PACKAGES>/openvino/tools/mo/front/tf` directory. Use:
|
||||
* `ssd_v2_support.json` --- for frozen SSD topologies from the models zoo version up to 1.13.X inclusively
|
||||
* `ssd_support_api_v.1.14.json` --- for SSD topologies trained using the TensorFlow\* Object Detection API version 1.14 up to 1.14.X inclusively
|
||||
* `ssd_support_api_v.1.15.json` --- for SSD topologies trained using the TensorFlow\* Object Detection API version 1.15 up to 2.0
|
||||
|
|
@ -52,7 +52,7 @@ Additionally to the mandatory parameters listed above you can use optional conve
|
|||
For example, if you downloaded the [pre-trained SSD InceptionV2 topology](http://download.tensorflow.org/models/object_detection/ssd_inception_v2_coco_2018_01_28.tar.gz) and extracted archive to the directory `/tmp/ssd_inception_v2_coco_2018_01_28`, the sample command line to convert the model looks as follows:
|
||||
|
||||
```
|
||||
<INSTALL_DIR>/tools/model_optimizer/mo_tf.py --input_model=/tmp/ssd_inception_v2_coco_2018_01_28/frozen_inference_graph.pb --transformations_config <INSTALL_DIR>/tools/model_optimizer/extensions/front/tf/ssd_v2_support.json --tensorflow_object_detection_api_pipeline_config /tmp/ssd_inception_v2_coco_2018_01_28/pipeline.config --reverse_input_channels
|
||||
mo --input_model=/tmp/ssd_inception_v2_coco_2018_01_28/frozen_inference_graph.pb --transformations_config front/tf/ssd_v2_support.json --tensorflow_object_detection_api_pipeline_config /tmp/ssd_inception_v2_coco_2018_01_28/pipeline.config --reverse_input_channels
|
||||
```
|
||||
|
||||
## OpenVINO&; Toolkit Samples and Open Model Zoo Demos
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ To convert this model to the TensorFlow\* format, you can use [Reproduce Keras*
|
|||
|
||||
After you convert the model to TensorFlow* format, run the Model Optimizer command below:
|
||||
```sh
|
||||
python mo.py --input "input_1[1 1333 1333 3]" --input_model retinanet_resnet50_coco_best_v2.1.0.pb --data_type FP32 --transformations_config ./extensions/front/tf/retinanet.json
|
||||
mo --input "input_1[1 1333 1333 3]" --input_model retinanet_resnet50_coco_best_v2.1.0.pb --data_type FP32 --transformations_config front/tf/retinanet.json
|
||||
```
|
||||
|
||||
Where `transformations_config` command-line parameter specifies the configuration json file containing model conversion hints for the Model Optimizer.
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ python3 tf_models/research/slim/export_inference_graph.py \
|
|||
Model Optimizer comes with the summarize graph utility, which identifies graph input and output nodes. Run the utility to determine input/output nodes of the Inception V1 model:
|
||||
|
||||
```sh
|
||||
python3 <MODEL_OPTIMIZER_INSTALL_DIR>/mo/utils/summarize_graph.py --input_model ./inception_v1_inference_graph.pb
|
||||
python3 <PYTHON_SITE_PACKAGES>/openvino/tools/mo/utils/summarize_graph.py --input_model ./inception_v1_inference_graph.pb
|
||||
```
|
||||
|
||||
The output looks as follows:<br>
|
||||
|
|
@ -56,7 +56,7 @@ The tool finds one input node with name `input`, type `float32`, fixed image siz
|
|||
Step 4. Convert the model with the Model Optimizer:
|
||||
|
||||
```sh
|
||||
<MODEL_OPTIMIZER_INSTALL_DIR>/mo_tf.py --input_model ./inception_v1_inference_graph.pb --input_checkpoint ./inception_v1.ckpt -b 1 --mean_value [127.5,127.5,127.5] --scale 127.5
|
||||
mo --input_model ./inception_v1_inference_graph.pb --input_checkpoint ./inception_v1.ckpt -b 1 --mean_value [127.5,127.5,127.5] --scale 127.5
|
||||
```
|
||||
|
||||
The `-b` command line parameter is required because the Model Optimizer cannot convert a model with undefined input size.
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ python census_main.py
|
|||
Use the following command line to convert the saved model file with the checkpoint:
|
||||
|
||||
```sh
|
||||
python mo.py
|
||||
mo
|
||||
--input_checkpoint checkpoint --input_meta_graph model.ckpt.meta
|
||||
--input "IteratorGetNext:0[2],
|
||||
IteratorGetNext:1[2],
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@ The script should save into `~/XLNet-Large/xlnet`.
|
|||
|
||||
To generate the XLNet Intermediate Representation (IR) of the model, run the Model Optimizer with the following parameters:
|
||||
```sh
|
||||
python3 mo.py --input_model path-to-model/model_frozen.pb \
|
||||
--input "input_mask[50 1],input_ids[50 1],seg_ids[50 1]"
|
||||
mo --input_model path-to-model/model_frozen.pb \
|
||||
--input "input_mask[50 1],input_ids[50 1],seg_ids[50 1]"
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ python converter.py
|
|||
|
||||
> **NOTE:** Before you run the convertion, make sure you have installed all the Model Optimizer dependencies for TensorFlow 2.
|
||||
```sh
|
||||
python mo.py --saved_model_dir yolov4 --output_dir models/IRs --input_shape [1,608,608,3] --model_name yolov4
|
||||
mo --saved_model_dir yolov4 --output_dir models/IRs --input_shape [1,608,608,3] --model_name yolov4
|
||||
```
|
||||
|
||||
## <a name="yolov3-to-ir"></a>Convert YOLOv3 Model to IR
|
||||
|
|
@ -124,18 +124,18 @@ where:
|
|||
|
||||
To generate an IR of the YOLOv3 TensorFlow model, run:<br>
|
||||
```sh
|
||||
python3 mo_tf.py \
|
||||
mo \
|
||||
--input_model /path/to/yolo_v3.pb \
|
||||
--transformations_config $MO_ROOT/extensions/front/tf/yolo_v3.json \
|
||||
--transformations_config front/tf/yolo_v3.json \
|
||||
--batch 1 \
|
||||
--output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
|
||||
To generate an IR of the YOLOv3-tiny TensorFlow model, run:<br>
|
||||
```sh
|
||||
python3 mo_tf.py \
|
||||
mo \
|
||||
--input_model /path/to/yolo_v3_tiny.pb \
|
||||
--transformations_config $MO_ROOT/extensions/front/tf/yolo_v3_tiny.json \
|
||||
--transformations_config front/tf/yolo_v3_tiny.json \
|
||||
--batch 1 \
|
||||
--output_dir <OUTPUT_MODEL_DIR>
|
||||
```
|
||||
|
|
@ -213,11 +213,11 @@ create another configuration file with custom operations and use it for conversi
|
|||
|
||||
To generate the IR of the YOLOv1 model, provide TensorFlow YOLOv1 or YOLOv2 model to the Model Optimizer with the following parameters:<br>
|
||||
```sh
|
||||
python3 ./mo_tf.py
|
||||
mo
|
||||
--input_model <path_to_model>/<model_name>.pb \
|
||||
--batch 1 \
|
||||
--scale 255 \
|
||||
--transformations_config <OPENVINO_INSTALL_DIR>/tools/model_optimizer/extensions/front/tf/<yolo_config>.json
|
||||
--transformations_config front/tf/<yolo_config>.json
|
||||
```
|
||||
where:
|
||||
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ There is a certain limitations for the model conversion:
|
|||
To generate the `lm_1b` Intermediate Representation (IR), provide TensorFlow `lm_1b` model to the
|
||||
Model Optimizer with parameters:
|
||||
```sh
|
||||
python3 ./mo_tf.py
|
||||
mo
|
||||
--input_model lm_1b/graph-2016-09-10.pbtxt \
|
||||
--input_checkpoint lm_1b/ckpt \
|
||||
--input_model_is_text \
|
||||
|
|
|
|||
|
|
@ -279,7 +279,7 @@ The `squeezenet1.1` model is downloaded in the Caffe* format. You must use the M
|
|||
cd /opt/intel/openvino_2022/tools/model_optimizer
|
||||
```
|
||||
```sh
|
||||
python3 ./mo.py --input_model <model_dir>/<model_file> --data_type <model_precision> --output_dir <ir_dir>
|
||||
mo --input_model <model_dir>/<model_file> --data_type <model_precision> --output_dir <ir_dir>
|
||||
```
|
||||
The produced IR files are in the `<ir_dir>` directory.
|
||||
|
||||
|
|
@ -292,7 +292,7 @@ The following command converts the public SqueezeNet 1.1 Caffe\* model to the FP
|
|||
cd /opt/intel/openvino_2022/tools/model_optimizer
|
||||
```
|
||||
```sh
|
||||
python3 ./mo.py --input_model ~/models/public/squeezenet1.1/squeezenet1.1.caffemodel --data_type FP16 --output_dir ~/models/public/squeezenet1.1/ir
|
||||
mo --input_model ~/models/public/squeezenet1.1/squeezenet1.1.caffemodel --data_type FP16 --output_dir ~/models/public/squeezenet1.1/ir
|
||||
```
|
||||
|
||||
After the Model Optimizer script is completed, the produced IR files (`squeezenet1.1.xml`, `squeezenet1.1.bin`) are in the specified `~/models/public/squeezenet1.1/ir` directory.
|
||||
|
|
|
|||
|
|
@ -261,7 +261,7 @@ The `squeezenet1.1` model is downloaded in the Caffe* format. You must use the M
|
|||
cd /opt/intel/openvino_2022/tools/model_optimizer
|
||||
```
|
||||
```sh
|
||||
python3 ./mo.py --input_model <model_dir>/<model_file> --data_type <model_precision> --output_dir <ir_dir>
|
||||
mo --input_model <model_dir>/<model_file> --data_type <model_precision> --output_dir <ir_dir>
|
||||
```
|
||||
The produced IR files are in the `<ir_dir>` directory.
|
||||
|
||||
|
|
@ -274,7 +274,7 @@ The following command converts the public SqueezeNet 1.1 Caffe\* model to the FP
|
|||
cd /opt/intel/openvino_2022/tools/model_optimizer
|
||||
```
|
||||
```sh
|
||||
python3 ./mo.py --input_model ~/models/public/squeezenet1.1/squeezenet1.1.caffemodel --data_type FP16 --output_dir ~/models/public/squeezenet1.1/ir
|
||||
mo --input_model ~/models/public/squeezenet1.1/squeezenet1.1.caffemodel --data_type FP16 --output_dir ~/models/public/squeezenet1.1/ir
|
||||
```
|
||||
|
||||
After the Model Optimizer script is completed, the produced IR files (`squeezenet1.1.xml`, `squeezenet1.1.bin`) are in the specified `~/models/public/squeezenet1.1/ir` directory.
|
||||
|
|
|
|||
|
|
@ -257,7 +257,7 @@ The `squeezenet1.1` model is downloaded in the Caffe* format. You must use the M
|
|||
cd <INSTALL_DIR>\tools\model_optimizer
|
||||
```
|
||||
```bat
|
||||
python .\mo.py --input_model <model_dir>\<model_file> --data_type <model_precision> --output_dir <ir_dir>
|
||||
mo --input_model <model_dir>\<model_file> --data_type <model_precision> --output_dir <ir_dir>
|
||||
```
|
||||
The produced IR files are in the `<ir_dir>` directory.
|
||||
|
||||
|
|
@ -266,11 +266,8 @@ The `squeezenet1.1` model is downloaded in the Caffe* format. You must use the M
|
|||
|
||||
The following command converts the public SqueezeNet 1.1 Caffe\* model to the FP16 IR and saves to the `C:\Users\<USER_ID>\Documents\models\public\squeezenet1.1\ir` output directory:
|
||||
|
||||
```bat
|
||||
cd <INSTALL_DIR>\tools\model_optimizer
|
||||
```
|
||||
```bat
|
||||
python .\mo.py --input_model C:\Users\username\Documents\models\public\squeezenet1.1\squeezenet1.1.caffemodel --data_type FP16 --output_dir C:\Users\username\Documents\models\public\squeezenet1.1\ir
|
||||
mo --input_model C:\Users\<username>\Documents\models\public\squeezenet1.1\squeezenet1.1.caffemodel --data_type FP16 --output_dir C:\Users\username\Documents\models\public\squeezenet1.1\ir
|
||||
```
|
||||
|
||||
After the Model Optimizer script is completed, the produced IR files (`squeezenet1.1.xml`, `squeezenet1.1.bin`) are in the specified `C:\Users\<USER_ID>\Documents\models\public\squeezenet1.1\ir` directory.
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ python3 /opt/intel/openvino_2022/extras/open_model_zoo/tools/downloader/pytorch_
|
|||
```
|
||||
Convert the model from ONNX to the OpenVINO™ Intermediate Representation (IR):
|
||||
```
|
||||
mo_onnx.py \
|
||||
mo \
|
||||
-m mobilenet-v2.onnx \
|
||||
--input=data \
|
||||
--mean_values=data[123.675,116.28,103.53] \
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ The Model Optimizer is a key component of the Intel® Distribution of OpenVINO
|
|||
|
||||
The Inference Engine reads, loads, and infers the IR files, using a common API across the CPU, GPU, or VPU hardware.
|
||||
|
||||
The Model Optimizer is a Python*-based command line tool (`mo.py`), which is located in `C:\Program Files (x86)\Intel\openvino_2022\tools\model_optimizer`. Use this tool on models trained with popular deep learning frameworks such as Caffe\*, TensorFlow\*, MXNet\*, and ONNX\* to convert them to an optimized IR format that the Inference Engine can use.
|
||||
The Model Optimizer is a Python*-based command line tool (`mo`), which is located in `C:\Program Files (x86)\Intel\openvino_2022\tools\model_optimizer`. Use this tool on models trained with popular deep learning frameworks such as Caffe\*, TensorFlow\*, MXNet\*, and ONNX\* to convert them to an optimized IR format that the Inference Engine can use.
|
||||
|
||||
This section explains how to use scripts to configure the Model Optimizer either for all of the supported frameworks at the same time or for individual frameworks. If you want to manually configure the Model Optimizer instead of using scripts, see the **Using Manual Configuration Process** section on the [Configuring the Model Optimizer](../MO_DG/prepare_model/Config_Model_Optimizer.md) page.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,81 +0,0 @@
|
|||
## Prerequisites
|
||||
|
||||
Model Optimizer requires:
|
||||
|
||||
1. Python 3 or newer
|
||||
|
||||
2. [Optional] Please read about use cases that require Caffe\* to be available on the machine in the documentation.
|
||||
|
||||
## Installation instructions
|
||||
|
||||
1. Go to the Model Optimizer folder:
|
||||
<pre>
|
||||
cd PATH_TO_INSTALL_DIR/tools/model_optimizer
|
||||
</pre>
|
||||
|
||||
2. Create virtual environment and activate it. This option is strongly recommended as it creates a Python sandbox and
|
||||
dependencies for the Model Optimizer do not influence global Python configuration, installed libraries etc. At the
|
||||
same time, special flag ensures that system-wide Python libraries are also available in this sandbox. Skip this
|
||||
step only if you do want to install all Model Optimizer dependencies globally:
|
||||
|
||||
* Create environment:
|
||||
<pre>
|
||||
virtualenv -p /usr/bin/python3.6 .env3 --system-site-packages
|
||||
</pre>
|
||||
* Activate it:
|
||||
<pre>
|
||||
. .env3/bin/activate
|
||||
</pre>
|
||||
3. Install dependencies. If you want to convert models only from particular framework, you should use one of
|
||||
available <code>requirements_\*.txt</code> files corresponding to the framework of choice. For example, for Caffe
|
||||
use <code>requirements_caffe.txt</code> and so on. When you decide to switch later to other frameworks, please
|
||||
install dependencies for them using the same mechanism:
|
||||
<pre>
|
||||
pip3 install -r requirements.txt
|
||||
</pre>
|
||||
Or you can use the installation scripts from the "install_prerequisites" directory.
|
||||
|
||||
4. [OPTIONAL] If you use Windows OS, most probably you get python version of `protobuf` library. It is known to be rather slow,
|
||||
and you can use a boosted version of library by building the .egg file (Python package format) yourself,
|
||||
using instructions below (section 'How to boost Caffe model loading') for the target OS and Python, or install it
|
||||
with the pre-built .egg (it is built for Python 3.4, 3.5, 3.6, 3.7):
|
||||
<pre>
|
||||
python3 -m easy_install protobuf-3.6.1-py3.6-win-amd64.egg
|
||||
</pre>
|
||||
|
||||
It overrides the protobuf python package installed by the previous command.
|
||||
|
||||
Set environment variable to enable boost in protobuf performance:
|
||||
<pre>
|
||||
set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp
|
||||
</pre>
|
||||
|
||||
|
||||
## Setup development environment
|
||||
|
||||
### How to run unit-tests
|
||||
|
||||
1. Run tests with:
|
||||
<pre>
|
||||
python -m unittest discover -p "*_test.py" [-s PATH_TO_DIR]
|
||||
</pre>
|
||||
|
||||
### How to capture unit-tests coverage
|
||||
|
||||
1. Run tests with:
|
||||
<pre>
|
||||
coverage run -m unittest discover -p "*_test.py" [-s PATH_TO_DIR]
|
||||
</pre>
|
||||
|
||||
2. Build html report:
|
||||
<pre>
|
||||
coverage html
|
||||
</pre>
|
||||
|
||||
### How to run code linting
|
||||
|
||||
1. Run the following command:
|
||||
<pre>
|
||||
pylint mo/ extensions/ mo.py
|
||||
</pre>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,3 +0,0 @@
|
|||
# Copyright (C) 2018-2021 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
# Copyright (C) 2018-2021 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
# Copyright (C) 2018-2021 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
# Copyright (C) 2018-2021 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
# Copyright (C) 2018-2021 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
# Copyright (C) 2018-2021 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
# Copyright (C) 2018-2021 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
# Copyright (C) 2018-2021 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
|
|
@ -34,9 +34,9 @@ goto :opencv_done
|
|||
:opencv_done
|
||||
|
||||
:: Model Optimizer
|
||||
if exist %INTEL_OPENVINO_DIR%\tools\model_optimizer (
|
||||
set PYTHONPATH=%INTEL_OPENVINO_DIR%\tools\model_optimizer;%PYTHONPATH%
|
||||
set "PATH=%INTEL_OPENVINO_DIR%\tools\model_optimizer;%PATH%"
|
||||
if exist %INTEL_OPENVINO_DIR%\tools\mo (
|
||||
set PYTHONPATH=%INTEL_OPENVINO_DIR%\tools\mo;%PYTHONPATH%
|
||||
set "PATH=%INTEL_OPENVINO_DIR%\tools\mo;%PATH%"
|
||||
)
|
||||
|
||||
:: OpenVINO runtime
|
||||
|
|
|
|||
|
|
@ -72,8 +72,8 @@ if [ -f "$INTEL_OPENVINO_DIR/extras/dl_streamer/setupvars.sh" ]; then
|
|||
source "$INTEL_OPENVINO_DIR/extras/dl_streamer/setupvars.sh"
|
||||
fi
|
||||
|
||||
export PATH="$INTEL_OPENVINO_DIR/tools/model_optimizer${PATH:+:$PATH}"
|
||||
export PYTHONPATH="$INTEL_OPENVINO_DIR/tools/model_optimizer${PYTHONPATH:+:$PYTHONPATH}"
|
||||
export PATH="$INTEL_OPENVINO_DIR/tools/mo${PATH:+:$PATH}"
|
||||
export PYTHONPATH="$INTEL_OPENVINO_DIR/tools/mo${PYTHONPATH:+:$PYTHONPATH}"
|
||||
|
||||
if [ -e "$INTEL_OPENVINO_DIR/tools/post_training_optimization_toolkit" ]; then
|
||||
export PYTHONPATH="$INTEL_OPENVINO_DIR/tools/post_training_optimization_toolkit:$PYTHONPATH"
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ from pathlib import Path
|
|||
import numpy as np
|
||||
from common.constants import test_device, test_precision
|
||||
from common.layer_utils import IEInfer
|
||||
from mo.utils.ir_engine.ir_engine import IREngine
|
||||
from openvino.tools.mo.utils.ir_engine.ir_engine import IREngine
|
||||
|
||||
from common.utils.common_utils import generate_ir
|
||||
from common.utils.parsers import mapping_parser
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import subprocess
|
|||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import mo
|
||||
from openvino.tools.mo import mo
|
||||
import numpy as np
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import re
|
|||
import tensorflow as tf
|
||||
import numpy as np
|
||||
|
||||
from mo.ops.op import PermuteAttrs
|
||||
from openvino.tools.mo.ops.op import PermuteAttrs
|
||||
|
||||
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import pytest
|
|||
|
||||
from common.layer_test_class import check_ir_version
|
||||
from common.onnx_layer_test_class import OnnxRuntimeLayerTest
|
||||
from mo.front.common.partial_infer.utils import int64_array
|
||||
from openvino.tools.mo.front.common.partial_infer.utils import int64_array
|
||||
from unit_tests.utils.graph import build_graph
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ import pytest
|
|||
|
||||
from common.layer_test_class import check_ir_version
|
||||
from common.onnx_layer_test_class import OnnxRuntimeLayerTest
|
||||
from mo.front.common.partial_infer.utils import int64_array
|
||||
from mo.middle.passes.convert_data_type import data_type_str_to_np, np_data_type_to_destination_type
|
||||
from openvino.tools.mo.front.common.partial_infer.utils import int64_array
|
||||
from openvino.tools.mo.middle.passes.convert_data_type import data_type_str_to_np, np_data_type_to_destination_type
|
||||
from unit_tests.utils.graph import build_graph
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import pytest
|
|||
|
||||
from common.layer_test_class import check_ir_version
|
||||
from common.onnx_layer_test_class import OnnxRuntimeLayerTest
|
||||
from mo.front.common.partial_infer.utils import int64_array
|
||||
from openvino.tools.mo.front.common.partial_infer.utils import int64_array
|
||||
from unit_tests.utils.graph import build_graph
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import pytest
|
|||
|
||||
from common.layer_test_class import check_ir_version
|
||||
from common.tf_layer_test_class import CommonTFLayerTest
|
||||
from mo.front.common.partial_infer.utils import int64_array
|
||||
from openvino.tools.mo.front.common.partial_infer.utils import int64_array
|
||||
from unit_tests.utils.graph import build_graph, regular_op_with_shaped_data, connect, \
|
||||
shaped_data, connect_front, regular_op
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import pytest
|
|||
from common.layer_test_class import check_ir_version
|
||||
from common.tf_layer_test_class import CommonTFLayerTest
|
||||
from common.utils.tf_utils import permute_nchw_to_nhwc
|
||||
from mo.front.common.partial_infer.utils import int64_array
|
||||
from openvino.tools.mo.front.common.partial_infer.utils import int64_array
|
||||
from unit_tests.utils.graph import build_graph
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import numpy as np
|
|||
import pytest
|
||||
|
||||
from common.tf_layer_test_class import CommonTFLayerTest
|
||||
from mo.front.common.partial_infer.utils import int64_array
|
||||
from openvino.tools.mo.front.common.partial_infer.utils import int64_array
|
||||
from unit_tests.utils.graph import build_graph
|
||||
from common.utils.tf_utils import permute_nchw_to_nhwc, permute_nchw_to_nhwc
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
import pytest
|
||||
import tensorflow as tf
|
||||
from mo.front.common.partial_infer.utils import int64_array
|
||||
from openvino.tools.mo.front.common.partial_infer.utils import int64_array
|
||||
from unit_tests.utils.graph import build_graph, regular_op_with_shaped_data, connect, \
|
||||
shaped_data, connect_front
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import pytest
|
|||
|
||||
from common.layer_test_class import check_ir_version
|
||||
from common.tf_layer_test_class import CommonTFLayerTest
|
||||
from mo.ops.op import PermuteAttrs
|
||||
from openvino.tools.mo.ops.op import PermuteAttrs
|
||||
from unit_tests.utils.graph import build_graph
|
||||
from common.utils.tf_utils import permute_nchw_to_nhwc, permute_axis
|
||||
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ def main():
|
|||
if not args.no_venv:
|
||||
Venv = VirtualEnv("./.stress_venv")
|
||||
requirements = [
|
||||
args.mo_tool.parent / "requirements.txt",
|
||||
args.mo_tool.parents[3] / "requirements.txt",
|
||||
omz_path / "tools" / "model_tools" / "requirements.in",
|
||||
omz_path / "tools" / "model_tools" / "requirements-caffe2.in",
|
||||
omz_path / "tools" / "model_tools" / "requirements-pytorch.in"
|
||||
|
|
|
|||
|
|
@ -81,6 +81,8 @@ if(ENABLE_PYTHON)
|
|||
EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
|
||||
add_subdirectory(mo)
|
||||
|
||||
# build and install openvino-dev wheel
|
||||
|
||||
if(ENABLE_WHEEL)
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/automation/version.txt.in"
|
|||
# ie_cpack_add_component(model_optimizer)
|
||||
|
||||
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
|
||||
DESTINATION tools/model_optimizer
|
||||
DESTINATION tools/mo
|
||||
USE_SOURCE_PERMISSIONS
|
||||
COMPONENT tests
|
||||
EXCLUDE_FROM_ALL
|
||||
|
|
@ -32,8 +32,8 @@ install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
|
|||
PATTERN "README.md" EXCLUDE
|
||||
PATTERN "CMakeLists.txt" EXCLUDE
|
||||
|
||||
PATTERN "extensions/front/caffe/CustomLayersMapping.xml" EXCLUDE
|
||||
PATTERN "mo/utils/convert.py" EXCLUDE
|
||||
PATTERN "openvino/tools/mo/front/caffe/CustomLayersMapping.xml" EXCLUDE
|
||||
PATTERN "openvino/tools/mo/utils/convert.py" EXCLUDE
|
||||
PATTERN "unit_tests" EXCLUDE
|
||||
PATTERN "openvino_mo.egg-info" EXCLUDE
|
||||
PATTERN "build" EXCLUDE
|
||||
|
|
@ -45,21 +45,21 @@ install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
|
|||
REGEX ".*_test\.py$" EXCLUDE)
|
||||
|
||||
install(FILES requirements_dev.txt
|
||||
DESTINATION tests/model_optimizer
|
||||
DESTINATION tests/mo
|
||||
COMPONENT tests
|
||||
EXCLUDE_FROM_ALL)
|
||||
|
||||
install(DIRECTORY unit_tests
|
||||
DESTINATION tests/model_optimizer
|
||||
DESTINATION tests/mo
|
||||
COMPONENT tests
|
||||
EXCLUDE_FROM_ALL)
|
||||
|
||||
install(DIRECTORY automation
|
||||
DESTINATION tests/model_optimizer
|
||||
DESTINATION tests/mo
|
||||
COMPONENT tests
|
||||
EXCLUDE_FROM_ALL)
|
||||
|
||||
install(FILES .coveragerc
|
||||
DESTINATION tests/model_optimizer
|
||||
DESTINATION tests/mo
|
||||
COMPONENT tests
|
||||
EXCLUDE_FROM_ALL)
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
## Installation
|
||||
|
||||
### Installing from PyPi
|
||||
1. Create a virtual environment and activate it, e.g.:
|
||||
```
|
||||
virtualenv -p /usr/bin/python3.7 .env3
|
||||
source .env3/bin/activate
|
||||
```
|
||||
|
||||
2. Install openvino-dev package, it contains Model Optimizer:
|
||||
```
|
||||
pip install openvino-dev
|
||||
```
|
||||
|
||||
This will download all requirements and will install MO in your current virtual environment.
|
||||
If you need only particular frameworks you can specify them manually as optional dependencies in square brackets.
|
||||
E.g. the command below will install dependencies to support ONNX\* and TensorFlow2\* models:
|
||||
```
|
||||
pip install openvino-dev[onnx,tensorflow2]
|
||||
```
|
||||
To enable support of MxNet\* models run:
|
||||
```
|
||||
pip install openvino-dev[mxnet]
|
||||
```
|
||||
To enable support of all frameworks:
|
||||
```
|
||||
pip install openvino-dev[all]
|
||||
```
|
||||
By default, if no frameworks are specified, dependencies to support ONNX\* and TensorFlow2\* are installed.
|
||||
|
||||
[//]: <> (### Installing wheel package from provided OpenVINO™ offline distribution)
|
||||
[//]: <> (To be done)
|
||||
|
||||
## Converting models
|
||||
* [Converting Model](../../docs/MO_DG/prepare_model/convert_model/Converting_Model.md)
|
||||
|
||||
## Setup development environment
|
||||
If you want to contribute to Model Optimizer you will need to deploy developer environment.
|
||||
You can do that by following the steps below:
|
||||
|
||||
1. Create virtual environment and activate it, e.g.:
|
||||
```
|
||||
virtualenv -p /usr/bin/python3.7 .env3
|
||||
source .env3/bin/activate
|
||||
```
|
||||
|
||||
2. Clone the OpenVINO™ repository and change dir to model-optimizer
|
||||
```
|
||||
git clone https://github.com/openvinotoolkit/openvino
|
||||
cd openvino/tools/mo/
|
||||
```
|
||||
|
||||
3. Install openvino-mo package for development:
|
||||
```
|
||||
pip install -e .
|
||||
```
|
||||
or run `setup.py develop`, result will be the same:
|
||||
```
|
||||
python setup.py develop
|
||||
```
|
||||
|
||||
This will download all requirements and deploy Model Optimizer for development in your virtual environment:
|
||||
specifically will create *.egg-link into the current directory in your site-packages.
|
||||
As previously noted, you can also manually specify to support only selected frameworks :
|
||||
```
|
||||
pip install -e ".[onnx,tensorflow2]"
|
||||
```
|
||||
|
||||
### How to run unit-tests
|
||||
|
||||
1. Run tests with:
|
||||
<pre>
|
||||
python -m unittest discover -p "*_test.py" [-s PATH_TO_DIR]
|
||||
</pre>
|
||||
|
||||
### How to capture unit-tests coverage
|
||||
|
||||
1. Run tests with:
|
||||
<pre>
|
||||
coverage run -m unittest discover -p "*_test.py" [-s PATH_TO_DIR]
|
||||
</pre>
|
||||
|
||||
2. Build html report:
|
||||
<pre>
|
||||
coverage html
|
||||
</pre>
|
||||
|
||||
### How to run code linting
|
||||
|
||||
1. Run the following command:
|
||||
<pre>
|
||||
pylint openvino/tools/mo/ mo.py
|
||||
</pre>
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -89,7 +89,7 @@ python -m pip install -U pip
|
|||
python -m pip install -r "%ROOT_DIR%..\requirements%postfix%.txt"
|
||||
|
||||
:: Chek MO version
|
||||
set python_command='python "%ROOT_DIR%..\mo\utils\extract_release_version.py"'
|
||||
set python_command='python "%ROOT_DIR%..\openvino\tools\mo\utils\extract_release_version.py"'
|
||||
FOR /F "delims=" %%i IN (%python_command%) DO set mo_release_version=%%i
|
||||
IF "%mo_release_version%" == "None.None" (
|
||||
set mo_is_custom="true"
|
||||
|
|
@ -99,7 +99,7 @@ IF "%mo_release_version%" == "None.None" (
|
|||
|
||||
:: Check if existing IE Python bindings satisfy requirements
|
||||
set errorlevel=
|
||||
python "%ROOT_DIR%..\mo\utils\find_ie_version.py"
|
||||
python "%ROOT_DIR%..\openvino\tools\mo\utils\find_ie_version.py"
|
||||
IF %errorlevel% EQU 0 goto ie_search_end
|
||||
|
||||
:: Check if OV already installed via pip
|
||||
|
|
@ -138,7 +138,7 @@ IF %errorlevel% NEQ 0 (
|
|||
)
|
||||
|
||||
set errorlevel=
|
||||
python "%ROOT_DIR%..\mo\utils\find_ie_version.py"
|
||||
python "%ROOT_DIR%..\openvino\tools\mo\utils\find_ie_version.py"
|
||||
IF %errorlevel% EQU 0 goto ie_search_end
|
||||
|
||||
echo [ WARNING ] The installed OpenVINO ^(TM^) toolkit version %mo_release_version% does not work as expected. Uninstalling...
|
||||
|
|
@ -156,7 +156,7 @@ IF %errorlevel% NEQ 0 (
|
|||
)
|
||||
|
||||
set errorlevel=
|
||||
python "%ROOT_DIR%..\mo\utils\find_ie_version.py"
|
||||
python "%ROOT_DIR%..\openvino\tools\mo\utils\find_ie_version.py"
|
||||
IF %errorlevel% EQU 0 goto ie_search_end
|
||||
|
||||
echo [ WARNING ] The installed highest OpenVINO ^(TM^) toolkit version doesn't work as expected. Uninstalling...
|
||||
|
|
@ -83,7 +83,7 @@ uninstall_ov() {
|
|||
}
|
||||
|
||||
check_ie() {
|
||||
$1 "$SCRIPTDIR/../mo/utils/find_ie_version.py"
|
||||
$1 "$SCRIPTDIR/../openvino/tools/mo/utils/find_ie_version.py"
|
||||
}
|
||||
|
||||
check_ov_package() {
|
||||
|
|
@ -104,7 +104,7 @@ find_ie_bindings() {
|
|||
python_executable="$1"
|
||||
requires_sudo="$2"
|
||||
|
||||
mo_release_version="$("$python_executable" "$SCRIPTDIR"/../mo/utils/extract_release_version.py)"
|
||||
mo_release_version="$("$python_executable" "$SCRIPTDIR"/../openvino/tools/mo/utils/extract_release_version.py)"
|
||||
if [[ $mo_release_version == "None.None" ]]; then
|
||||
mo_is_custom=true
|
||||
else
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue