Modified samples to support ONNX models (#1680)
* 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
This commit is contained in:
1 parent
6a0f3e5efa
commit
7859aab4b0
15 files changed
+26
-14
No files matched your search
@@ -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)
|
||||
* [Model Downloader](@ref omz_tools_downloader_README)
|
||||
@@ -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
|
||||
|
||||
@@ -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 **/
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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™ toolkit person detection SSD models, run one of the following commands:
|
||||
|
||||
|
||||
@@ -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 **/
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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).
|
||||
|
||||
|
||||
@@ -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 **/
|
||||
|
||||
Reference in new issue
Block a user