This directory contains scripts that automate certain model-related tasks based on configuration files in the models' directories.
downloader.py
(model downloader) downloads model files from online sources and, if necessary, patches them to make them more usable with Model Optimizer;converter.py
(model converter) converts the models that are not in the Inference Engine IR format into that format using Model Optimizer.info_dumper.py
(model information dumper) prints information about the models in a stable machine-readable format.Please use these tools instead of attempting to parse the configuration files directly. Their format is undocumented and may change in incompatible ways in future releases.
For the model converter, you will also need to install the OpenVINO™ toolkit and the prerequisite libraries for Model Optimizer. See the OpenVINO toolkit documentation for details.
If you using models from PyTorch or Caffe2 framework, you will also need to use intermediate conversion to ONNX format. To use automatic conversion install additional dependencies.
For models from PyTorch:
For models from Caffe2:
When running the model downloader with Python 3.5.x on macOS, you may encounter an error similar to the following:
requests.exceptions.SSLError: [...] (Caused by SSLError(SSLError(1, '[SSL: TLSV1_ALERT_PROTOCOL_VERSION]
tlsv1 alert protocol version (_ssl.c:719)'),))
You can work around this by installing additional packages:
Alternatively, upgrade to Python 3.6 or a later version.
The basic usage is to run the script like this:
This will download all models into a directory tree rooted in the current directory. To download into a different directory, use the -o
/--output_dir
option:
The --all
option can be replaced with other filter options to download only a subset of models. See the "Shared options" section.
You may use --precisions
flag to specify comma separated precisions of weights to be downloaded.
By default, the script will attempt to download each file only once. You can use the --num_attempts
option to change that and increase the robustness of the download process:
You can use the --cache_dir
option to make the script use the specified directory as a cache. The script will place a copy of each downloaded file in the cache, or, if it is already there, retrieve it from the cache instead of downloading it again.
The cache format is intended to remain compatible in future Open Model Zoo versions, so you can use a cache to avoid redownloading most files when updating Open Model Zoo.
By default, the script outputs progress information as unstructured, human-readable text. If you want to consume progress information programmatically, use the --progress_format
option:
When this option is set to json
, the script's standard output is replaced by a machine-readable progress report, whose format is documented in the "JSON progress report format" section. This option does not affect errors and warnings, which will still be printed to the standard error stream in a human-readable format.
You can also set this option to text
to explicitly request the default text format.
See the "Shared options" section for information on other options accepted by the script.
This section documents the format of the progress report produced by the script when the --progress_format=json
option is specified.
The report consists of a sequence of events, where each event is represented by a line containing a JSON-encoded object. Each event has a member with the name $type
whose value determines the type of the event, as well as which additional members it contains.
The following event types are currently defined:
model_download_begin
Additional members: model
(string), num_files
(integer).
The script started downloading the model named by model
. num_files
is the number of files that will be downloaded for this model.
This event will always be followed by a corresponding model_download_end
event.
model_download_end
Additional members: model
(string), successful
(boolean).
The script stopped downloading the model named by model
. successful
is true if every file was downloaded successfully.
model_file_download_begin
Additional members: model
(string), model_file
(string), size
(integer).
The script started downloading the file named by model_file
of the model named by model
. size
is the size of the file in bytes.
This event will always occur between model_download_begin
and model_download_end
events for the model, and will always be followed by a corresponding model_file_download_end
event.
model_file_download_end
Additional members: model
(string), model_file
(string), successful
(boolean).
The script stopped downloading the file named by model_file
of the model named by model
. successful
is true if the file was downloaded successfully.
model_file_download_progress
Additional members: model
(string), model_file
(string), size
(integer).
The script downloaded size
bytes of the file named by model_file
of the model named by model
so far. Note that size
can decrease in a subsequent event if the download is interrupted and retried.
This event will always occur between model_file_download_begin
and model_file_download_end
events for the file.
model_postprocessing_begin
Additional members: model
.
The script started post-download processing on the model named by model
.
This event will always be followed by a corresponding model_postprocessing_end
event.
model_postprocessing_end
Additional members: model
.
The script stopped post-download processing on the model named by model
.
Additional event types and members may be added in the future.
Tools parsing the machine-readable format should avoid relying on undocumented details. In particular:
The basic usage is to run the script like this:
This will convert all models into the Inference Engine IR format. Models that were originally in that format are ignored. Models in PyTorch and Caffe2 formats will be converted in ONNX format first.
The current directory must be the root of a download tree created by the model downloader. To specify a different download tree path, use the -d
/--download_dir
option:
By default, the converted models are placed into the download tree. To place them into a different directory tree, use the -o
/--output_dir
option:
>Note: models in intermediate format are placed to this directory too.
The --all
option can be replaced with other filter options to convert only a subset of models. See the "Shared options" section.
By default, the script will produce models in every precision that is supported for conversion. To only produce models in a specific precision, use the --precisions
option:
If the specified precision is not supported for a model, that model will be skipped.
The script will attempt to locate Model Optimizer using the environment variables set by the OpenVINO™ toolkit's setupvars.sh
/setupvars.bat
script. You can override this heuristic with the --mo
option:
You can add extra Model Optimizer arguments to the ones specified in the model configuration by using the --add-mo-arg
option. The option can be repeated to add multiple arguments:
By default, the script will run Model Optimizer using the same Python executable that was used to run the script itself. To use a different Python executable, use the -p
/--python
option:
The script can run multiple conversion commands concurrently. To enable this, use the -j
/--jobs
option:
The argument to the option must be either a maximum number of concurrently executed commands, or "auto", in which case the number of CPUs in the system is used. By default, all commands are run sequentially.
The script can print the conversion commands without actually running them. To do this, use the --dry-run
option:
See the "Shared options" section for information on other options accepted by the script.
The basic usage is to run the script like this:
This will print to standard output information about all models.
The only options accepted by the script are those described in the "Shared options" section.
The script's output is a JSON array, each element of which is a JSON object describing a single model. Each such object has the following keys:
name
: the identifier of the model, as accepted by the --name
option.description
: text describing the model. Paragraphs are separated by line feed characters.framework
: a string identifying the framework whose format the model is downloaded in. Current possible values are dldt
(Inference Engine IR), caffe
, caffe2
, mxnet
, onnx
, pytorch
and tf
(TensorFlow). Additional possible values might be added in the future.license_url
: an URL for the license that the model is distributed under.precisions
: the list of precisions that the model has IR files for. For models downloaded in a format other than the Inference Engine IR format, these are the precisions that the model converter can produce IR files in. Current possible values are:
FP16
FP16-INT1
FP16-INT8
FP32
FP32-INT1
FP32-INT8
INT1
INT8
Additional possible values might be added in the future.
subdirectory
: the subdirectory of the output tree into which the downloaded or converted files will be placed by the downloader or the converter, respectively.task_type
: a string identifying the type of task that the model performs. Current possible values are:
action_recognition
classification
detection
face_recognition
feature_extraction
head_pose_estimation
human_pose_estimation
image_processing
instance_segmentation
object_attributes
optical_character_recognition
semantic_segmentation
Additional possible values might be added in the future.
The are certain options that both tools accept.
-h
/--help
can be used to print a help message:
There are several mutually exclusive filter options that select the models the tool will process:
--all
selects all models.--name
takes a comma-separated list of patterns and selects models that match at least one of these patterns. The patterns may contain shell-style wildcards.See https://docs.python.org/3/library/fnmatch.html for a full description of the pattern syntax.
--list
takes a path to a file that must contain a list of patterns and selects models that match at least one of those patterns.The file must contain one pattern per line. The pattern syntax is the same as for the --name
option. Blank lines and comments starting with #
are ignored. For example:
To see the available models, you can use the --print_all
option. When this option is specified, the tool will print all model names defined in the configuration file and exit:
Either --print_all
or one of the filter options must be specified.
In earlier releases, the tools used a single configuration file instead of per-model configuration files. For compatibility, loading such a file is still supported. However, this feature is deprecated and will be removed in a future release.
To load a configuration file in the old format, use the -c
/--config
option:
OpenVINO is a trademark of Intel Corporation or its subsidiaries in the U.S. and/or other countries.
Copyright © 2018-2019 Intel Corporation
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.