Files
openvino/model-optimizer
Tomasz Dołbniak b5f0ca5d10 Offline transformations exposed to python with pybind11 (#7987)
* New approach to offline transformations

* Include paths fix

* Imports fix

* offline_transformations target dependency simplification

* MakeStatefulTransformation exposed to python

* Python bindings build configuration fix

* Test variable name refactor

* Stop crying (snow)flake

* Snake cased offline transformations API

* Removal of old offline transformations from python

* Imports adaptation to new code style

* offline_transformations as a part of the common wheel

* Cmake simplification and refactor

* Correct transform invocation

* CI fix

* Proper dependency check in MO

* _pyngraph as a dependency of MO in cmake

* IR serialization fix in MO

* POT adaptation to the new API

* Revert "Removal of old offline transformations from python"

This reverts commit f9a0551ead.

* Merge of old& new bindings for offline_transformations

* Revert "POT adaptation to the new API"

This reverts commit 499554e68c.

* Obsolete cmake line removal

* Missing comma and merge conflict fix

* Offline transformations tests fix

* IE imports removal from check_ie_bindings

* Installation of opevino/__init__.py fix

* Obsolete line removal

* MO serialization switched to the new API

* Revert of preliminary MO adaptation to the new API

* Another magic spell that will hopefully make CI pass

* Python api cmake dependencies reorg

* Temporary solution for the CI/cpack errors

* Installation fix and code formatting

* ie_api & pyopenvino dependency removal

* Explicit cpack configuration for the new API

* cpack configuration adaptation

* Revert of obsolete cpack changes

Co-authored-by: Alexander Zhogov <alexander.zhogov@intel.com>
2021-11-03 20:00:14 +03:00
..
2021-03-22 19:35:32 +03:00
2020-04-15 21:46:27 +03:00
2021-09-15 16:49:11 +03:00
2021-07-22 21:12:44 +03:00

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:
    cd PATH_TO_INSTALL_DIR/tools/model_optimizer
  1. 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:
          virtualenv -p /usr/bin/python3.6 .env3 --system-site-packages
        
    • Activate it:
        . .env3/bin/activate
      
  2. Install dependencies. If you want to convert models only from particular framework, you should use one of available requirements_*.txt files corresponding to the framework of choice. For example, for Caffe use requirements_caffe.txt and so on. When you decide to switch later to other frameworks, please install dependencies for them using the same mechanism:

    pip3 install -r requirements.txt
    

    Or you can use the installation scripts from the "install_prerequisites" directory.

  3. [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):

         python3 -m easy_install protobuf-3.6.1-py3.6-win-amd64.egg
    

    It overrides the protobuf python package installed by the previous command.

    Set environment variable to enable boost in protobuf performance:

         set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp
    

Setup development environment

How to run unit-tests

  1. Run tests with:
    python -m unittest discover -p "*_test.py" [-s PATH_TO_DIR]

How to capture unit-tests coverage

  1. Run tests with:
    coverage run -m unittest discover -p "*_test.py" [-s PATH_TO_DIR]
  1. Build html report:
    coverage html

How to run code linting

  1. Run the following command:
    pylint mo/ extensions/ mo.py