Modified samples to support ONNX models (#1680)
authorMikhail Ryzhov <mikhail.ryzhov@intel.com>
Wed, 26 Aug 2020 15:53:24 +0000 (18:53 +0300)
committerGitHub <noreply@github.com>
Wed, 26 Aug 2020 15:53:24 +0000 (18:53 +0300)
* Modified samples to support ONNX models

- Removed manual loading of IR .bin files (hello_classification, object_detection_sample_ssd)
- Corrected comments
- Added Note in README files

* Modified samples to support ONNX models

- Removed manual loading of IR .bin files (hello_classification, object_detection_sample_ssd)
- Corrected comments
- Added Note in README files

15 files changed:
inference-engine/samples/benchmark_app/README.md
inference-engine/samples/classification_sample_async/README.md
inference-engine/samples/classification_sample_async/main.cpp
inference-engine/samples/hello_classification/README.md
inference-engine/samples/hello_classification/main.cpp
inference-engine/samples/hello_nv12_input_classification/README.md
inference-engine/samples/hello_nv12_input_classification/main.cpp
inference-engine/samples/hello_reshape_ssd/README.md
inference-engine/samples/hello_reshape_ssd/main.cpp
inference-engine/samples/object_detection_sample_ssd/README.md
inference-engine/samples/object_detection_sample_ssd/main.cpp
inference-engine/samples/speech_sample/README.md
inference-engine/samples/speech_sample/main.cpp
inference-engine/samples/style_transfer_sample/README.md
inference-engine/samples/style_transfer_sample/main.cpp

index b90c5b4..65d2530 100644 (file)
@@ -116,6 +116,8 @@ If a model has mixed input types, input folder should contain all required files
 To run the tool, you can use public or Intel's pre-trained models. To download the models, use the OpenVINO [Model Downloader](@ref omz_tools_downloader_README) or go to [https://download.01.org/opencv/](https://download.01.org/opencv/).
 
 > **NOTE**: Before running the tool with a trained model, make sure the model is converted to the Inference Engine format (\*.xml + \*.bin) using the [Model Optimizer tool](../../../docs/MO_DG/Deep_Learning_Model_Optimizer_DevGuide.md).
+> 
+> The sample accepts models in ONNX format (.onnx) that do not require preprocessing.
 
 ## Examples of Running the Tool
 
@@ -183,4 +185,4 @@ Below are fragments of sample output for CPU and FPGA devices:
 ## See Also
 * [Using Inference Engine Samples](../../../docs/IE_DG/Samples_Overview.md)
 * [Model Optimizer](../../../docs/MO_DG/Deep_Learning_Model_Optimizer_DevGuide.md)
-* [Model Downloader](@ref omz_tools_downloader_README)
\ No newline at end of file
+* [Model Downloader](@ref omz_tools_downloader_README)
index f41d009..4d87920 100644 (file)
@@ -52,6 +52,8 @@ Running the application with the empty list of options yields the usage message
 To run the sample, use AlexNet and GoogLeNet or other public or pre-trained image classification models. To download the pre-trained models, use the OpenVINO [Model Downloader](@ref omz_tools_downloader_README) or go to [https://download.01.org/opencv/](https://download.01.org/opencv/).
 
 > **NOTE**: Before running the sample with a trained model, make sure the model is converted to the Inference Engine format (\*.xml + \*.bin) using the [Model Optimizer tool](../../../docs/MO_DG/Deep_Learning_Model_Optimizer_DevGuide.md).
+> 
+> The sample accepts models in ONNX format (.onnx) that do not require preprocessing.
 
 You can do inference of an image using a trained AlexNet network on FPGA with fallback to CPU using the following command:
 ```sh
index c761eae..b8cf5a0 100644 (file)
@@ -90,7 +90,7 @@ int main(int argc, char *argv[]) {
         std::cout << ie.GetVersions(FLAGS_d) << std::endl;
         // -----------------------------------------------------------------------------------------------------
 
-        // --------------------------- 2. Read IR Generated by ModelOptimizer (.xml and .bin files) ------------
+        // 2. Read a model in OpenVINO Intermediate Representation (.xml and .bin files) or ONNX (.onnx file) format
         slog::info << "Loading network files" << slog::endl;
 
         /** Read network model **/
index 5f744f1..f390cf9 100644 (file)
@@ -22,7 +22,9 @@ Refer to [Integrate the Inference Engine New Request API with Your Application](
 To run the sample, you can use public or pre-trained models. To download the pre-trained models, use the OpenVINO [Model Downloader](@ref omz_tools_downloader_README) or go to [https://download.01.org/opencv/](https://download.01.org/opencv/).
 
 > **NOTE**: Before running the sample with a trained model, make sure the model is converted to the Inference Engine format (\*.xml + \*.bin) using the [Model Optimizer tool](../../../docs/MO_DG/Deep_Learning_Model_Optimizer_DevGuide.md).
-
+>
+> The sample accepts models in ONNX format (.onnx) that do not require preprocessing.
 You can do inference of an image using a trained AlexNet network on a GPU using the following command:
 ```sh
 ./hello_classification <path_to_model>/alexnet_fp32.xml <path_to_image>/cat.bmp GPU
index 1e2190b..974aa0d 100644 (file)
@@ -16,13 +16,11 @@ using namespace InferenceEngine;
 #if defined(ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32)
 #define tcout std::wcout
 #define file_name_t std::wstring
-#define WEIGHTS_EXT L".bin"
 #define imread_t imreadW
 #define ClassificationResult_t ClassificationResultW
 #else
 #define tcout std::cout
 #define file_name_t std::string
-#define WEIGHTS_EXT ".bin"
 #define imread_t cv::imread
 #define ClassificationResult_t ClassificationResult
 #endif
@@ -86,8 +84,8 @@ int main(int argc, char *argv[]) {
         Core ie;
         // -----------------------------------------------------------------------------------------------------
 
-        // --------------------------- 2. Read IR Generated by ModelOptimizer (.xml and .bin files) ------------
-        CNNNetwork network = ie.ReadNetwork(input_model, input_model.substr(0, input_model.size() - 4) + WEIGHTS_EXT);
+        // 2. Read a model in OpenVINO Intermediate Representation (.xml and .bin files) or ONNX (.onnx file) format
+        CNNNetwork network = ie.ReadNetwork(input_model);
         network.setBatchSize(1);
         // -----------------------------------------------------------------------------------------------------
 
index 3986bcb..b80a5a8 100644 (file)
@@ -41,6 +41,8 @@ or go to [https://download.01.org/opencv/](https://download.01.org/opencv/).
 
 > **NOTE**: Before running the sample with a trained model, make sure the model is converted to the
 > Inference Engine format (\*.xml + \*.bin) using the [Model Optimizer tool](../../../docs/MO_DG/Deep_Learning_Model_Optimizer_DevGuide.md).
+>
+> The sample accepts models in ONNX format (.onnx) that do not require preprocessing. 
 
 You can perform inference on an NV12 image using a trained AlexNet network on CPU with the following command:
 ```sh
index 3e9f7c9..9eafbaf 100644 (file)
@@ -112,7 +112,7 @@ int main(int argc, char *argv[]) {
         Core ie;
         // -----------------------------------------------------------------------------------------------------
 
-        // -------------------------- 2. Read the IR generated by the Model Optimizer (.xml and .bin files) ----
+        // 2. Read a model in OpenVINO Intermediate Representation (.xml and .bin files) or ONNX (.onnx file) format
         CNNNetwork network = ie.ReadNetwork(input_model);
         setBatchSize(network, 1);
         // -----------------------------------------------------------------------------------------------------
index c9291a8..ae14ddc 100644 (file)
@@ -10,6 +10,8 @@ networks like SSD-VGG. The sample shows how to use [Shape Inference feature](../
 To run the sample, you can use public or pre-trained models. To download the pre-trained models, use the OpenVINO [Model Downloader](@ref omz_tools_downloader_README) or go to [https://download.01.org/opencv/](https://download.01.org/opencv/).
 
 > **NOTE**: Before running the sample with a trained model, make sure the model is converted to the Inference Engine format (\*.xml + \*.bin) using the [Model Optimizer tool](../../../docs/MO_DG/Deep_Learning_Model_Optimizer_DevGuide.md).
+>
+> The sample accepts models in ONNX format (.onnx) that do not require preprocessing.
 
 You can use the following command to do inference on CPU of an image using a trained SSD network:
 ```sh
index cba1d81..ef28ece 100644 (file)
@@ -40,7 +40,7 @@ int main(int argc, char* argv[]) {
         }
         // -----------------------------------------------------------------------------------------------------
 
-        // --------------------------- 2. Read IR Generated by ModelOptimizer (.xml and .bin files) ------------
+        // 2. Read a model in OpenVINO Intermediate Representation (.xml and .bin files) or ONNX (.onnx file) format
         CNNNetwork network = ie.ReadNetwork(input_model);
 
         OutputsDataMap outputs_info(network.getOutputsInfo());
index a6acae7..9ce4460 100644 (file)
@@ -39,6 +39,8 @@ Running the application with the empty list of options yields the usage message
 To run the sample, you can use public or pre-trained models. To download the pre-trained models, use the OpenVINO [Model Downloader](@ref omz_tools_downloader_README) or go to [https://download.01.org/opencv/](https://download.01.org/opencv/).
 
 > **NOTE**: Before running the sample with a trained model, make sure the model is converted to the Inference Engine format (\*.xml + \*.bin) using the [Model Optimizer tool](../../../docs/MO_DG/Deep_Learning_Model_Optimizer_DevGuide.md).
+>
+> The sample accepts models in ONNX format (.onnx) that do not require preprocessing.
 
 For example, to do inference on a CPU with the OpenVINO&trade; toolkit person detection SSD models, run one of the following commands:
 
index f3ea08a..382e007 100644 (file)
@@ -97,11 +97,9 @@ int main(int argc, char *argv[]) {
         }
         // -----------------------------------------------------------------------------------------------------
 
-        // --------------------------- 4. Read IR Generated by ModelOptimizer (.xml and .bin files) ------------
-        std::string binFileName = fileNameNoExt(FLAGS_m) + ".bin";
+        // 4. Read a model in OpenVINO Intermediate Representation (.xml and .bin files) or ONNX (.onnx file) format
         slog::info << "Loading network files:"
             "\n\t" << FLAGS_m <<
-            "\n\t" << binFileName <<
             slog::endl;
 
         /** Read network model **/
index cec758f..1dee4af 100644 (file)
@@ -155,6 +155,8 @@ feature file (`wsj_dnn5b_smbr_dev93_10.ark`) are assumed to be available
 for comparison.
 
 > **NOTE**: Before running the sample with a trained model, make sure the model is converted to the Inference Engine format (\*.xml + \*.bin) using the [Model Optimizer tool](../../../docs/MO_DG/Deep_Learning_Model_Optimizer_DevGuide.md).
+>
+> The sample accepts models in ONNX format (.onnx) that do not require preprocessing.
 
 ## Sample Output
 
index 36b4054..2ae1be9 100644 (file)
@@ -567,7 +567,7 @@ int main(int argc, char *argv[]) {
         std::cout << ie.GetVersions(deviceStr) << std::endl;
         // -----------------------------------------------------------------------------------------------------
 
-        // --------------------------- 2. Read IR Generated by ModelOptimizer (.xml and .bin files) ------------
+        // 2. Read a model in OpenVINO Intermediate Representation (.xml and .bin files) or ONNX (.onnx file) format
         slog::info << "Loading network files" << slog::endl;
 
         CNNNetwork network;
index 73f13a0..ae1bb42 100644 (file)
@@ -4,6 +4,8 @@ This topic demonstrates how to run the Neural Style Transfer sample application,
 inference of style transfer models.
 
 > **NOTE**: The OpenVINO™ toolkit does not include a pre-trained model to run the Neural Style Transfer sample. A public model from the [Zhaw's Neural Style Transfer repository](https://github.com/zhaw/neural_style) can be used. Read the [Converting a Style Transfer Model from MXNet*](../../../docs/MO_DG/prepare_model/convert_model/mxnet_specific/Convert_Style_Transfer_From_MXNet.md) topic from the [Model Optimizer Developer Guide](../../../docs/MO_DG/Deep_Learning_Model_Optimizer_DevGuide.md) to learn about how to get the trained model and how to convert it to the Inference Engine format (\*.xml + \*.bin).
+> 
+> The sample accepts models in ONNX format (.onnx) that do not require preprocessing.
 
 > **NOTE**: By default, Inference Engine samples and demos expect input with BGR channels order. If you trained your model to work with RGB order, you need to manually rearrange the default channels order in the sample or demo application or reconvert your model using the Model Optimizer tool with `--reverse_input_channels` argument specified. For more information about the argument, refer to **When to Reverse Input Channels** section of [Converting a Model Using General Conversion Parameters](../../../docs/MO_DG/prepare_model/convert_model/Converting_Model_General.md).
 
index 0e2da0c..cc37023 100644 (file)
@@ -79,7 +79,7 @@ int main(int argc, char *argv[]) {
         }
         // -----------------------------------------------------------------------------------------------------
 
-        // --------------------------- 2. Read IR Generated by ModelOptimizer (.xml and .bin files) ------------
+        // 2. Read a model in OpenVINO Intermediate Representation (.xml and .bin files) or ONNX (.onnx file) format
         slog::info << "Loading network files" << slog::endl;
 
         /** Read network model **/