Merge remote-tracking branch 'github/master' into auto-batch-master
# Conflicts: # inference-engine/src/CMakeLists.txt # inference-engine/tests/functional/plugin/conformance/test_runner/api_conformance_runner/include/api_conformance_helpers.hpp
This commit is contained in:
commit
d328835222
@ -88,7 +88,7 @@ jobs:
|
||||
rm -rf $(BUILD_SAMPLES_DIR) ; mkdir $(BUILD_SAMPLES_DIR)
|
||||
sudo rm -rf $(TMP_DIR) ; sudo mkdir $(TMP_DIR) ; sudo chmod 777 -R $(TMP_DIR)
|
||||
sudo mkdir -p $(SHARE_DIR)
|
||||
sudo apt --assume-yes update && sudo apt --assume-yes install nfs-common
|
||||
sudo apt --assume-yes install nfs-common
|
||||
sudo mount -vvv -t nfs cinfsshare.file.core.windows.net:/cinfsshare/onnxtestdata $(SHARE_DIR) -o vers=4,minorversion=1,sec=sys
|
||||
mkdir -p $(CCACHE_DIR)
|
||||
displayName: 'Make dir'
|
||||
@ -147,7 +147,7 @@ jobs:
|
||||
-DCMAKE_BUILD_TYPE=$(BUILD_TYPE)
|
||||
-DENABLE_PYTHON=ON
|
||||
-DBUILD_SHARED_LIBS=$(CMAKE_BUILD_SHARED_LIBS)
|
||||
-DENABLE_GNA=$(CMAKE_BUILD_SHARED_LIBS)
|
||||
-DENABLE_INTEL_GNA=$(CMAKE_BUILD_SHARED_LIBS)
|
||||
-DENABLE_ONEDNN_FOR_GPU=$(CMAKE_BUILD_SHARED_LIBS)
|
||||
-DPYTHON_EXECUTABLE=/usr/bin/python3.8
|
||||
-DENABLE_WHEEL=ON
|
||||
|
@ -93,7 +93,7 @@ jobs:
|
||||
-DENABLE_PYTHON=ON
|
||||
-DPYTHON_EXECUTABLE=/usr/bin/python3.8
|
||||
-DENABLE_VPU=OFF
|
||||
-DENABLE_GNA=OFF
|
||||
-DENABLE_INTEL_GNA=OFF
|
||||
-DENABLE_OPENCV=OFF
|
||||
-DENABLE_CPPLINT=OFF
|
||||
-DENABLE_TESTS=OFF
|
||||
|
@ -132,7 +132,7 @@ jobs:
|
||||
|
||||
- script: |
|
||||
set PATH=$(WORK_DIR)\ninja-win;%PATH%
|
||||
call "$(MSVS_VARS_PATH)" && $(CMAKE_CMD) -G "Ninja Multi-Config" -DENABLE_ONEDNN_FOR_GPU=OFF -DENABLE_GNA=$(CMAKE_BUILD_SHARED_LIBS) -DENABLE_INTEL_GPU=$(CMAKE_BUILD_SHARED_LIBS) -DENABLE_GAPI_PREPROCESSING=$(CMAKE_BUILD_SHARED_LIBS) -DBUILD_SHARED_LIBS=$(CMAKE_BUILD_SHARED_LIBS) -DENABLE_REQUIREMENTS_INSTALL=OFF -DENABLE_FASTER_BUILD=ON -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DENABLE_TESTS=ON -DENABLE_STRICT_DEPENDENCIES=OFF -DENABLE_PYTHON=ON -DPYTHON_EXECUTABLE="C:\hostedtoolcache\windows\Python\3.7.6\x64\python.exe" -DPYTHON_INCLUDE_DIR="C:\hostedtoolcache\windows\Python\3.7.6\x64\include" -DPYTHON_LIBRARY="C:\hostedtoolcache\windows\Python\3.7.6\x64\libs\python37.lib" -DIE_EXTRA_MODULES=$(OPENVINO_CONTRIB_REPO_DIR)\modules -DCMAKE_C_COMPILER:PATH="$(MSVC_COMPILER_PATH)" -DCMAKE_CXX_COMPILER:PATH="$(MSVC_COMPILER_PATH)" $(REPO_DIR)
|
||||
call "$(MSVS_VARS_PATH)" && $(CMAKE_CMD) -G "Ninja Multi-Config" -DENABLE_ONEDNN_FOR_GPU=OFF -DENABLE_INTEL_GNA=$(CMAKE_BUILD_SHARED_LIBS) -DENABLE_INTEL_GPU=$(CMAKE_BUILD_SHARED_LIBS) -DENABLE_GAPI_PREPROCESSING=$(CMAKE_BUILD_SHARED_LIBS) -DBUILD_SHARED_LIBS=$(CMAKE_BUILD_SHARED_LIBS) -DENABLE_REQUIREMENTS_INSTALL=OFF -DENABLE_FASTER_BUILD=ON -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DENABLE_TESTS=ON -DENABLE_STRICT_DEPENDENCIES=OFF -DENABLE_PYTHON=ON -DPYTHON_EXECUTABLE="C:\hostedtoolcache\windows\Python\3.7.6\x64\python.exe" -DPYTHON_INCLUDE_DIR="C:\hostedtoolcache\windows\Python\3.7.6\x64\include" -DPYTHON_LIBRARY="C:\hostedtoolcache\windows\Python\3.7.6\x64\libs\python37.lib" -DIE_EXTRA_MODULES=$(OPENVINO_CONTRIB_REPO_DIR)\modules -DCMAKE_C_COMPILER:PATH="$(MSVC_COMPILER_PATH)" -DCMAKE_CXX_COMPILER:PATH="$(MSVC_COMPILER_PATH)" $(REPO_DIR)
|
||||
workingDirectory: $(BUILD_DIR)
|
||||
displayName: 'CMake'
|
||||
|
||||
|
@ -56,7 +56,7 @@ WORKDIR /openvino/build
|
||||
RUN cmake .. \
|
||||
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
|
||||
-DENABLE_VPU=OFF \
|
||||
-DENABLE_GNA=OFF \
|
||||
-DENABLE_INTEL_GNA=OFF \
|
||||
-DENABLE_OPENCV=OFF \
|
||||
-DENABLE_CPPLINT=OFF \
|
||||
-DENABLE_TESTS=OFF \
|
||||
|
@ -49,7 +49,7 @@ azure-pipelines.yml @openvinotoolkit/openvino-admins
|
||||
/inference-engine/scripts/run_tests_myriad_multistick.sh @openvinotoolkit/openvino-ie-vpu-maintainers
|
||||
|
||||
# IE GNA:
|
||||
/inference-engine/src/gna_plugin/ @openvinotoolkit/openvino-ie-gna-maintainers
|
||||
/src/plugins/intel_gna/ @openvinotoolkit/openvino-ie-gna-maintainers
|
||||
/src/inference/include/ie/gna/ @openvinotoolkit/openvino-ie-gna-maintainers
|
||||
|
||||
# IE MULTI:
|
||||
|
@ -28,9 +28,9 @@ ie_coverage_extract(INPUT "openvino" OUTPUT "ov_hetero_plugin"
|
||||
ie_coverage_genhtml(INFO_FILE "ov_hetero_plugin"
|
||||
PREFIX "${OV_COVERAGE_BASE_DIRECTORY}")
|
||||
|
||||
ie_coverage_extract(INPUT "openvino" OUTPUT "multi_device"
|
||||
PATTERNS "${OV_COVERAGE_BASE_DIRECTORY}/inference-engine/src/multi_device/*")
|
||||
ie_coverage_genhtml(INFO_FILE "multi_device"
|
||||
ie_coverage_extract(INPUT "openvino" OUTPUT "ov_auto_plugin"
|
||||
PATTERNS "${OV_COVERAGE_BASE_DIRECTORY}/src/plugins/auto/*")
|
||||
ie_coverage_genhtml(INFO_FILE "ov_auto_plugin"
|
||||
PREFIX "${OV_COVERAGE_BASE_DIRECTORY}")
|
||||
|
||||
ie_coverage_extract(INPUT "openvino" OUTPUT "preprocessing"
|
||||
@ -72,10 +72,10 @@ if (ENABLE_INTEL_GPU)
|
||||
PREFIX "${OV_COVERAGE_BASE_DIRECTORY}")
|
||||
endif()
|
||||
|
||||
if(ENABLE_GNA)
|
||||
ie_coverage_extract(INPUT "openvino" OUTPUT "gna_plugin"
|
||||
PATTERNS "${OV_COVERAGE_BASE_DIRECTORY}/inference-engine/src/gna_plugin/*")
|
||||
ie_coverage_genhtml(INFO_FILE "gna_plugin"
|
||||
if(ENABLE_INTEL_GNA)
|
||||
ie_coverage_extract(INPUT "openvino" OUTPUT "ov_intel_gna_plugin"
|
||||
PATTERNS "${OV_COVERAGE_BASE_DIRECTORY}/src/plugins/intel_gna/*")
|
||||
ie_coverage_genhtml(INFO_FILE "ov_intel_gna_plugin"
|
||||
PREFIX "${OV_COVERAGE_BASE_DIRECTORY}")
|
||||
endif()
|
||||
|
||||
|
@ -84,10 +84,10 @@ if(THREADING STREQUAL "OMP")
|
||||
endif()
|
||||
update_deps_cache(OMP "${OMP}" "Path to OMP root folder")
|
||||
debug_message(STATUS "intel_omp=" ${OMP})
|
||||
|
||||
|
||||
ie_cpack_add_component(omp REQUIRED)
|
||||
file(GLOB_RECURSE source_list "${OMP}/*${CMAKE_SHARED_LIBRARY_SUFFIX}*")
|
||||
install(FILES ${source_list}
|
||||
install(FILES ${source_list}
|
||||
DESTINATION "runtime/3rdparty/omp/lib"
|
||||
COMPONENT omp)
|
||||
endif()
|
||||
@ -267,7 +267,7 @@ endif()
|
||||
|
||||
include(${OpenVINO_SOURCE_DIR}/cmake/ie_parallel.cmake)
|
||||
|
||||
if(ENABLE_GNA)
|
||||
if(ENABLE_INTEL_GNA)
|
||||
reset_deps_cache(
|
||||
GNA
|
||||
GNA_PLATFORM_DIR
|
||||
@ -297,7 +297,7 @@ if(ENABLE_GNA)
|
||||
else()
|
||||
LIST(APPEND FILES_TO_EXTRACT_LIST gna_${GNA_VERSION}/linux)
|
||||
endif()
|
||||
|
||||
|
||||
RESOLVE_DEPENDENCY(GNA
|
||||
ARCHIVE_UNIFIED "GNA/GNA_${GNA_VERSION}.zip"
|
||||
TARGET_PATH "${TEMP}/gna_${GNA_VERSION}"
|
||||
|
@ -129,7 +129,7 @@ set(IE_DEBUG_POSTFIX_WIN "d")
|
||||
set(IE_RELEASE_POSTFIX_WIN "")
|
||||
set(IE_DEBUG_POSTFIX_LIN "")
|
||||
set(IE_RELEASE_POSTFIX_LIN "")
|
||||
set(IE_DEBUG_POSTFIX_MAC "d")
|
||||
set(IE_DEBUG_POSTFIX_MAC "")
|
||||
set(IE_RELEASE_POSTFIX_MAC "")
|
||||
|
||||
if(WIN32)
|
||||
|
@ -59,8 +59,6 @@ cmake_dependent_option (ENABLE_WHEEL "Build wheel packages for PyPi" OFF
|
||||
# Inference Engine specific options
|
||||
#
|
||||
|
||||
ie_dependent_option (ENABLE_GNA "GNA support for inference engine" ON "NOT APPLE;NOT ANDROID;X86_64" OFF)
|
||||
|
||||
# "MKL-DNN library based on OMP or TBB or Sequential implementation: TBB|OMP|SEQ"
|
||||
if(X86 OR ARM OR (MSVC AND (ARM OR AARCH64)) )
|
||||
set(THREADING_DEFAULT "SEQ")
|
||||
@ -86,7 +84,10 @@ endif()
|
||||
|
||||
ie_dependent_option (ENABLE_TBBBIND_2_5 "Enable TBBBind_2_5 static usage in OpenVINO runtime" ON "ENABLE_TBBBIND_2_5_DEFAULT" OFF)
|
||||
|
||||
if (ENABLE_GNA)
|
||||
ie_dependent_option (ENABLE_INTEL_GNA "GNA support for inference engine" ON
|
||||
"NOT APPLE;NOT ANDROID;X86_64;CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 5.4" OFF)
|
||||
|
||||
if (ENABLE_INTEL_GNA)
|
||||
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.4)
|
||||
set (DEFAULT_GNA_LIB GNA1)
|
||||
else()
|
||||
@ -112,7 +113,8 @@ ie_option (ENABLE_IR_V7_READER "Enables IR v7 reader" ${ENABLE_IR_V7_READER_DEFA
|
||||
|
||||
ie_option (ENABLE_GAPI_PREPROCESSING "Enables G-API preprocessing" ON)
|
||||
|
||||
ie_option (ENABLE_MULTI "Enables Multi Device Plugin" ON)
|
||||
ie_option (ENABLE_MULTI "Enables MULTI Device Plugin" ON)
|
||||
ie_option (ENABLE_AUTO "Enables AUTO Device Plugin" ON)
|
||||
|
||||
ie_option (ENABLE_BATCH "Enables Auto-Batching Plugin" ON)
|
||||
|
||||
@ -211,8 +213,8 @@ if (ENABLE_MKL_DNN)
|
||||
add_definitions(-DENABLE_MKL_DNN=1)
|
||||
endif()
|
||||
|
||||
if (ENABLE_GNA)
|
||||
add_definitions(-DENABLE_GNA)
|
||||
if (ENABLE_INTEL_GNA)
|
||||
add_definitions(-DENABLE_INTEL_GNA)
|
||||
|
||||
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.4)
|
||||
message(WARNING "${GNA_LIBRARY_VERSION} is not supported on GCC version ${CMAKE_CXX_COMPILER_VERSION}. Fallback to GNA1")
|
||||
|
@ -69,9 +69,10 @@ The table below shows the plugin libraries and additional dependencies for Linux
|
||||
| GPU | `libov_intel_gpu_plugin.so` | `libinference_engine_lp_transformations.so`, `libOpenCL.so` | `ov_intel_gpu_plugin.dll` | `OpenCL.dll`, `inference_engine_lp_transformations.dll` | Is not supported | - |
|
||||
| MYRIAD | `libmyriadPlugin.so` | `libusb.so`, | `myriadPlugin.dll` | `usb.dll` | `libmyriadPlugin.so` | `libusb.dylib` |
|
||||
| HDDL | `libHDDLPlugin.so` | `libbsl.so`, `libhddlapi.so`, `libmvnc-hddl.so` | `HDDLPlugin.dll` | `bsl.dll`, `hddlapi.dll`, `json-c.dll`, `libcrypto-1_1-x64.dll`, `libssl-1_1-x64.dll`, `mvnc-hddl.dll` | Is not supported | - |
|
||||
| GNA | `libGNAPlugin.so` | `libgna.so`, | `GNAPlugin.dll` | `gna.dll` | Is not supported | - |
|
||||
| GNA | `libov_intel_gna_plugin.so` | `libgna.so`, | `ov_intel_gna_plugin.dll` | `gna.dll` | Is not supported | - |
|
||||
| HETERO | `libov_hetero_plugin.so` | Same as for selected plugins | `ov_hetero_plugin.dll` | Same as for selected plugins | `libov_hetero_plugin.so` | Same as for selected plugins |
|
||||
| MULTI | `libMultiDevicePlugin.so` | Same as for selected plugins | `MultiDevicePlugin.dll` | Same as for selected plugins | `libMultiDevicePlugin.so` | Same as for selected plugins |
|
||||
| MULTI | `libov_auto_plugin.so` | Same as for selected plugins | `ov_auto_plugin.dll` | Same as for selected plugins | `libov_auto_plugin.so` | Same as for selected plugins |
|
||||
| AUTO | `libov_auto_plugin.so` | Same as for selected plugins | `ov_auto_plugin.dll` | Same as for selected plugins | `libov_auto_plugin.so` | Same as for selected plugins |
|
||||
|
||||
> **NOTE**: All plugin libraries also depend on core Inference Engine libraries.
|
||||
|
||||
|
@ -31,15 +31,9 @@ Inference Engine sample applications include the following:
|
||||
- **Image Classification Sample Async** – Inference of image classification networks like AlexNet and GoogLeNet using Asynchronous Inference Request API (the sample supports only images as inputs).
|
||||
- [Image Classification Async C++ Sample](../../samples/cpp/classification_sample_async/README.md)
|
||||
- [Image Classification Async Python* Sample](../../samples/python/classification_sample_async/README.md)
|
||||
- **Style Transfer Sample** – Style Transfer sample (the sample supports only images as inputs).
|
||||
- [Style Transfer C++ Sample](../../samples/cpp/style_transfer_sample/README.md)
|
||||
- [Style Transfer Python* Sample](../../samples/python/style_transfer_sample/README.md)
|
||||
- **nGraph Function Creation Sample** – Construction of the LeNet network using the nGraph function creation sample.
|
||||
- [nGraph Function Creation C++ Sample](../../samples/cpp/ngraph_function_creation_sample/README.md)
|
||||
- [nGraph Function Creation Python Sample](../../samples/python/ngraph_function_creation_sample/README.md)
|
||||
- **Object Detection for SSD Sample** – Inference of object detection networks based on the SSD, this sample is simplified version that supports only images as inputs.
|
||||
- [Object Detection SSD C++ Sample](../../samples/cpp/object_detection_sample_ssd/README.md)
|
||||
- [Object Detection SSD C Sample](../../samples/c/object_detection_sample_ssd/README.md)
|
||||
|
||||
> **NOTE**: All C++ samples support input paths containing only ASCII characters, except the Hello Classification Sample, that supports Unicode.
|
||||
|
||||
|
@ -74,9 +74,10 @@ The table below shows the plugin libraries and additional dependencies for Linux
|
||||
| GPU | `libov_intel_gpu_plugin.so` | `libinference_engine_lp_transformations.so`, `libOpenCL.so` | `ov_intel_gpu_plugin.dll` | `OpenCL.dll`, `inference_engine_lp_transformations.dll` | Is not supported | - |
|
||||
| MYRIAD | `libmyriadPlugin.so` | `libusb.so`, | `myriadPlugin.dll` | `usb.dll` | `libmyriadPlugin.so` | `libusb.dylib` |
|
||||
| HDDL | `libHDDLPlugin.so` | `libbsl.so`, `libhddlapi.so`, `libmvnc-hddl.so` | `HDDLPlugin.dll` | `bsl.dll`, `hddlapi.dll`, `json-c.dll`, `libcrypto-1_1-x64.dll`, `libssl-1_1-x64.dll`, `mvnc-hddl.dll` | Is not supported | - |
|
||||
| GNA | `libGNAPlugin.so` | `libgna.so`, | `GNAPlugin.dll` | `gna.dll` | Is not supported | - |
|
||||
| GNA | `libov_intel_gna_plugin.so` | `libgna.so`, | `ov_intel_gna_plugin.dll` | `gna.dll` | Is not supported | - |
|
||||
| HETERO | `libov_hetero_plugin.so` | Same as for selected plugins | `ov_hetero_plugin.dll` | Same as for selected plugins | `libov_hetero_plugin.so` | Same as for selected plugins |
|
||||
| MULTI | `libMultiDevicePlugin.so` | Same as for selected plugins | `MultiDevicePlugin.dll` | Same as for selected plugins | `libMultiDevicePlugin.so` | Same as for selected plugins |
|
||||
| MULTI | `libov_auto_plugin.so` | Same as for selected plugins | `ov_auto_plugin.dll` | Same as for selected plugins | `libov_auto_plugin.so` | Same as for selected plugins |
|
||||
| AUTO | `libov_auto_plugin.so` | Same as for selected plugins | `ov_auto_plugin.dll` | Same as for selected plugins | `libov_auto_plugin.so` | Same as for selected plugins |
|
||||
|
||||
> **NOTE**: All plugin libraries also depend on core Inference Engine libraries.
|
||||
|
||||
|
@ -68,7 +68,7 @@ The attribute names are self-explanatory or match the name in the `hparams_confi
|
||||
> **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 more information about the parameter, refer to **When to Reverse Input Channels** section of [Converting a Model Using General Conversion Parameters](../Converting_Model_General.md).
|
||||
|
||||
OpenVINO™ toolkit provides samples that can be used to infer EfficientDet model. For more information, refer to
|
||||
[Object Detection for SSD C++ Sample](@ref openvino_inference_engine_samples_object_detection_sample_ssd_README) and
|
||||
[Open Model Zoo Demos](@ref omz_demos) and
|
||||
|
||||
## <a name="efficientdet-ir-results-interpretation"></a>Interpreting Results of the TensorFlow Model and the IR
|
||||
|
||||
|
@ -55,13 +55,19 @@ For example, if you downloaded the [pre-trained SSD InceptionV2 topology](http:/
|
||||
<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
|
||||
```
|
||||
|
||||
## OpenVINO&; Toolkit Samples and Open Model Zoo Demos
|
||||
|
||||
Inference Engine comes with a number of samples to demonstrate use of OpenVINO API, additionally,
|
||||
Open Model Zoo provides set of demo applications to show implementation of close to real life applications
|
||||
based on deep learning in various tasks, including Image Classifiacton, Visual Object Detection, Text Recognition,
|
||||
Speech Recognition, Natural Language Processing and others. Refer to the links below for more details.
|
||||
|
||||
|
||||
* [Inference Engine Samples](../../../../IE_DG/Samples_Overview.md)
|
||||
* [Open Model Zoo Demos](@ref omz_demos)
|
||||
|
||||
## Important Notes About Feeding Input Images to the Samples
|
||||
|
||||
Inference Engine comes with a number of samples to infer Object Detection API models including:
|
||||
|
||||
* [Object Detection for SSD Sample](../../../../../samples/cpp/object_detection_sample_ssd/README.md) --- for RFCN, SSD and Faster R-CNNs
|
||||
* [Mask R-CNN Sample for TensorFlow* Object Detection API Models](@ref omz_demos_mask_rcnn_demo_cpp) --- for Mask R-CNNs
|
||||
|
||||
There are several important notes about feeding input images to the samples:
|
||||
|
||||
1. Inference Engine samples stretch input image to the size of the input operation without preserving aspect ratio. This behavior is usually correct for most topologies (including SSDs), but incorrect for other models like Faster R-CNN, Mask R-CNN and R-FCN. These models usually use keeps aspect ratio resizer. The type of pre-processing is defined in the pipeline configuration file in the section `image_resizer`. If keeping aspect ratio is used, then it is necessary to resize image before passing it to the sample and optionally pad the resized image with 0s (if the attribute "pad_to_max_dimension" in the pipeline.config is equal to "true").
|
||||
|
@ -139,6 +139,7 @@ limitations under the License.
|
||||
<tab type="user" title="DeformablePSROIPooling-1" url="@ref openvino_docs_ops_detection_DeformablePSROIPooling_1"/>
|
||||
<tab type="user" title="DepthToSpace-1" url="@ref openvino_docs_ops_movement_DepthToSpace_1"/>
|
||||
<tab type="user" title="DetectionOutput-1" url="@ref openvino_docs_ops_detection_DetectionOutput_1"/>
|
||||
<tab type="user" title="DetectionOutput-8" url="@ref openvino_docs_ops_detection_DetectionOutput_8"/>
|
||||
<tab type="user" title="DFT-7" url="@ref openvino_docs_ops_signals_DFT_7"/>
|
||||
<tab type="user" title="Divide-1" url="@ref openvino_docs_ops_arithmetic_Divide_1"/>
|
||||
<tab type="user" title="Einsum-7" url="@ref openvino_docs_ops_matrix_Einsum_7"/>
|
||||
|
@ -173,12 +173,8 @@ limitations under the License.
|
||||
<tab type="user" title="Hello Query Device Python* Sample" url="@ref openvino_inference_engine_ie_bridges_python_sample_hello_query_device_README"/>
|
||||
<tab type="user" title="nGraph Function Creation C++ Sample" url="@ref openvino_inference_engine_samples_ngraph_function_creation_sample_README"/>
|
||||
<tab type="user" title="nGraph Function Creation Python* Sample" url="@ref openvino_inference_engine_ie_bridges_python_sample_ngraph_function_creation_sample_README"/>
|
||||
<tab type="user" title="Object Detection SSD C++ Sample" url="@ref openvino_inference_engine_samples_object_detection_sample_ssd_README"/>
|
||||
<tab type="user" title="Object Detection SSD C Sample" url="@ref openvino_inference_engine_ie_bridges_c_samples_object_detection_sample_ssd_README"/>
|
||||
<tab type="user" title="Automatic Speech Recognition C++ Sample" url="@ref openvino_inference_engine_samples_speech_sample_README"/>
|
||||
<tab type="user" title="Automatic Speech Recognition Python Sample" url="@ref openvino_inference_engine_ie_bridges_python_sample_speech_sample_README"/>
|
||||
<tab type="user" title="Style Transfer C++ Sample" url="@ref openvino_inference_engine_samples_style_transfer_sample_README"/>
|
||||
<tab type="user" title="Style Transfer Python* Sample" url="@ref openvino_inference_engine_ie_bridges_python_sample_style_transfer_sample_README"/>
|
||||
<tab type="user" title="Benchmark C++ Tool" url="@ref openvino_inference_engine_samples_benchmark_app_README"/>
|
||||
<tab type="user" title="Benchmark Python* Tool" url="@ref openvino_inference_engine_tools_benchmark_tool_README"/>
|
||||
</tab>
|
||||
|
@ -432,13 +432,6 @@ Template to call sample code or a demo application:
|
||||
<path_to_app> -i <path_to_media> -m <path_to_model> -d <target_device>
|
||||
```
|
||||
|
||||
With the sample information specified, the command might look like this:
|
||||
|
||||
```sh
|
||||
./object_detection_demo_ssd_async -i ~/Videos/catshow.mp4 \
|
||||
-m ~/ir/fp32/mobilenet-ssd.xml -d CPU
|
||||
```
|
||||
|
||||
## <a name="advanced-samples"></a> Advanced Demo Use
|
||||
|
||||
Some demo applications let you use multiple models for different purposes. In these cases, the output of the first model is usually used as the input for later models.
|
||||
@ -453,22 +446,6 @@ For head pose:
|
||||
|
||||
`-m_hp <headpose model> -d_hp <headpose hardware target>`
|
||||
|
||||
**Example of an Entire Command (object_detection + head pose):**
|
||||
|
||||
```sh
|
||||
./object_detection_demo_ssd_async -i ~/Videos/catshow.mp4 \
|
||||
-m ~/ir/fp32/mobilenet-ssd.xml -d CPU -m_hp headpose.xml \
|
||||
-d_hp CPU
|
||||
```
|
||||
|
||||
**Example of an Entire Command (object_detection + head pose + age-gender):**
|
||||
|
||||
```sh
|
||||
./object_detection_demo_ssd_async -i ~/Videos/catshow.mp4 \
|
||||
-m ~/r/fp32/mobilenet-ssd.xml -d CPU -m_hp headpose.xml \
|
||||
-d_hp CPU -m_ag age-gender.xml -d_ag CPU
|
||||
```
|
||||
|
||||
You can see all the sample application’s parameters by adding the `-h` or `--help` option at the command line.
|
||||
|
||||
|
||||
|
@ -416,22 +416,6 @@ For head pose:
|
||||
|
||||
`-m_hp <headpose model> -d_hp <headpose hardware target>`
|
||||
|
||||
**Example of an Entire Command (object_detection + head pose):**
|
||||
|
||||
```sh
|
||||
./object_detection_demo_ssd_async -i ~/Videos/catshow.mp4 \
|
||||
-m ~/ir/fp32/mobilenet-ssd.xml -d CPU -m_hp headpose.xml \
|
||||
-d_hp CPU
|
||||
```
|
||||
|
||||
**Example of an Entire Command (object_detection + head pose + age-gender):**
|
||||
|
||||
```sh
|
||||
./object_detection_demo_ssd_async -i ~/Videos/catshow.mp4 \
|
||||
-m ~/r/fp32/mobilenet-ssd.xml -d CPU -m_hp headpose.xml \
|
||||
-d_hp CPU -m_ag age-gender.xml -d_ag CPU
|
||||
```
|
||||
|
||||
You can see all the sample application’s parameters by adding the `-h` or `--help` option at the command line.
|
||||
|
||||
|
||||
|
@ -396,13 +396,6 @@ Template to call sample code or a demo application:
|
||||
<path_to_app> -i <path_to_media> -m <path_to_model> -d <target_device>
|
||||
```
|
||||
|
||||
With the sample information specified, the command might look like this:
|
||||
|
||||
```bat
|
||||
.\object_detection_demo_ssd_async -i C:\Users\<USER_ID>\Documents\Videos\catshow.mp4 \
|
||||
-m C:\Users\<USER_ID>\Documents\ir\fp32\mobilenet-ssd.xml -d CPU
|
||||
```
|
||||
|
||||
## <a name="advanced-samples"></a> Advanced Demo Use
|
||||
|
||||
Some demo applications let you use multiple models for different purposes. In these cases, the output of the first model is usually used as the input for later models.
|
||||
@ -417,22 +410,6 @@ For head pose:
|
||||
|
||||
`-m_hp <headpose model> -d_hp <headpose hardware target>`
|
||||
|
||||
**Example of an Entire Command (object_detection + head pose):**
|
||||
|
||||
```bat
|
||||
.\object_detection_demo_ssd_async -i C:\Users\<USER_ID>\Documents\Videos\catshow.mp4 \
|
||||
-m C:\Users\<USER_ID>\Documents\ir\fp32\mobilenet-ssd.xml -d CPU -m_hp headpose.xml \
|
||||
-d_hp CPU
|
||||
```
|
||||
|
||||
**Example of an Entire Command (object_detection + head pose + age-gender):**
|
||||
|
||||
```bat
|
||||
.\object_detection_demo_ssd_async -i C:\Users\<USER_ID>\Documents\Videos\catshow.mp4 \
|
||||
-m C:\Users\<USER_ID>\Documents\ir\fp32\mobilenet-ssd.xml -d CPU -m_hp headpose.xml \
|
||||
-d_hp CPU -m_ag age-gender.xml -d_ag CPU
|
||||
```
|
||||
|
||||
You can see all the sample application’s parameters by adding the `-h` or `--help` option at the command line.
|
||||
|
||||
|
||||
|
198
docs/ops/detection/DetectionOutput_8.md
Normal file
198
docs/ops/detection/DetectionOutput_8.md
Normal file
@ -0,0 +1,198 @@
|
||||
## DetectionOutput <a name="DetectionOutput"></a> {#openvino_docs_ops_detection_DetectionOutput_8}
|
||||
|
||||
**Versioned name**: *DetectionOutput-8*
|
||||
|
||||
**Category**: *Object detection*
|
||||
|
||||
**Short description**: *DetectionOutput* performs non-maximum suppression to generate the detection output using information on location and
|
||||
confidence predictions.
|
||||
|
||||
**Detailed description**: [Reference](https://arxiv.org/pdf/1512.02325.pdf). The layer has 3 mandatory inputs: tensor with box logits,
|
||||
tensor with confidence predictions and tensor with box coordinates (proposals). It can have 2 additional inputs with additional confidence
|
||||
predictions and box coordinates described in the [article](https://arxiv.org/pdf/1711.06897.pdf). The output tensor contains information
|
||||
about filtered detections described with 7 element tuples: `[batch_id, class_id, confidence, x_1, y_1, x_2, y_2]`. The first tuple
|
||||
with `batch_id` equal to `-1` means end of output.
|
||||
|
||||
At each feature map cell, *DetectionOutput* predicts the offsets relative to the default box shapes in the cell, as well as the per-class
|
||||
scores that indicate the presence of a class instance in each of those boxes. Specifically, for each box out of k at a given
|
||||
location, *DetectionOutput* computes class scores and the four offsets relative to the original default box shape.
|
||||
This results in a total of \f$(c + 4)k\f$ filters that are applied around each location in the feature map,
|
||||
yielding \f$(c + 4)kmn\f$ outputs for a *m \* n* feature map.
|
||||
|
||||
**Attributes**:
|
||||
|
||||
**NOTE:** *num_classes*, a number of classes attribute, presents in [DetectionOutput_1](DetectionOutput_1.md) has been removed.
|
||||
It can be computed as `cls_pred_shape[-1] // num_prior_boxes` where `cls_pred_shape` and `num_prior_boxes` are class predictions tensor shape and
|
||||
a number of prior boxes.
|
||||
|
||||
* *background_label_id*
|
||||
|
||||
* **Description**: background label id. If there is no background class, set it to -1.
|
||||
* **Range of values**: integer values
|
||||
* **Type**: int
|
||||
* **Default value**: 0
|
||||
* **Required**: *no*
|
||||
|
||||
* *top_k*
|
||||
|
||||
* **Description**: maximum number of results to be kept per batch after NMS step. -1 means keeping all bounding boxes.
|
||||
* **Range of values**: integer values
|
||||
* **Type**: int
|
||||
* **Default value**: -1
|
||||
* **Required**: *no*
|
||||
|
||||
* *variance_encoded_in_target*
|
||||
|
||||
* **Description**: *variance_encoded_in_target* is a flag that denotes if variance is encoded in target. If flag is false then
|
||||
it is necessary to adjust the predicted offset accordingly.
|
||||
* **Range of values**: false or true
|
||||
* **Type**: boolean
|
||||
* **Default value**: false
|
||||
* **Required**: *no*
|
||||
|
||||
* *keep_top_k*
|
||||
|
||||
* **Description**: maximum number of bounding boxes per batch to be kept after NMS step. -1 means keeping all bounding boxes after NMS step.
|
||||
* **Range of values**: integer values
|
||||
* **Type**: int[]
|
||||
* **Required**: *yes*
|
||||
|
||||
* *code_type*
|
||||
|
||||
* **Description**: type of coding method for bounding boxes
|
||||
* **Range of values**: "caffe.PriorBoxParameter.CENTER_SIZE", "caffe.PriorBoxParameter.CORNER"
|
||||
* **Type**: string
|
||||
* **Default value**: "caffe.PriorBoxParameter.CORNER"
|
||||
* **Required**: *no*
|
||||
|
||||
* *share_location*
|
||||
|
||||
* **Description**: *share_location* is a flag that denotes if bounding boxes are shared among different classes.
|
||||
* **Range of values**: false or true
|
||||
* **Type**: boolean
|
||||
* **Default value**: true
|
||||
* **Required**: *no*
|
||||
|
||||
* *nms_threshold*
|
||||
|
||||
* **Description**: threshold to be used in the NMS stage
|
||||
* **Range of values**: floating-point values
|
||||
* **Type**: float
|
||||
* **Required**: *yes*
|
||||
|
||||
* *confidence_threshold*
|
||||
|
||||
* **Description**: only consider detections whose confidences are larger than a threshold. If not provided, consider all boxes.
|
||||
* **Range of values**: floating-point values
|
||||
* **Type**: float
|
||||
* **Default value**: 0
|
||||
* **Required**: *no*
|
||||
|
||||
* *clip_after_nms*
|
||||
|
||||
* **Description**: *clip_after_nms* flag that denotes whether to perform clip bounding boxes after non-maximum suppression or not.
|
||||
* **Range of values**: false or true
|
||||
* **Type**: boolean
|
||||
* **Default value**: false
|
||||
* **Required**: *no*
|
||||
|
||||
* *clip_before_nms*
|
||||
|
||||
* **Description**: *clip_before_nms* flag that denotes whether to perform clip bounding boxes before non-maximum suppression or not.
|
||||
* **Range of values**: false or true
|
||||
* **Type**: boolean
|
||||
* **Default value**: false
|
||||
* **Required**: *no*
|
||||
|
||||
* *decrease_label_id*
|
||||
|
||||
* **Description**: *decrease_label_id* flag that denotes how to perform NMS.
|
||||
* **Range of values**:
|
||||
* false - perform NMS like in Caffe\*.
|
||||
* true - perform NMS like in MxNet\*.
|
||||
* **Type**: boolean
|
||||
* **Default value**: false
|
||||
* **Required**: *no*
|
||||
|
||||
* *normalized*
|
||||
|
||||
* **Description**: *normalized* flag that denotes whether input tensor with proposal boxes is normalized.
|
||||
If tensor is not normalized then *input_height* and *input_width* attributes are used to normalize box coordinates.
|
||||
* **Range of values**: false or true
|
||||
* **Type**: boolean
|
||||
* **Default value**: false
|
||||
* **Required**: *no*
|
||||
|
||||
* *input_height (input_width)*
|
||||
|
||||
* **Description**: input image height (width). If the *normalized* is 1 then these attributes are not used.
|
||||
* **Range of values**: positive integer number
|
||||
* **Type**: int
|
||||
* **Default value**: 1
|
||||
* **Required**: *no*
|
||||
|
||||
* *objectness_score*
|
||||
|
||||
* **Description**: threshold to sort out confidence predictions. Used only when the *DetectionOutput* layer has 5 inputs.
|
||||
* **Range of values**: non-negative float number
|
||||
* **Type**: float
|
||||
* **Default value**: 0
|
||||
* **Required**: *no*
|
||||
|
||||
**Inputs**
|
||||
|
||||
* **1**: 2D input tensor with box logits with shape `[N, num_prior_boxes * num_loc_classes * 4]` and type *T*. `num_loc_classes`
|
||||
is equal to `num_classes` when `share_location` is 0 or it's equal to 1 otherwise. **Required.**
|
||||
* **2**: 2D input tensor with class predictions with shape `[N, num_prior_boxes * num_classes]` and type *T*. **Required.**
|
||||
* **3**: 3D input tensor with proposals with shape `[priors_batch_size, 1, num_prior_boxes * prior_box_size]` or
|
||||
`[priors_batch_size, 2, num_prior_boxes * prior_box_size]`. `priors_batch_size` is either 1 or `N`.
|
||||
Size of the second dimension depends on `variance_encoded_in_target`. If `variance_encoded_in_target` is equal to 0,
|
||||
the second dimension equals to 2 and variance values are provided for each boxes coordinates.
|
||||
If `variance_encoded_in_target` is equal to 1, the second dimension equals to 1 and this tensor contains proposals boxes only.
|
||||
`prior_box_size` is equal to 4 when `normalized` is set to 1 or it's equal to 5 otherwise. **Required.**
|
||||
* **4**: 2D input tensor with additional class predictions information described in the [article](https://arxiv.org/pdf/1711.06897.pdf).
|
||||
Its shape must be equal to `[N, num_prior_boxes * 2]`. **Optional.**
|
||||
* **5**: 2D input tensor with additional box predictions information described in the [article](https://arxiv.org/pdf/1711.06897.pdf).
|
||||
Its shape must be equal to first input tensor shape. **Optional.**
|
||||
|
||||
**Outputs**
|
||||
|
||||
* **1**: 4D output tensor with type *T*. Its shape depends on `keep_top_k` or `top_k` being set. It `keep_top_k[0]` is greater than zero,
|
||||
then the shape is `[1, 1, N * keep_top_k[0], 7]`. If `keep_top_k[0]` is set to -1 and `top_k` is greater than zero,
|
||||
then the shape is `[1, 1, N * top_k * num_classes, 7]`. Otherwise, the output shape is equal to `[1, 1, N * num_classes * num_prior_boxes, 7]`.
|
||||
|
||||
**Types**
|
||||
|
||||
* *T*: any supported floating-point type.
|
||||
|
||||
|
||||
**Example**
|
||||
|
||||
```xml
|
||||
<layer ... type="DetectionOutput" version="opset8">
|
||||
<data background_label_id="1" code_type="caffe.PriorBoxParameter.CENTER_SIZE" confidence_threshold="0.019999999552965164" input_height="1" input_width="1" keep_top_k="200" nms_threshold="0.44999998807907104" normalized="true" share_location="true" top_k="200" variance_encoded_in_target="false" clip_after_nms="false" clip_before_nms="false" objectness_score="0" decrease_label_id="false"/>
|
||||
<input>
|
||||
<port id="0">
|
||||
<dim>1</dim>
|
||||
<dim>5376</dim>
|
||||
</port>
|
||||
<port id="1">
|
||||
<dim>1</dim>
|
||||
<dim>2688</dim>
|
||||
</port>
|
||||
<port id="2">
|
||||
<dim>1</dim>
|
||||
<dim>2</dim>
|
||||
<dim>5376</dim>
|
||||
</port>
|
||||
</input>
|
||||
<output>
|
||||
<port id="3" precision="FP32">
|
||||
<dim>1</dim>
|
||||
<dim>1</dim>
|
||||
<dim>200</dim>
|
||||
<dim>7</dim>
|
||||
</port>
|
||||
</output>
|
||||
</layer>
|
||||
```
|
@ -43,7 +43,7 @@ declared in `namespace opset8`.
|
||||
* [DeformableConvolution](convolution/DeformableConvolution_8.md)
|
||||
* [DeformablePSROIPooling](detection/DeformablePSROIPooling_1.md)
|
||||
* [DepthToSpace](movement/DepthToSpace_1.md)
|
||||
* [DetectionOutput](detection/DetectionOutput_1.md)
|
||||
* [DetectionOutput](detection/DetectionOutput_8.md)
|
||||
* [DFT](signals/DFT_7.md)
|
||||
* [Divide](arithmetic/Divide_1.md)
|
||||
* [Einsum](matrix/Einsum_7.md)
|
||||
|
@ -238,12 +238,12 @@ For general details on the heterogeneous plugin, refer to the [corresponding sec
|
||||
|
||||
### Trying the Heterogeneous Plugin with Inference Engine Samples <a name="heterogeneous-plugin-with-samples"></a>
|
||||
|
||||
Every Inference Engine sample supports the `-d` (device) option.
|
||||
Target device cand be specified from command line for every Inference Engine sample.
|
||||
|
||||
For example, here is a command to run an [Object Detection Sample SSD Sample](../../samples/cpp/object_detection_sample_ssd/README.md):
|
||||
For example, here is a command to run an [Classification Sample Async](../../samples/cpp/classification_sample_async/README.md):
|
||||
|
||||
```sh
|
||||
./object_detection_sample_ssd -m <path_to_model>/ModelSSD.xml -i <path_to_pictures>/picture.jpg -d HETERO:GPU,CPU
|
||||
./classification_sample_async -m <path_to_model>/Model.xml -i <path_to_pictures>/picture.jpg -d HETERO:GPU,CPU
|
||||
```
|
||||
|
||||
where:
|
||||
|
@ -17,13 +17,6 @@ if(ENABLE_VPU)
|
||||
add_subdirectory(vpu)
|
||||
endif()
|
||||
|
||||
if(ENABLE_GNA)
|
||||
add_subdirectory(gna_plugin)
|
||||
endif()
|
||||
|
||||
if(ENABLE_MULTI)
|
||||
add_subdirectory(multi_device)
|
||||
endif()
|
||||
|
||||
if(ENABLE_BATCH)
|
||||
add_subdirectory(auto_batch)
|
||||
|
@ -109,8 +109,7 @@ std::vector<VectorDims> MKLDNNAdaptivePoolingNode::shapeInfer() const {
|
||||
spatialDimsValue[i] = newSpatialDimsPtr[i];
|
||||
}
|
||||
|
||||
std::vector<VectorDims> result = {};
|
||||
result.resize(outputShapes.size(), outputDims);
|
||||
std::vector<VectorDims> result(outputShapes.size(), outputDims);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -16,10 +16,6 @@ using namespace InferenceEngine;
|
||||
|
||||
bool MKLDNNExperimentalDetectronTopKROIsNode::isSupportedOperation(const std::shared_ptr<const ngraph::Node>& op, std::string& errorMessage) noexcept {
|
||||
try {
|
||||
if (isDynamicNgraphNode(op)) {
|
||||
errorMessage = "Doesn't support op with dynamic shapes";
|
||||
return false;
|
||||
}
|
||||
const auto topKROI = std::dynamic_pointer_cast<const ngraph::opset6::ExperimentalDetectronTopKROIs>(op);
|
||||
if (!topKROI) {
|
||||
errorMessage = "Only opset6 ExperimentalDetectronTopKROIs operation is supported";
|
||||
@ -44,10 +40,10 @@ MKLDNNExperimentalDetectronTopKROIsNode::MKLDNNExperimentalDetectronTopKROIsNode
|
||||
IE_THROW() << "Operation with name '" << op->get_friendly_name() <<
|
||||
"' is not an instance of ExperimentalDetectronTopKROIs from opset6.";
|
||||
|
||||
if (getOriginalInputsNumber() != 2 || getOriginalOutputsNumber() != 1)
|
||||
if (inputShapes.size() != 2 || outputShapes.size() != 1)
|
||||
IE_THROW() << errorPrefix << " has incorrect number of input/output edges!";
|
||||
|
||||
if (op->get_input_shape(INPUT_ROIS).size() != 2 || op->get_input_shape(INPUT_PROBS).size() != 1)
|
||||
if (getInputShapeAtPort(INPUT_ROIS).getDims().size() != 2 || getInputShapeAtPort(INPUT_PROBS).getDims().size() != 1)
|
||||
IE_THROW() << errorPrefix << " has nsupported input shape";
|
||||
|
||||
max_rois_num_ = topKROI->get_max_rois();
|
||||
|
@ -19,6 +19,10 @@ public:
|
||||
void execute(mkldnn::stream strm) override;
|
||||
bool created() const override;
|
||||
|
||||
bool needShapeInfer() const override { return false; };
|
||||
bool needPrepareParams() const override { return false; };
|
||||
void executeDynamicImpl(mkldnn::stream strm) override { execute(strm); };
|
||||
|
||||
static bool isSupportedOperation(const std::shared_ptr<const ngraph::Node>& op, std::string& errorMessage) noexcept;
|
||||
|
||||
private:
|
||||
|
@ -44,8 +44,8 @@ if(ENABLE_HETERO)
|
||||
list(APPEND DEPENDENCIES ov_hetero_plugin)
|
||||
endif()
|
||||
|
||||
if(ENABLE_MULTI)
|
||||
list(APPEND DEPENDENCIES MultiDevicePlugin)
|
||||
if(ENABLE_AUTO OR ENABLE_MULTI)
|
||||
list(APPEND DEPENDENCIES ov_auto_plugin)
|
||||
endif()
|
||||
|
||||
if(ENABLE_BATCH)
|
||||
|
@ -12,7 +12,7 @@ if (ENABLE_INTEL_GPU)
|
||||
add_subdirectory(gpu)
|
||||
endif()
|
||||
|
||||
if (ENABLE_GNA)
|
||||
if (ENABLE_INTEL_GNA)
|
||||
add_subdirectory(gna)
|
||||
endif()
|
||||
|
||||
|
@ -19,13 +19,13 @@ inline const std::string getPluginLibNameByDevice(const std::string& deviceName)
|
||||
{ "AUTO", "AutoPlugin" },
|
||||
{ "HDDL", "HDDLPlugin" },
|
||||
{ "VPUX", "VPUXPlugin" },
|
||||
{ "AUTO", "MultiDevicePlugin" },
|
||||
{ "AUTO", "ov_auto_plugin" },
|
||||
{ "CPU", "MKLDNNPlugin" },
|
||||
{ "GNA", "GNAPlugin" },
|
||||
{ "GNA", "ov_intel_gna_plugin" },
|
||||
{ "GPU", "ov_intel_gpu_plugin" },
|
||||
{ "HETERO", "ov_hetero_plugin" },
|
||||
{ "BATCH", "AutoBatchPlugin" },
|
||||
{ "MULTI", "MultiDevicePlugin" },
|
||||
{ "MULTI", "ov_multi_plugin" },
|
||||
{ "MYRIAD", "myriadPlugin" },
|
||||
{ "TEMPLATE", "templatePlugin" },
|
||||
};
|
||||
|
@ -0,0 +1,55 @@
|
||||
// Copyright (C) 2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <vector>
|
||||
#include "single_layer_tests/experimental_detectron_topkrois.hpp"
|
||||
|
||||
using namespace ov::test;
|
||||
using namespace ov::test::subgraph;
|
||||
|
||||
namespace {
|
||||
std::vector<int64_t> maxRois {
|
||||
1000,
|
||||
1500,
|
||||
2000,
|
||||
2500
|
||||
};
|
||||
|
||||
const std::vector<std::vector<InputShape>> staticInputShape = {
|
||||
static_shapes_to_test_representation({{3000, 4}, {3000}}),
|
||||
static_shapes_to_test_representation({{4200, 4}, {4200}}),
|
||||
static_shapes_to_test_representation({{4500, 4}, {4500}})
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(smoke_ExperimentalDetectronTopKROIs_static, ExperimentalDetectronTopKROIsLayerTest,
|
||||
::testing::Combine(
|
||||
::testing::ValuesIn(staticInputShape),
|
||||
::testing::ValuesIn(maxRois),
|
||||
::testing::Values(ElementType::f32),
|
||||
::testing::Values(CommonTestUtils::DEVICE_CPU)),
|
||||
ExperimentalDetectronTopKROIsLayerTest::getTestCaseName);
|
||||
|
||||
const std::vector<std::vector<InputShape>> dynamicInputShape = {
|
||||
{
|
||||
{
|
||||
{{-1, 4}, {{5000, 4}, {4000, 4}, {3500, 4}}},
|
||||
{{-1}, {{5000}, {4000}, {3500}}}
|
||||
}
|
||||
},
|
||||
{
|
||||
{
|
||||
{{{1000, 5000}, 4}, {{5000, 4}, {3000, 4}, {2500, 4}}},
|
||||
{{{1000, 5000}}, {{5000}, {3000}, {2500}}}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(smoke_ExperimentalROI_dynamic, ExperimentalDetectronTopKROIsLayerTest,
|
||||
::testing::Combine(
|
||||
::testing::ValuesIn(dynamicInputShape),
|
||||
::testing::ValuesIn(maxRois),
|
||||
::testing::Values(ElementType::f32),
|
||||
::testing::Values(CommonTestUtils::DEVICE_CPU)),
|
||||
ExperimentalDetectronTopKROIsLayerTest::getTestCaseName);
|
||||
} // namespace
|
@ -8,7 +8,7 @@ addIeTargetTest(
|
||||
NAME ${TARGET_NAME}
|
||||
ROOT ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
DEPENDENCIES
|
||||
GNAPlugin
|
||||
ov_intel_gna_plugin
|
||||
LINK_LIBRARIES
|
||||
funcSharedTests
|
||||
ADD_CPPLINT
|
||||
|
@ -16,7 +16,7 @@ namespace {
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(nightly_OVClassBasicTestP,
|
||||
OVClassBasicTestP,
|
||||
::testing::Values(std::make_pair("GNAPlugin", "GNA")));
|
||||
::testing::Values(std::make_pair("ov_intel_gna_plugin", "GNA")));
|
||||
|
||||
// TODO
|
||||
INSTANTIATE_TEST_SUITE_P(DISABLED_smoke_OVClassNetworkTestP, OVClassNetworkTestP, ::testing::Values("GNA"));
|
||||
|
@ -15,7 +15,7 @@ namespace {
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
nightly_IEClassBasicTestP, IEClassBasicTestP,
|
||||
::testing::Values(std::make_pair("GNAPlugin", "GNA")));
|
||||
::testing::Values(std::make_pair("ov_intel_gna_plugin", "GNA")));
|
||||
|
||||
// TODO
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
|
@ -0,0 +1,35 @@
|
||||
// Copyright (C) 2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "single_layer_tests/convert_color_i420.hpp"
|
||||
#include "common_test_utils/test_constants.hpp"
|
||||
#include "negative_layer_support_test.hpp"
|
||||
|
||||
using namespace LayerTestsDefinitions;
|
||||
|
||||
namespace {
|
||||
|
||||
const std::vector<ov::Shape> inShapes_nhwc = {
|
||||
{1, 10, 10, 1}
|
||||
};
|
||||
|
||||
const std::vector<ov::element::Type> inTypes = {
|
||||
ov::element::u8,
|
||||
ov::element::f32
|
||||
};
|
||||
|
||||
const auto testCase_values = ::testing::Combine(
|
||||
::testing::ValuesIn(inShapes_nhwc),
|
||||
::testing::ValuesIn(inTypes),
|
||||
::testing::Bool(),
|
||||
::testing::Bool(),
|
||||
::testing::Values(CommonTestUtils::DEVICE_GNA)
|
||||
);
|
||||
|
||||
|
||||
GNA_UNSUPPPORTED_LAYER_NEG_TEST(ConvertColorI420LayerTest, "The plugin does not support layer", testCase_values)
|
||||
|
||||
} // namespace
|
@ -0,0 +1,35 @@
|
||||
// Copyright (C) 2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "single_layer_tests/convert_color_nv12.hpp"
|
||||
#include "common_test_utils/test_constants.hpp"
|
||||
#include "negative_layer_support_test.hpp"
|
||||
|
||||
using namespace LayerTestsDefinitions;
|
||||
|
||||
namespace {
|
||||
|
||||
const std::vector<ov::Shape> inShapes_nhwc = {
|
||||
{1, 10, 10, 1}
|
||||
};
|
||||
|
||||
const std::vector<ov::element::Type> inTypes = {
|
||||
ov::element::u8,
|
||||
ov::element::f32
|
||||
};
|
||||
|
||||
const auto testCase_values = ::testing::Combine(
|
||||
::testing::ValuesIn(inShapes_nhwc),
|
||||
::testing::ValuesIn(inTypes),
|
||||
::testing::Bool(),
|
||||
::testing::Bool(),
|
||||
::testing::Values(CommonTestUtils::DEVICE_GNA)
|
||||
);
|
||||
|
||||
|
||||
GNA_UNSUPPPORTED_LAYER_NEG_TEST(ConvertColorNV12LayerTest, "The plugin does not support layer", testCase_values)
|
||||
|
||||
} // namespace
|
@ -0,0 +1,33 @@
|
||||
// Copyright (C) 2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
namespace LayerTestsDefinitions {
|
||||
|
||||
#define GNA_UNSUPPPORTED_LAYER_NEG_TEST(test_class, expected_error_substring, test_configuration) \
|
||||
class Negative##test_class : public test_class { \
|
||||
public: \
|
||||
void Run() override { \
|
||||
try { \
|
||||
test_class::LoadNetwork(); \
|
||||
FAIL() << "GNA's unsupported layers were not detected during LoadNetwork()"; \
|
||||
} \
|
||||
catch (std::runtime_error& e) { \
|
||||
const std::string errorMsg = e.what(); \
|
||||
const auto expectedMsg = expected_error_substring; \
|
||||
ASSERT_STR_CONTAINS(errorMsg, expectedMsg); \
|
||||
EXPECT_TRUE(errorMsg.find(expectedMsg) != std::string::npos) \
|
||||
<< "Wrong error message, actual error message: " << errorMsg \
|
||||
<< ", expected: " << expectedMsg; \
|
||||
} \
|
||||
} \
|
||||
}; \
|
||||
\
|
||||
TEST_P(Negative##test_class, ThrowAsNotSupported) { \
|
||||
Run(); \
|
||||
} \
|
||||
\
|
||||
INSTANTIATE_TEST_SUITE_P(smoke_NegativeTestsUnsupportedLayer, Negative##test_class, \
|
||||
test_configuration, Negative##test_class::getTestCaseName);
|
||||
|
||||
} // namespace LayerTestsDefinitions
|
@ -0,0 +1,157 @@
|
||||
// Copyright (C) 2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
#include <vector>
|
||||
#include "common_test_utils/test_constants.hpp"
|
||||
#include "single_layer_tests/deformable_convolution.hpp"
|
||||
using namespace LayerTestsDefinitions;
|
||||
namespace {
|
||||
const std::vector<InferenceEngine::Precision> netPrecisions = {
|
||||
InferenceEngine::Precision::FP32,
|
||||
InferenceEngine::Precision::FP16,
|
||||
InferenceEngine::Precision::I16
|
||||
};
|
||||
|
||||
/* ============= 2D DeformableConvolution ============= */
|
||||
const std::vector<std::vector<size_t>> deformable_values_0 = {{1, 16, 2, 2}};
|
||||
const std::vector<std::vector<size_t>> kernel_shapes_0 = {{2, 2, 2, 2}};
|
||||
const std::vector<std::vector<size_t>> stride_values = {{1, 1}};
|
||||
const std::vector<std::vector<ptrdiff_t>> pad_begin_values = {{0, 0}};
|
||||
const std::vector<std::vector<ptrdiff_t>> pad_end_values ={{0, 0}};
|
||||
const std::vector<std::vector<size_t>> dilation_values = {{1, 1}};
|
||||
const std::vector<size_t> num_groups = {1};
|
||||
const std::vector<size_t> num_deformable_groups_0 = {2};
|
||||
const std::vector<size_t> num_out_channels = {1, 5};
|
||||
const std::vector<size_t> multiple_defor_groups = {4};
|
||||
const std::vector<std::vector<size_t>> deformable_values_1 = {{1, 72, 64, 64}};
|
||||
const std::vector<std::vector<size_t>> kernel_shapes_1 = {{16, 16, 3, 3}};
|
||||
|
||||
const std::vector<bool> with_bilinear_interpolation_pad = { false, true };
|
||||
const std::vector<bool> with_modulated_scalar = { false, true };
|
||||
|
||||
const auto deformableConv2DParams_ExplicitPadding = ::testing::Combine(
|
||||
::testing::ValuesIn(deformable_values_0),
|
||||
::testing::ValuesIn(kernel_shapes_0), ::testing::ValuesIn(stride_values),
|
||||
::testing::ValuesIn(pad_begin_values), ::testing::ValuesIn(pad_end_values),
|
||||
::testing::ValuesIn(dilation_values), ::testing::ValuesIn(num_groups),
|
||||
::testing::ValuesIn(num_deformable_groups_0), ::testing::ValuesIn(num_out_channels),
|
||||
::testing::Values(ngraph::op::PadType::EXPLICIT), ::testing::ValuesIn(with_bilinear_interpolation_pad),
|
||||
::testing::ValuesIn(with_modulated_scalar));
|
||||
|
||||
const auto deformableConv2DParams_AutoPadValid = ::testing::Combine(
|
||||
::testing::ValuesIn(deformable_values_0),
|
||||
::testing::ValuesIn(kernel_shapes_0), ::testing::ValuesIn(stride_values),
|
||||
::testing::Values(std::vector<ptrdiff_t>({0, 0})),
|
||||
::testing::Values(std::vector<ptrdiff_t>({0, 0})),
|
||||
::testing::ValuesIn(dilation_values), ::testing::ValuesIn(num_groups),
|
||||
::testing::ValuesIn(num_deformable_groups_0), ::testing::ValuesIn(num_out_channels),
|
||||
::testing::Values(ngraph::op::PadType::VALID),
|
||||
::testing::ValuesIn(with_bilinear_interpolation_pad),
|
||||
::testing::ValuesIn(with_modulated_scalar));
|
||||
|
||||
const auto deformableConv2DParams_DeformableGroups_AutoPadExplicit = ::testing::Combine(
|
||||
::testing::ValuesIn(deformable_values_1),
|
||||
::testing::ValuesIn(kernel_shapes_1), ::testing::ValuesIn(stride_values),
|
||||
::testing::Values(std::vector<ptrdiff_t>({0, 0})),
|
||||
::testing::Values(std::vector<ptrdiff_t>({0, 0})),
|
||||
::testing::ValuesIn(dilation_values), ::testing::ValuesIn(num_groups),
|
||||
::testing::ValuesIn(multiple_defor_groups), ::testing::ValuesIn(num_out_channels),
|
||||
::testing::Values(ngraph::op::PadType::EXPLICIT),
|
||||
::testing::ValuesIn(with_bilinear_interpolation_pad),
|
||||
::testing::ValuesIn(with_modulated_scalar));
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
smoke_DeformableConvolution2D_ExplicitPadding, DeformableConvolutionLayerTest,
|
||||
::testing::Combine(
|
||||
deformableConv2DParams_ExplicitPadding, ::testing::ValuesIn(netPrecisions),
|
||||
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
|
||||
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
|
||||
::testing::Values(InferenceEngine::Layout::ANY),
|
||||
::testing::Values(InferenceEngine::Layout::ANY),
|
||||
::testing::Values(std::vector<size_t>({1, 2, 3, 3})),
|
||||
::testing::Values(CommonTestUtils::DEVICE_GPU)),
|
||||
DeformableConvolutionLayerTest::getTestCaseName);
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
smoke_DeformableConvolution2D_AutoPadValid, DeformableConvolutionLayerTest,
|
||||
::testing::Combine(
|
||||
deformableConv2DParams_AutoPadValid, ::testing::ValuesIn(netPrecisions),
|
||||
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
|
||||
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
|
||||
::testing::Values(InferenceEngine::Layout::ANY),
|
||||
::testing::Values(InferenceEngine::Layout::ANY),
|
||||
::testing::Values(std::vector<size_t>({1, 2, 3, 3})),
|
||||
::testing::Values(CommonTestUtils::DEVICE_GPU)),
|
||||
DeformableConvolutionLayerTest::getTestCaseName);
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
smoke_DeformableConvolution2D_DeformableGroups_ExplicitPadding, DeformableConvolutionLayerTest,
|
||||
::testing::Combine(
|
||||
deformableConv2DParams_DeformableGroups_AutoPadExplicit,
|
||||
::testing::ValuesIn(netPrecisions),
|
||||
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
|
||||
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
|
||||
::testing::Values(InferenceEngine::Layout::ANY),
|
||||
::testing::Values(InferenceEngine::Layout::ANY),
|
||||
::testing::Values(std::vector<size_t>({1, 16, 66, 66})),
|
||||
::testing::Values(CommonTestUtils::DEVICE_GPU)),
|
||||
DeformableConvolutionLayerTest::getTestCaseName);
|
||||
|
||||
///* ============= Single Test Case ============= */
|
||||
const std::vector<std::vector<size_t>> deformable_values_2 = {{1, 54, 28, 28}};
|
||||
const std::vector<std::vector<size_t>> kernel_shapes_2 = {{1, 3, 3, 3}};
|
||||
const std::vector<size_t> num_deformable_groups_1 = {3};
|
||||
|
||||
const auto deformableConv2DParams_SingleTestCase = ::testing::Combine(
|
||||
::testing::ValuesIn(deformable_values_2),
|
||||
::testing::ValuesIn(kernel_shapes_2),
|
||||
::testing::ValuesIn(stride_values),
|
||||
::testing::ValuesIn(pad_begin_values),
|
||||
::testing::ValuesIn(pad_end_values),
|
||||
::testing::ValuesIn(dilation_values),
|
||||
::testing::ValuesIn(num_groups),
|
||||
::testing::ValuesIn(num_deformable_groups_1),
|
||||
::testing::ValuesIn(num_out_channels),
|
||||
::testing::Values(ngraph::op::PadType::EXPLICIT),
|
||||
::testing::ValuesIn(with_bilinear_interpolation_pad),
|
||||
::testing::ValuesIn(with_modulated_scalar)
|
||||
);
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
smoke_DeformableConvolution2D_SingleTestCase, DeformableConvolutionLayerTest,
|
||||
::testing::Combine(
|
||||
deformableConv2DParams_SingleTestCase,
|
||||
::testing::ValuesIn(netPrecisions),
|
||||
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
|
||||
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
|
||||
::testing::Values(InferenceEngine::Layout::ANY),
|
||||
::testing::Values(InferenceEngine::Layout::ANY),
|
||||
::testing::Values(std::vector<size_t>({1, 3, 30, 30})),
|
||||
::testing::Values(CommonTestUtils::DEVICE_GPU)),
|
||||
DeformableConvolutionLayerTest::getTestCaseName);
|
||||
/* ============= Multiple groups case ============= */
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
smoke_DeformableConvolution2D_MultipleGroups, DeformableConvolutionLayerTest,
|
||||
::testing::Combine(
|
||||
::testing::Combine(
|
||||
::testing::ValuesIn(std::vector<std::vector<size_t>> {{1, 18, 66, 66}}), // offsets
|
||||
::testing::ValuesIn(std::vector<std::vector<size_t>> {{4, 2, 3, 3}}), // ker.
|
||||
::testing::ValuesIn(stride_values),
|
||||
::testing::Values(std::vector<ptrdiff_t>({0, 0})),
|
||||
::testing::Values(std::vector<ptrdiff_t>({0, 0})),
|
||||
::testing::ValuesIn(dilation_values),
|
||||
::testing::ValuesIn(std::vector<size_t> {4}), // gr.
|
||||
::testing::ValuesIn(std::vector<size_t> {1}), // def. gr.
|
||||
::testing::ValuesIn(num_out_channels),
|
||||
::testing::Values(ngraph::op::PadType::EXPLICIT),
|
||||
::testing::ValuesIn(with_bilinear_interpolation_pad),
|
||||
::testing::ValuesIn(with_modulated_scalar)),
|
||||
::testing::ValuesIn(netPrecisions),
|
||||
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
|
||||
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
|
||||
::testing::Values(InferenceEngine::Layout::ANY),
|
||||
::testing::Values(InferenceEngine::Layout::ANY),
|
||||
::testing::Values(std::vector<size_t>({1, 8, 68, 68})),
|
||||
::testing::Values(CommonTestUtils::DEVICE_GPU)),
|
||||
DeformableConvolutionLayerTest::getTestCaseName);
|
||||
} // namespace
|
@ -12,8 +12,8 @@ if(ENABLE_HETERO)
|
||||
list(APPEND DEPENDENCIES ov_hetero_plugin)
|
||||
endif()
|
||||
|
||||
if(ENABLE_MULTI)
|
||||
list(APPEND DEPENDENCIES MultiDevicePlugin)
|
||||
if(ENABLE_AUTO OR ENABLE_MULTI)
|
||||
list(APPEND DEPENDENCIES ov_auto_plugin)
|
||||
endif()
|
||||
|
||||
if(ENABLE_BATCH)
|
||||
|
@ -0,0 +1,19 @@
|
||||
// Copyright (C) 2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <shared_test_classes/single_layer/experimental_detectron_topkrois.hpp>
|
||||
|
||||
namespace ov {
|
||||
namespace test {
|
||||
namespace subgraph {
|
||||
|
||||
TEST_P(ExperimentalDetectronTopKROIsLayerTest, ExperimentalDetectronTopKROIsTests) {
|
||||
run();
|
||||
}
|
||||
|
||||
} // namespace subgraph
|
||||
} // namespace test
|
||||
} // namespace ov
|
@ -0,0 +1,32 @@
|
||||
// Copyright (C) 2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ngraph_functions/utils/ngraph_helpers.hpp"
|
||||
#include "common_test_utils/common_utils.hpp"
|
||||
#include "shared_test_classes/base/ov_subgraph.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace test {
|
||||
namespace subgraph {
|
||||
|
||||
typedef std::tuple<
|
||||
std::vector<InputShape>, // input shape
|
||||
int64_t , // Max rois
|
||||
ElementType, // Network precision
|
||||
std::string // Device name
|
||||
> ExperimentalDetectronTopKROIsTestParams;
|
||||
|
||||
class ExperimentalDetectronTopKROIsLayerTest : public testing::WithParamInterface<ExperimentalDetectronTopKROIsTestParams>,
|
||||
virtual public SubgraphBaseTest {
|
||||
protected:
|
||||
void SetUp() override;
|
||||
|
||||
public:
|
||||
static std::string getTestCaseName(const testing::TestParamInfo<ExperimentalDetectronTopKROIsTestParams>& obj);
|
||||
};
|
||||
} // namespace subgraph
|
||||
} // namespace test
|
||||
} // namespace ov
|
@ -0,0 +1,60 @@
|
||||
// Copyright (C) 2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "ngraph_functions/builders.hpp"
|
||||
#include "functional_test_utils/ov_tensor_utils.hpp"
|
||||
#include "shared_test_classes/single_layer/experimental_detectron_topkrois.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace test {
|
||||
namespace subgraph {
|
||||
|
||||
std::string ExperimentalDetectronTopKROIsLayerTest::getTestCaseName(const testing::TestParamInfo<ExperimentalDetectronTopKROIsTestParams>& obj) {
|
||||
std::vector<InputShape> inputShapes;
|
||||
int64_t maxRois;
|
||||
ElementType netPrecision;
|
||||
std::string targetName;
|
||||
std::tie(inputShapes, maxRois, netPrecision, targetName) = obj.param;
|
||||
|
||||
std::ostringstream result;
|
||||
if (inputShapes.front().first.size() != 0) {
|
||||
result << "IS=(";
|
||||
for (const auto &shape : inputShapes) {
|
||||
result << CommonTestUtils::partialShape2str({shape.first}) << "_";
|
||||
}
|
||||
result.seekp(-1, result.cur);
|
||||
result << ")_";
|
||||
}
|
||||
result << "TS=";
|
||||
for (const auto& shape : inputShapes) {
|
||||
for (const auto& item : shape.second) {
|
||||
result << CommonTestUtils::vec2str(item) << "_";
|
||||
}
|
||||
}
|
||||
result << "maxRois=" << maxRois << "_";
|
||||
result << "netPRC=" << netPrecision << "_";
|
||||
result << "trgDev=" << targetName;
|
||||
return result.str();
|
||||
}
|
||||
|
||||
void ExperimentalDetectronTopKROIsLayerTest::SetUp() {
|
||||
std::vector<InputShape> inputShapes;
|
||||
int64_t maxRois;
|
||||
ElementType netPrecision;
|
||||
std::string targetName;
|
||||
std::tie(inputShapes, maxRois, netPrecision, targetName) = this->GetParam();
|
||||
|
||||
inType = outType = netPrecision;
|
||||
targetDevice = targetName;
|
||||
|
||||
init_input_shapes(inputShapes);
|
||||
|
||||
auto params = ngraph::builder::makeDynamicParams(netPrecision, inputDynamicShapes);
|
||||
auto paramOuts = ngraph::helpers::convert2OutputVector(ngraph::helpers::castOps2Nodes<ngraph::op::Parameter>(params));
|
||||
auto experimentalDetectronTopKROIs = std::make_shared<ov::op::v6::ExperimentalDetectronTopKROIs>(paramOuts[0], paramOuts[1], maxRois);
|
||||
function = std::make_shared<ov::Function>(ov::OutputVector {experimentalDetectronTopKROIs->output(0)}, "ExperimentalDetectronTopKROIs");
|
||||
}
|
||||
} // namespace subgraph
|
||||
} // namespace test
|
||||
} // namespace ov
|
@ -16,7 +16,7 @@ if (ENABLE_MKL_DNN)
|
||||
add_subdirectory(cpu)
|
||||
endif ()
|
||||
|
||||
if (ENABLE_GNA)
|
||||
if (ENABLE_INTEL_GNA)
|
||||
add_subdirectory(gna)
|
||||
endif ()
|
||||
|
||||
@ -28,4 +28,6 @@ if(NGRAPH_ONNX_FRONTEND_ENABLE)
|
||||
add_subdirectory(frontends/onnx_import)
|
||||
endif()
|
||||
|
||||
add_subdirectory(multi)
|
||||
if (ENABLE_AUTO OR ENABLE_MULTI)
|
||||
add_subdirectory(auto)
|
||||
endif()
|
||||
|
@ -5,15 +5,15 @@
|
||||
set(TARGET_NAME ieMultiPluginUnitTests)
|
||||
|
||||
set(CI_BUILD_NUMBER "unittest")
|
||||
addVersionDefines(${IE_MAIN_SOURCE_DIR}/src/multi_device/multi_device_plugin.cpp CI_BUILD_NUMBER)
|
||||
addVersionDefines(${OpenVINO_SOURCE_DIR}/src/plugins/auto/plugin.cpp CI_BUILD_NUMBER)
|
||||
add_definitions(-DMULTIUNITTEST)
|
||||
|
||||
addIeTargetTest(
|
||||
NAME ${TARGET_NAME}
|
||||
ROOT ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
ADDITIONAL_SOURCE_DIRS ${IE_MAIN_SOURCE_DIR}/src/multi_device ${IE_MAIN_SOURCE_DIR}/src/multi_device/utils
|
||||
ADDITIONAL_SOURCE_DIRS ${OpenVINO_SOURCE_DIR}/src/plugins/auto ${OpenVINO_SOURCE_DIR}/src/plugins/auto/utils
|
||||
INCLUDES
|
||||
${IE_MAIN_SOURCE_DIR}/src/multi_device ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${OpenVINO_SOURCE_DIR}/src/plugins/auto ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
LINK_LIBRARIES
|
||||
inference_engine_lp_transformations
|
||||
ngraphFunctions
|
@ -15,7 +15,7 @@
|
||||
#include <ngraph_functions/subgraph_builders.hpp>
|
||||
#include <gtest/gtest.h>
|
||||
#include <gmock/gmock.h>
|
||||
#include "plugin/mock_multi_device_plugin.hpp"
|
||||
#include "plugin/mock_auto_device_plugin.hpp"
|
||||
#include "cpp/ie_plugin.hpp"
|
||||
|
||||
using ::testing::MatcherCast;
|
@ -5,7 +5,7 @@
|
||||
#pragma once
|
||||
#include <gmock/gmock.h>
|
||||
#include "ie_icore.hpp"
|
||||
#include "multi_device_plugin.hpp"
|
||||
#include "plugin.hpp"
|
||||
#include <iostream>
|
||||
|
||||
using namespace MockMultiDevicePlugin;
|
@ -18,7 +18,7 @@ addIeTargetTest(
|
||||
ngraphFunctions
|
||||
gmock
|
||||
commonTestUtils_s
|
||||
GNAPlugin_test_static
|
||||
ov_intel_gna_plugin_test_static
|
||||
engines_test_util
|
||||
ADD_CPPLINT
|
||||
LABELS
|
||||
|
@ -10,8 +10,8 @@ file(GLOB_RECURSE SHARED_TESTS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp
|
||||
add_library(${TARGET_NAME} STATIC ${SHARED_TESTS_SRC})
|
||||
add_dependencies(${TARGET_NAME} inference_engine_preproc)
|
||||
|
||||
if(ENABLE_MULTI)
|
||||
add_dependencies(${TARGET_NAME} MultiDevicePlugin)
|
||||
if(ENABLE_AUTO OR ENABLE_MULTI)
|
||||
add_dependencies(${TARGET_NAME} ov_auto_plugin)
|
||||
endif()
|
||||
|
||||
if(ENABLE_BATCH)
|
||||
|
@ -10,6 +10,6 @@ if (ENABLE_MYRIAD)
|
||||
add_subdirectory(vpu)
|
||||
endif()
|
||||
|
||||
if (ENABLE_GNA)
|
||||
if (ENABLE_INTEL_GNA)
|
||||
add_subdirectory(gna)
|
||||
endif()
|
||||
|
@ -13,7 +13,7 @@ file(GLOB TEST_SRC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shared_tests_instance/single_layer_tests/*.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/backward_compatibility/*.cpp)
|
||||
|
||||
list(APPEND DEPENDENCIES GNAPlugin)
|
||||
list(APPEND DEPENDENCIES ov_intel_gna_plugin)
|
||||
|
||||
if(ENABLE_HETERO)
|
||||
list(APPEND DEPENDENCIES ov_hetero_plugin)
|
||||
|
@ -21,8 +21,8 @@ add_library(${TARGET_NAME} STATIC ${SHARED_TESTS_SRC})
|
||||
|
||||
add_dependencies(${TARGET_NAME} inference_engine_preproc mock_engine)
|
||||
|
||||
if(ENABLE_MULTI)
|
||||
add_dependencies(${TARGET_NAME} MultiDevicePlugin)
|
||||
if(ENABLE_AUTO OR ENABLE_MULTI)
|
||||
add_dependencies(${TARGET_NAME} ov_auto_plugin)
|
||||
endif()
|
||||
|
||||
if(ENABLE_BATCH)
|
||||
|
@ -19,7 +19,7 @@ file(GLOB
|
||||
)
|
||||
|
||||
# TODO: fix CVS-71010 and remove BUILD_SHARED_LIBS
|
||||
if (ENABLE_GNA AND BUILD_SHARED_LIBS)
|
||||
if (ENABLE_INTEL_GNA AND BUILD_SHARED_LIBS)
|
||||
file(GLOB
|
||||
GNA_TESTS
|
||||
engines/gna/*cpp
|
||||
@ -28,7 +28,7 @@ if (ENABLE_GNA AND BUILD_SHARED_LIBS)
|
||||
)
|
||||
source_group("gna" FILES ${GNA_TESTS})
|
||||
list(APPEND TEST_SRC ${GNA_TESTS})
|
||||
list(APPEND TEST_DEPS GNAPlugin_test_static)
|
||||
list(APPEND TEST_DEPS ov_intel_gna_plugin_test_static)
|
||||
|
||||
if(SUGGEST_OVERRIDE_SUPPORTED)
|
||||
set_source_files_properties(engines/gna/graph_tools/graph_copy_tests.cpp
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "graph_test_base.hpp"
|
||||
#include <memory>
|
||||
|
||||
#ifdef ENABLE_GNA
|
||||
#ifdef ENABLE_INTEL_GNA
|
||||
# include <frontend/model_quantizer.hpp>
|
||||
#endif
|
||||
|
||||
@ -95,7 +95,7 @@ TEST_F(GraphCopyTests, canPreserveAttributes) {
|
||||
ASSERT_STREQ(idMemInput.c_str(), "r-1-2-3");
|
||||
}
|
||||
|
||||
#ifdef ENABLE_GNA
|
||||
#ifdef ENABLE_INTEL_GNA
|
||||
using namespace GNAPluginNS;
|
||||
struct _FP32_2_FP32 : public GNAPluginNS::frontend::QuantDescTmpl<float, float, float, float, float> {
|
||||
};
|
||||
|
@ -65,7 +65,6 @@ struct convolution : public primitive_base<convolution> {
|
||||
deformable_groups(1),
|
||||
padding_above(tensor(0)),
|
||||
padding_below(tensor(0)),
|
||||
deformable_mode(false),
|
||||
grouped_weights_shape(grouped_weights_shape),
|
||||
weights(weights),
|
||||
bias(bias),
|
||||
@ -116,7 +115,6 @@ struct convolution : public primitive_base<convolution> {
|
||||
deformable_groups(1),
|
||||
padding_above(tensor(0)),
|
||||
padding_below(tensor(0)),
|
||||
deformable_mode(false),
|
||||
grouped_weights_shape(grouped_weights_shape),
|
||||
weights(weights),
|
||||
bias(bias),
|
||||
@ -174,7 +172,6 @@ struct convolution : public primitive_base<convolution> {
|
||||
deformable_groups(1),
|
||||
padding_above(tensor(0)),
|
||||
padding_below(tensor(0)),
|
||||
deformable_mode(false),
|
||||
grouped_weights_shape(grouped_weights_shape),
|
||||
weights(weights),
|
||||
bias(bias),
|
||||
@ -220,7 +217,6 @@ struct convolution : public primitive_base<convolution> {
|
||||
deformable_groups(1),
|
||||
padding_above(tensor(0)),
|
||||
padding_below(tensor(0)),
|
||||
deformable_mode(false),
|
||||
grouped_weights_shape(false),
|
||||
weights(weights),
|
||||
bias(bias),
|
||||
@ -266,7 +262,6 @@ struct convolution : public primitive_base<convolution> {
|
||||
deformable_groups(1),
|
||||
padding_above(padding_above),
|
||||
padding_below(padding_below),
|
||||
deformable_mode(false),
|
||||
grouped_weights_shape(false),
|
||||
weights(weights),
|
||||
bias(bias),
|
||||
@ -314,7 +309,6 @@ struct convolution : public primitive_base<convolution> {
|
||||
deformable_groups(1),
|
||||
padding_above(padding_above),
|
||||
padding_below(padding_below),
|
||||
deformable_mode(false),
|
||||
grouped_weights_shape(false),
|
||||
weights(weights),
|
||||
bias(bias),
|
||||
@ -360,7 +354,6 @@ struct convolution : public primitive_base<convolution> {
|
||||
deformable_groups(1),
|
||||
padding_above(tensor(0)),
|
||||
padding_below(tensor(0)),
|
||||
deformable_mode(false),
|
||||
grouped_weights_shape(grouped_weights_shape),
|
||||
weights(weights),
|
||||
bias(bias),
|
||||
@ -404,7 +397,6 @@ struct convolution : public primitive_base<convolution> {
|
||||
deformable_groups(1),
|
||||
padding_above(tensor(0)),
|
||||
padding_below(tensor(0)),
|
||||
deformable_mode(false),
|
||||
grouped_weights_shape(grouped_weights_shape),
|
||||
weights(weights),
|
||||
bias(std::vector<primitive_id>(0)),
|
||||
@ -446,7 +438,6 @@ struct convolution : public primitive_base<convolution> {
|
||||
deformable_groups(1),
|
||||
padding_above(padding_above),
|
||||
padding_below(padding_below),
|
||||
deformable_mode(false),
|
||||
grouped_weights_shape(false),
|
||||
weights(weights),
|
||||
bias(std::vector<primitive_id>(0)),
|
||||
@ -490,7 +481,6 @@ struct convolution : public primitive_base<convolution> {
|
||||
deformable_groups(1),
|
||||
padding_above(padding_above),
|
||||
padding_below(padding_below),
|
||||
deformable_mode(false),
|
||||
grouped_weights_shape(false),
|
||||
weights(weights),
|
||||
bias(std::vector<primitive_id>(0)),
|
||||
@ -531,7 +521,6 @@ struct convolution : public primitive_base<convolution> {
|
||||
deformable_groups(1),
|
||||
padding_above(tensor(0)),
|
||||
padding_below(tensor(0)),
|
||||
deformable_mode(false),
|
||||
grouped_weights_shape(grouped_weights_shape),
|
||||
weights(weights),
|
||||
bias(std::vector<primitive_id>(0)),
|
||||
@ -574,7 +563,6 @@ struct convolution : public primitive_base<convolution> {
|
||||
deformable_groups(1),
|
||||
padding_above(tensor(0)),
|
||||
padding_below(tensor(0)),
|
||||
deformable_mode(false),
|
||||
grouped_weights_shape(false),
|
||||
weights(weights),
|
||||
bias(bias),
|
||||
@ -618,7 +606,6 @@ struct convolution : public primitive_base<convolution> {
|
||||
deformable_groups(1),
|
||||
padding_above(tensor(0)),
|
||||
padding_below(tensor(0)),
|
||||
deformable_mode(false),
|
||||
grouped_weights_shape(false),
|
||||
weights(weights),
|
||||
bias(std::vector<primitive_id>(0)),
|
||||
@ -626,14 +613,14 @@ struct convolution : public primitive_base<convolution> {
|
||||
activations_zero_points(std::vector<primitive_id>(0)),
|
||||
compensation(std::vector<primitive_id>(0)) {}
|
||||
|
||||
/*
|
||||
/// @brief Constructs convolution primitive.
|
||||
/// @param id This primitive id.
|
||||
/// @param input Input primitive id.
|
||||
/// @param inputs Array of input primitive ids.
|
||||
/// @param weights List of primitive ids containing weights data.
|
||||
/// @param groups Number of filter groups.
|
||||
/// @param bias List of primitive ids containing bias data.
|
||||
/// @param pad Defines logical pad value added to input tensor
|
||||
/// @param input_offset Defines a shift, relative to (0,0) position of the input buffer,
|
||||
/// where (0,0) point of the convolution window should start calculations.
|
||||
/// @param stride Defines shift in input buffer between adjacent calculations of output values.
|
||||
/// @param deformable_groups Defines a number of deformable groups that splits trans input into several parts
|
||||
/// by channel dimension.
|
||||
@ -642,10 +629,11 @@ struct convolution : public primitive_base<convolution> {
|
||||
/// As an example in one dimension, a filter w of size 3 would compute over input x the following:
|
||||
/// w[0]*x[0] + w[1]*x[1] + w[2]*x[2] for dilation of 1.
|
||||
/// For dilation 2 the filter would instead compute w[0]*x[0] + w[1]*x[2] + w[2]*x[4].
|
||||
*/
|
||||
/// @param bilinear_interpolation_pad If bilinear_interpolation_pad is true and the sampling location is within
|
||||
/// one pixel outside of the feature map boundary, then bilinear interpolation is performed on the zero padded feature map.
|
||||
/// @param output_size Shape of the output
|
||||
convolution(const primitive_id& id,
|
||||
const primitive_id& input,
|
||||
const primitive_id& trans,
|
||||
const std::vector<primitive_id>& inputs,
|
||||
const std::vector<primitive_id>& weights,
|
||||
const std::vector<primitive_id>& bias,
|
||||
uint32_t groups,
|
||||
@ -654,25 +642,27 @@ struct convolution : public primitive_base<convolution> {
|
||||
tensor pad,
|
||||
tensor dilation,
|
||||
tensor output_size,
|
||||
bool bilinear_interpolation_pad = false,
|
||||
const primitive_id& ext_prim_id = "",
|
||||
const padding& output_padding = padding())
|
||||
: primitive_base(id, {input, trans}, ext_prim_id, output_padding),
|
||||
pad(pad),
|
||||
stride(stride),
|
||||
dilation(dilation),
|
||||
with_output_size(true),
|
||||
output_size(output_size),
|
||||
groups(groups),
|
||||
deformable_groups(deformable_groups),
|
||||
padding_above(tensor(0)),
|
||||
padding_below(tensor(0)),
|
||||
deformable_mode(true),
|
||||
grouped_weights_shape(false),
|
||||
weights(weights),
|
||||
bias(bias),
|
||||
weights_zero_points(std::vector<primitive_id>(0)),
|
||||
activations_zero_points(std::vector<primitive_id>(0)),
|
||||
compensation(std::vector<primitive_id>(0)) {
|
||||
: primitive_base(id, inputs, ext_prim_id, output_padding),
|
||||
pad(pad),
|
||||
stride(stride),
|
||||
dilation(dilation),
|
||||
with_output_size(true),
|
||||
output_size(output_size),
|
||||
groups(groups),
|
||||
deformable_groups(deformable_groups),
|
||||
padding_above(tensor(0)),
|
||||
padding_below(tensor(0)),
|
||||
deformable_mode {true},
|
||||
bilinear_interpolation_pad(bilinear_interpolation_pad),
|
||||
grouped_weights_shape(false),
|
||||
weights(weights),
|
||||
bias(bias),
|
||||
weights_zero_points(std::vector<primitive_id>(0)),
|
||||
activations_zero_points(std::vector<primitive_id>(0)),
|
||||
compensation(std::vector<primitive_id>(0)) {
|
||||
if ((bias.size() != 0) && (weights.size() != bias.size()))
|
||||
throw std::runtime_error("convolution's weights/bias count does not match");
|
||||
if ((groups > 1) && ((weights.size() != 1) || ((bias.size() != 0) && (bias.size() != 1))))
|
||||
@ -774,7 +764,12 @@ struct convolution : public primitive_base<convolution> {
|
||||
/// @param padding_below Defines a padding added to input image on right (x axis) and bottom (y axis).
|
||||
tensor padding_below;
|
||||
/// @param deformable_mode.
|
||||
bool deformable_mode;
|
||||
bool deformable_mode {false};
|
||||
/// if bilinear_interpolation_pad is true and the sampling location is within one pixel outside of the feature map boundary,
|
||||
/// then bilinear interpolation is performed on the zero padded feature map.
|
||||
/// If bilinear_interpolation_pad is false and the sampling location is within one pixel outside of the feature map boundary,
|
||||
/// then the sampling location shifts to the inner boundary of the feature map.
|
||||
bool bilinear_interpolation_pad {false};
|
||||
/// @param grouped_weights_shape Defines if weights tensor has explicit group dimension.
|
||||
bool grouped_weights_shape;
|
||||
/// @brief List of primitive ids containing weights data.
|
||||
@ -808,8 +803,7 @@ struct deformable_interp : public primitive_base<deformable_interp> {
|
||||
CLDNN_DECLARE_PRIMITIVE(deformable_interp)
|
||||
|
||||
deformable_interp(const primitive_id& id,
|
||||
const primitive_id& input,
|
||||
const primitive_id& trans,
|
||||
const std::vector<primitive_id>& inputs,
|
||||
uint32_t groups,
|
||||
uint32_t deformable_groups,
|
||||
tensor stride,
|
||||
@ -817,18 +811,20 @@ struct deformable_interp : public primitive_base<deformable_interp> {
|
||||
tensor dilation,
|
||||
tensor output_size,
|
||||
tensor kernel_size,
|
||||
bool bilinear_interpolation_pad,
|
||||
const primitive_id& ext_prim_id = "",
|
||||
const padding& output_padding = padding())
|
||||
: primitive_base(id, {input, trans}, ext_prim_id, output_padding),
|
||||
pad(pad),
|
||||
stride(stride),
|
||||
dilation(dilation),
|
||||
output_size(output_size),
|
||||
kernel_size(kernel_size),
|
||||
groups(groups),
|
||||
deformable_groups(deformable_groups),
|
||||
padding_above(tensor(0)),
|
||||
padding_below(tensor(0)) {}
|
||||
: primitive_base(id, inputs, ext_prim_id, output_padding),
|
||||
pad(pad),
|
||||
stride(stride),
|
||||
dilation(dilation),
|
||||
output_size(output_size),
|
||||
kernel_size(kernel_size),
|
||||
groups(groups),
|
||||
deformable_groups(deformable_groups),
|
||||
padding_above(tensor(0)),
|
||||
padding_below(tensor(0)),
|
||||
bilinear_interpolation_pad {bilinear_interpolation_pad} {}
|
||||
|
||||
/// @brief Defines logical pad value added to input tensor.
|
||||
tensor pad;
|
||||
@ -851,6 +847,9 @@ struct deformable_interp : public primitive_base<deformable_interp> {
|
||||
tensor padding_above;
|
||||
/// @param padding_below Defines a padding added to input image on right (x axis) and bottom (y axis).
|
||||
tensor padding_below;
|
||||
/// @brief if bilinear_interpolation_pad is true and the sampling location is within one pixel outside
|
||||
/// of the feature map boundary, then bilinear interpolation is performed on the zero padded feature map.
|
||||
bool bilinear_interpolation_pad {false};
|
||||
};
|
||||
|
||||
struct deformable_conv : public primitive_base<deformable_conv> {
|
||||
@ -864,11 +863,11 @@ struct deformable_conv : public primitive_base<deformable_conv> {
|
||||
tensor output_size,
|
||||
const primitive_id& ext_prim_id = "",
|
||||
const padding& output_padding = padding())
|
||||
: primitive_base(id, {input}, ext_prim_id, output_padding),
|
||||
output_size(output_size),
|
||||
groups(groups),
|
||||
weights(weights),
|
||||
bias(biases) {}
|
||||
: primitive_base(id, {input}, ext_prim_id, output_padding),
|
||||
output_size(output_size),
|
||||
groups(groups),
|
||||
weights(weights),
|
||||
bias(biases) {}
|
||||
|
||||
/// @brief User-defined output data size of the primitive (w/o padding).
|
||||
tensor output_size;
|
||||
|
@ -76,6 +76,10 @@ JitConstants ConvolutionKernelBase::GetJitConstants(const convolution_params& pa
|
||||
if (params.deformable_mode) {
|
||||
mem_consts.AddConstants({MakeJitConstant("DEFORMABLE_GROUPS", params.deformable_groups)});
|
||||
mem_consts.AddConstants({MakeJitConstant("DEFORMABLE_MODE", params.deformable_mode)});
|
||||
if (params.deformable_mask_enabled)
|
||||
mem_consts.AddConstants({MakeJitConstant("DEFORMABLE_MASK_ENABLED", params.deformable_mask_enabled)});
|
||||
if (params.bilinear_interpolation_pad)
|
||||
mem_consts.AddConstants({MakeJitConstant("BILINEAR_INTERPOLATION_PAD", params.bilinear_interpolation_pad)});
|
||||
}
|
||||
|
||||
std::vector<uint32_t> unrollLoopParams{params.filterSize.x,
|
||||
@ -243,6 +247,8 @@ KernelsData ConvolutionKernelBase::GetCommonKernelsData(const Params& params,
|
||||
|
||||
if (newParams.deformable_mode) {
|
||||
kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, 1});
|
||||
if (newParams.deformable_mask_enabled)
|
||||
kernel.params.arguments.push_back({ArgumentDescriptor::Types::INPUT, 2});
|
||||
}
|
||||
|
||||
if (!newParams.weights_zero_points.empty())
|
||||
|
@ -65,6 +65,10 @@ ParamsKey convolution_params::GetParamsKey() const {
|
||||
|
||||
if (deformable_mode) {
|
||||
k.EnableDeformableMode();
|
||||
if (bilinear_interpolation_pad)
|
||||
k.EnableBilinearInterpolationPad();
|
||||
if (deformable_mask_enabled)
|
||||
k.EnableDeformableMask();
|
||||
}
|
||||
|
||||
k.EnableQuantization(quantization);
|
||||
|
@ -30,6 +30,8 @@ struct convolution_params : public weight_bias_zero_point_params {
|
||||
uint32_t groups = 1;
|
||||
uSize kernelSize;
|
||||
uint32_t deformable_groups = 1;
|
||||
bool bilinear_interpolation_pad {false};
|
||||
bool deformable_mask_enabled {false};
|
||||
|
||||
std::string to_string() const override;
|
||||
std::string to_cache_string_v2() const override;
|
||||
|
@ -29,6 +29,8 @@ ParamsKey DeformableConvolutionKernel_bfyx_conv::GetSupportedKey() const {
|
||||
k.EnableLocalConvolution();
|
||||
k.EnableGroupedConvolution();
|
||||
k.EnableDeformableMode();
|
||||
k.EnableDeformableMask();
|
||||
k.EnableBilinearInterpolationPad();
|
||||
k.EnableSubGroup();
|
||||
k.EnableSubGroupShort();
|
||||
return k;
|
||||
|
@ -29,6 +29,8 @@ ParamsKey DeformableConvolutionKernel_bfyx_interp::GetSupportedKey() const {
|
||||
k.EnableLocalConvolution();
|
||||
k.EnableGroupedConvolution();
|
||||
k.EnableDeformableMode();
|
||||
k.EnableDeformableMask();
|
||||
k.EnableBilinearInterpolationPad();
|
||||
return k;
|
||||
}
|
||||
|
||||
@ -68,6 +70,9 @@ JitConstants DeformableConvolutionKernel_bfyx_interp::GetJitConstants(const conv
|
||||
});
|
||||
jit.AddConstants({MakeJitConstant("DEFORMABLE_GROUPS", params.deformable_groups)});
|
||||
jit.AddConstants({MakeJitConstant("DEFORMABLE_MODE", params.deformable_mode)});
|
||||
jit.AddConstants({MakeJitConstant("DEFORMABLE_MASK_ENABLED", params.deformable_mask_enabled)});
|
||||
jit.AddConstants({MakeJitConstant("BILINEAR_INTERPOLATION_PAD", params.bilinear_interpolation_pad)});
|
||||
|
||||
return jit;
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,8 @@ ParamsKey DeformableConvolutionKernel_bfyx_Ref::GetSupportedKey() const {
|
||||
k.EnableLocalConvolution();
|
||||
k.EnableGroupedConvolution();
|
||||
k.EnableDeformableMode();
|
||||
k.EnableDeformableMask();
|
||||
k.EnableBilinearInterpolationPad();
|
||||
return k;
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@ protected:
|
||||
return { FusedOpType::ELTWISE,
|
||||
FusedOpType::QUANTIZE,
|
||||
FusedOpType::SCALE,
|
||||
FusedOpType::REORDER,
|
||||
FusedOpType::ACTIVATION };
|
||||
}
|
||||
};
|
||||
|
@ -14,6 +14,7 @@ ParamsKey RegionYoloKernelRef::GetSupportedKey() const {
|
||||
k.EnableInputDataType(Datatype::F32);
|
||||
k.EnableOutputDataType(Datatype::F16);
|
||||
k.EnableOutputDataType(Datatype::F32);
|
||||
k.EnableDifferentTypes();
|
||||
k.EnableAllInputLayout();
|
||||
k.EnableAllOutputLayout();
|
||||
k.EnableTensorOffset();
|
||||
@ -54,8 +55,15 @@ RegionYoloKernelRef::DispatchData SetDefault(const region_yolo_params& params) {
|
||||
RegionYoloKernelRef::DispatchData dispatchData;
|
||||
|
||||
const auto& input = params.inputs[0];
|
||||
auto in_layout = params.inputs[0].GetLayout();
|
||||
auto out_layout = params.output.GetLayout();
|
||||
std::vector<std::vector<Tensor::DataChannelName>> dims_by_gws = {{ Tensor::DataChannelName::X, Tensor::DataChannelName::Y },
|
||||
{ Tensor::DataChannelName::FEATURE },
|
||||
{ Tensor::DataChannelName::BATCH }};
|
||||
|
||||
switch (input.GetLayout()) {
|
||||
case DataLayout::b_fs_yx_fsv16:
|
||||
case DataLayout::b_fs_yx_fsv32:
|
||||
case DataLayout::bfyx:
|
||||
case DataLayout::byxf: {
|
||||
uint32_t region_num = params.do_softmax ? params.num : params.mask_size;
|
||||
@ -64,7 +72,7 @@ RegionYoloKernelRef::DispatchData SetDefault(const region_yolo_params& params) {
|
||||
default:
|
||||
throw std::invalid_argument("Unsupported DataLayout");
|
||||
}
|
||||
dispatchData.lws = GetOptimalLocalWorkGroupSizes(dispatchData.gws, params.engineInfo);
|
||||
dispatchData.lws = GetOptimalLocalWorkGroupSizes(dispatchData.gws, params.engineInfo, in_layout, out_layout, dims_by_gws);
|
||||
|
||||
return dispatchData;
|
||||
}
|
||||
|
@ -50,5 +50,8 @@ public:
|
||||
protected:
|
||||
virtual JitConstants GetJitConstants(const region_yolo_params& params) const;
|
||||
bool Validate(const Params& p, const optional_params& o) const override;
|
||||
std::vector<FusedOpType> GetSupportedFusedOps() const override {
|
||||
return { FusedOpType::REORDER };
|
||||
}
|
||||
};
|
||||
} // namespace kernel_selector
|
||||
|
@ -9,6 +9,9 @@ __attribute__((intel_reqd_sub_group_size(16)))
|
||||
KERNEL(deformable_convolution_gpu_bfyx_interp)(
|
||||
const __global INPUT0_TYPE* data,
|
||||
const __global INPUT1_TYPE* trans,
|
||||
#if DEFORMABLE_MASK_ENABLED
|
||||
const __global INPUT2_TYPE* mask,
|
||||
#endif
|
||||
__global OUTPUT_TYPE* output)
|
||||
{
|
||||
const int xy = get_global_id(0);
|
||||
@ -24,37 +27,72 @@ KERNEL(deformable_convolution_gpu_bfyx_interp)(
|
||||
|
||||
const int channel_per_deformable_group = INPUT0_FEATURE_NUM / DEFORMABLE_GROUPS;
|
||||
|
||||
const int trans_offset = b * INPUT1_BATCH_PITCH +
|
||||
dg * 2 * FILTER_SIZE_Y * FILTER_SIZE_X * OUTPUT_SIZE_Y * OUTPUT_SIZE_X;
|
||||
const int input_offset_x = input_x + kw * DILATION_SIZE_X;
|
||||
const int input_offset_y = input_y + kh * DILATION_SIZE_Y;
|
||||
|
||||
#if DEFORMABLE_MASK_ENABLED
|
||||
const int dg_size = dg * FILTER_SIZE_Y * FILTER_SIZE_X * OUTPUT_SIZE_Y * OUTPUT_SIZE_X;
|
||||
const int trans_offset = b * INPUT1_BATCH_PITCH + 2 * dg_size;
|
||||
const int filter_part_offset = kh * FILTER_SIZE_X + kw;
|
||||
const int trans_x_idx = ((2 * filter_part_offset + 1) * OUTPUT_SIZE_Y + y) * OUTPUT_SIZE_X + x;
|
||||
const int trans_y_idx = (2 * filter_part_offset * OUTPUT_SIZE_Y + y) * OUTPUT_SIZE_X + x;
|
||||
const int mask_offset = b * INPUT2_BATCH_PITCH + dg_size;
|
||||
const int mask_idx = (filter_part_offset * OUTPUT_SIZE_Y + y) * OUTPUT_SIZE_X + x;
|
||||
#else
|
||||
const int trans_offset = b * INPUT1_BATCH_PITCH +
|
||||
dg * 2 * FILTER_SIZE_Y * FILTER_SIZE_X * OUTPUT_SIZE_Y * OUTPUT_SIZE_X;
|
||||
const int trans_x_idx = ((2 * (kh * FILTER_SIZE_X + kw) + 1) * OUTPUT_SIZE_Y + y) * OUTPUT_SIZE_X + x;
|
||||
const int trans_y_idx = ((2 * (kh * FILTER_SIZE_X + kw)) * OUTPUT_SIZE_Y + y) * OUTPUT_SIZE_X + x;
|
||||
float transformed_x = input_offset_x + trans[trans_offset + trans_x_idx];
|
||||
float transformed_y = input_offset_y + trans[trans_offset + trans_y_idx];
|
||||
const bool zero_y = transformed_y >= INPUT0_SIZE_Y || transformed_y < 0;
|
||||
const bool zero_x = transformed_x >= INPUT0_SIZE_X || transformed_x < 0;
|
||||
#endif
|
||||
float transformed_x = input_offset_x + (float) trans[trans_offset + trans_x_idx];
|
||||
float transformed_y = input_offset_y + (float) trans[trans_offset + trans_y_idx];
|
||||
#if BILINEAR_INTERPOLATION_PAD
|
||||
const bool x_is_out_of_boundaries = (int)transformed_x >= INPUT0_SIZE_X || (int)transformed_x <= -1;
|
||||
const bool y_is_out_of_boundaries = (int)transformed_y >= INPUT0_SIZE_Y || (int)transformed_y <= -1;
|
||||
#else
|
||||
const bool y_is_out_of_boundaries = transformed_y >= INPUT0_SIZE_Y || transformed_y < 0;
|
||||
const bool x_is_out_of_boundaries = transformed_x >= INPUT0_SIZE_X || transformed_x < 0;
|
||||
#endif
|
||||
|
||||
int top_y_index = (int)(floor(transformed_y));
|
||||
int bottom_y_index = (int)(min(ceil(transformed_y), (float)INPUT0_SIZE_Y - 1));
|
||||
int left_x_index = (int)(floor(transformed_x));
|
||||
#if BILINEAR_INTERPOLATION_PAD
|
||||
int bottom_y_index = top_y_index + 1;
|
||||
int right_x_index = left_x_index + 1;
|
||||
#else
|
||||
int bottom_y_index = (int)(min(ceil(transformed_y), (float)INPUT0_SIZE_Y - 1));
|
||||
int right_x_index = (int)(min(ceil(transformed_x), (float)INPUT0_SIZE_X - 1));
|
||||
#endif
|
||||
|
||||
int oc = kh*FILTER_SIZE_X*INPUT0_FEATURE_NUM + kw*INPUT0_FEATURE_NUM + dg*channel_per_deformable_group;
|
||||
const uint dst_index = GET_DATA_INDEX(OUTPUT, b, oc, y, x);
|
||||
if (!zero_y & !zero_x & xy < OUTPUT_SIZE_X*OUTPUT_SIZE_Y) {
|
||||
if (!y_is_out_of_boundaries & !x_is_out_of_boundaries & xy < OUTPUT_SIZE_X*OUTPUT_SIZE_Y) {
|
||||
for (int c = 0; c < channel_per_deformable_group; ++c) {
|
||||
uint ifm = dg * channel_per_deformable_group + c;
|
||||
|
||||
#if BILINEAR_INTERPOLATION_PAD
|
||||
INPUT0_TYPE top_left = top_y_index < 0 || left_x_index < 0 ? 0 : (INPUT0_TYPE)data[GET_DATA_INDEX(INPUT0, b, ifm, top_y_index, left_x_index)];
|
||||
INPUT0_TYPE top_right = top_y_index < 0 || right_x_index >= INPUT0_SIZE_X ? 0 :
|
||||
(INPUT0_TYPE)data[GET_DATA_INDEX(INPUT0, b, ifm, top_y_index, right_x_index)];
|
||||
INPUT0_TYPE bottom_left = bottom_y_index >= INPUT0_SIZE_Y || left_x_index < 0 ? 0 :
|
||||
(INPUT0_TYPE)data[GET_DATA_INDEX(INPUT0, b, ifm, bottom_y_index, left_x_index)];
|
||||
INPUT0_TYPE bottom_right = bottom_y_index >= INPUT0_SIZE_Y || right_x_index >= INPUT0_SIZE_X ? 0 :
|
||||
(INPUT0_TYPE)data[GET_DATA_INDEX(INPUT0, b, ifm, bottom_y_index, right_x_index)];
|
||||
#else
|
||||
INPUT0_TYPE top_left = (INPUT0_TYPE)data[GET_DATA_INDEX(INPUT0, b, ifm, top_y_index, left_x_index)];
|
||||
INPUT0_TYPE top_right = (INPUT0_TYPE)data[GET_DATA_INDEX(INPUT0, b, ifm, top_y_index, right_x_index)];
|
||||
INPUT0_TYPE bottom_left = (INPUT0_TYPE)data[GET_DATA_INDEX(INPUT0, b, ifm, bottom_y_index, left_x_index)];
|
||||
INPUT0_TYPE bottom_right = (INPUT0_TYPE)data[GET_DATA_INDEX(INPUT0, b, ifm, bottom_y_index, right_x_index)];
|
||||
#endif
|
||||
|
||||
INPUT0_TYPE top = top_left + (top_right - top_left) * (transformed_x - left_x_index);
|
||||
INPUT0_TYPE bottom = bottom_left + (bottom_right - bottom_left) * (transformed_x - left_x_index);
|
||||
|
||||
#if DEFORMABLE_MASK_ENABLED
|
||||
output[dst_index + c*OUTPUT_FEATURE_PITCH] = (top + (bottom - top) * (transformed_y - top_y_index)) * mask[mask_offset + mask_idx];
|
||||
#else
|
||||
output[dst_index + c*OUTPUT_FEATURE_PITCH] = top + (bottom - top) * (transformed_y - top_y_index);
|
||||
#endif
|
||||
}
|
||||
} else if (xy < OUTPUT_SIZE_X*OUTPUT_SIZE_Y) {
|
||||
for (int c = 0; c < channel_per_deformable_group; ++c) {
|
||||
|
@ -15,6 +15,9 @@ KERNEL(deformable_convolution_gpu_bfyx_ref)(
|
||||
#endif
|
||||
#if DEFORMABLE_MODE
|
||||
const __global INPUT1_TYPE* trans,
|
||||
#if DEFORMABLE_MASK_ENABLED
|
||||
const __global INPUT2_TYPE* mask,
|
||||
#endif
|
||||
#endif
|
||||
uint split_idx)
|
||||
{
|
||||
@ -48,8 +51,11 @@ KERNEL(deformable_convolution_gpu_bfyx_ref)(
|
||||
for (uint dg = 0; dg < DEFORMABLE_GROUPS; ++dg)
|
||||
{
|
||||
const int ifm_offset = dg * channel_per_deformable_group;
|
||||
const int trans_offset = b * INPUT1_BATCH_PITCH +
|
||||
dg * 2 * FILTER_SIZE_Y * FILTER_SIZE_X * OUTPUT_SIZE_Y * OUTPUT_SIZE_X;
|
||||
const int dg_offset = dg * FILTER_SIZE_Y * FILTER_SIZE_X * OUTPUT_SIZE_Y * OUTPUT_SIZE_X;
|
||||
const int trans_offset = b * INPUT1_BATCH_PITCH + 2 * dg_offset;
|
||||
#if DEFORMABLE_MASK_ENABLED
|
||||
const int mask_offset = b * INPUT2_BATCH_PITCH + dg_offset;
|
||||
#endif
|
||||
for (uint j = 0; j < FILTER_SIZE_Y ; ++j)
|
||||
{
|
||||
const int input_offset_y = input_y + j * DILATION_SIZE_Y;
|
||||
@ -57,46 +63,64 @@ KERNEL(deformable_convolution_gpu_bfyx_ref)(
|
||||
{
|
||||
const int trans_y_idx = ((2 * (j * FILTER_SIZE_X + i)) * OUTPUT_SIZE_Y + y) * OUTPUT_SIZE_X + x;
|
||||
float transformed_y = input_offset_y + (float)trans[trans_offset + trans_y_idx];
|
||||
|
||||
const bool zero_y = transformed_y >= INPUT0_SIZE_Y || transformed_y < 0;
|
||||
|
||||
const int input_offset_x = input_x + i * DILATION_SIZE_X;
|
||||
|
||||
const int trans_x_idx = ((2 * (j * FILTER_SIZE_X + i) + 1) * OUTPUT_SIZE_Y + y) * OUTPUT_SIZE_X + x;
|
||||
float transformed_x = input_offset_x + (float)trans[trans_offset + trans_x_idx];
|
||||
|
||||
const bool zero_x = transformed_x >= INPUT0_SIZE_X || transformed_x < 0;
|
||||
if(!zero_y) {
|
||||
if(!zero_x) {
|
||||
for (uint c = 0; c < channel_per_deformable_group; ++c) {
|
||||
uint ifm = ifm_offset + c;
|
||||
uint filter_idx = GET_FILTER_INDEX(FILTER, conv_group, f, ifm, j, i);
|
||||
#if BILINEAR_INTERPOLATION_PAD
|
||||
const bool x_is_out_of_boundaries = (int)transformed_x >= INPUT0_SIZE_X || (int)transformed_x <= -1;
|
||||
const bool y_is_out_of_boundaries = (int)transformed_y >= INPUT0_SIZE_Y || (int)transformed_y <= -1;
|
||||
#else
|
||||
const bool x_is_out_of_boundaries = transformed_x >= INPUT0_SIZE_X || transformed_x < 0;
|
||||
const bool y_is_out_of_boundaries = transformed_y >= INPUT0_SIZE_Y || transformed_y < 0;
|
||||
#endif
|
||||
if (!y_is_out_of_boundaries && !x_is_out_of_boundaries) {
|
||||
#if DEFORMABLE_MASK_ENABLED
|
||||
const int mask_idx = mask_offset + ((j * FILTER_SIZE_X + i) * OUTPUT_SIZE_Y + y) * OUTPUT_SIZE_X + x;
|
||||
#endif
|
||||
for (uint c = 0; c < channel_per_deformable_group; ++c) {
|
||||
uint ifm = ifm_offset + c;
|
||||
uint filter_idx = GET_FILTER_INDEX(FILTER, conv_group, f, ifm, j, i);
|
||||
|
||||
#ifdef LOCAL_CONVOLUTION
|
||||
filter_idx += FILTER_SIZE_X * FILTER_SIZE_Y * (x + OUTPUT_SIZE_X * y);
|
||||
filter_idx += FILTER_SIZE_X * FILTER_SIZE_Y * (x + OUTPUT_SIZE_X * y);
|
||||
#endif
|
||||
|
||||
int top_y_index = (int)(floor(transformed_y));
|
||||
int bottom_y_index = (int)(min(ceil(transformed_y), (float)INPUT0_SIZE_Y - 1));
|
||||
int top_y_index = (int)(floor(transformed_y));
|
||||
int left_x_index = (int)(floor(transformed_x));
|
||||
int right_x_index = (int)(min(ceil(transformed_x), (float)INPUT0_SIZE_X - 1));
|
||||
#if BILINEAR_INTERPOLATION_PAD
|
||||
int bottom_y_index = top_y_index + 1;
|
||||
int right_x_index = left_x_index + 1;
|
||||
|
||||
INPUT0_TYPE top_left = (INPUT0_TYPE)data[GET_DATA_INDEX(INPUT0, b, ifm, top_y_index, left_x_index) + in_split_offset];
|
||||
INPUT0_TYPE top_right = (INPUT0_TYPE)data[GET_DATA_INDEX(INPUT0, b, ifm, top_y_index, right_x_index) + in_split_offset];
|
||||
INPUT0_TYPE bottom_left = (INPUT0_TYPE)data[GET_DATA_INDEX(INPUT0, b, ifm, bottom_y_index, left_x_index) + in_split_offset];
|
||||
INPUT0_TYPE bottom_right = (INPUT0_TYPE)data[GET_DATA_INDEX(INPUT0, b, ifm, bottom_y_index, right_x_index) + in_split_offset];
|
||||
INPUT0_TYPE top_left = top_y_index < 0 || left_x_index < 0 ? 0 :
|
||||
(INPUT0_TYPE)data[GET_DATA_INDEX(INPUT0, b, ifm, top_y_index, left_x_index) + in_split_offset];
|
||||
INPUT0_TYPE top_right = top_y_index < 0 || right_x_index >= INPUT0_SIZE_X ? 0 :
|
||||
(INPUT0_TYPE)data[GET_DATA_INDEX(INPUT0, b, ifm, top_y_index, right_x_index) + in_split_offset];
|
||||
INPUT0_TYPE bottom_left = bottom_y_index >= INPUT0_SIZE_Y || left_x_index < 0 ? 0 :
|
||||
(INPUT0_TYPE)data[GET_DATA_INDEX(INPUT0, b, ifm, bottom_y_index, left_x_index) + in_split_offset];
|
||||
INPUT0_TYPE bottom_right = bottom_y_index >= INPUT0_SIZE_Y || right_x_index >= INPUT0_SIZE_X ? 0 :
|
||||
(INPUT0_TYPE)data[GET_DATA_INDEX(INPUT0, b, ifm, bottom_y_index, right_x_index) + in_split_offset];
|
||||
#else
|
||||
int bottom_y_index = (int)(min(ceil(transformed_y), (float)INPUT0_SIZE_Y - 1));
|
||||
int right_x_index = (int)(min(ceil(transformed_x), (float)INPUT0_SIZE_X - 1));
|
||||
|
||||
INPUT0_TYPE top = top_left + (top_right - top_left) * (transformed_x - left_x_index);
|
||||
INPUT0_TYPE bottom = bottom_left + (bottom_right - bottom_left) * (transformed_x - left_x_index);
|
||||
INPUT0_TYPE top_left = (INPUT0_TYPE)data[GET_DATA_INDEX(INPUT0, b, ifm, top_y_index, left_x_index) + in_split_offset];
|
||||
INPUT0_TYPE top_right = (INPUT0_TYPE)data[GET_DATA_INDEX(INPUT0, b, ifm, top_y_index, right_x_index) + in_split_offset];
|
||||
INPUT0_TYPE bottom_left = (INPUT0_TYPE)data[GET_DATA_INDEX(INPUT0, b, ifm, bottom_y_index, left_x_index) + in_split_offset];
|
||||
INPUT0_TYPE bottom_right = (INPUT0_TYPE)data[GET_DATA_INDEX(INPUT0, b, ifm, bottom_y_index, right_x_index) + in_split_offset];
|
||||
#endif
|
||||
INPUT0_TYPE top = top_left + (top_right - top_left) * (transformed_x - left_x_index);
|
||||
INPUT0_TYPE bottom = bottom_left + (bottom_right - bottom_left) * (transformed_x - left_x_index);
|
||||
|
||||
INPUT0_TYPE value = top + (bottom - top) * (transformed_y - top_y_index);
|
||||
INPUT0_TYPE value = top + (bottom - top) * (transformed_y - top_y_index);
|
||||
|
||||
dotProd += value * weights[filter_idx];
|
||||
}
|
||||
} // zero_x
|
||||
} // zero_y
|
||||
#if DEFORMABLE_MASK_ENABLED
|
||||
dotProd += value * weights[filter_idx] * (float)mask[mask_idx];
|
||||
#else
|
||||
dotProd += value * weights[filter_idx];
|
||||
#endif
|
||||
}
|
||||
} // !y_is_out_of_boundaries && !x_is_out_of_boundaries
|
||||
} // i
|
||||
|
||||
} // j
|
||||
} // dg
|
||||
|
||||
|
@ -73,8 +73,10 @@ KERNEL (region_yolo_ref)(const __global INPUT0_TYPE* input, __global OUTPUT_TYPE
|
||||
#else
|
||||
for (int j = 0; j < CLASSES; j++)
|
||||
{
|
||||
in_i = INPUT0_GET_INDEX(batch, COORDS + 1 + j + region_offset, y_index, x_index);
|
||||
output[in_i] = FUNC_CALL(logistic_activate)(input[in_i]);
|
||||
volatile int var = COORDS + 1 + j + region_offset; // WA for igc crash
|
||||
in_i = INPUT0_GET_INDEX(batch, var, y_index, x_index);
|
||||
out_i = FUNC_CALL(output_index)(batch, region_num, x_index, y_index, xy, COORDS + 1 + j + region_offset);
|
||||
output[out_i] = FUNC_CALL(logistic_activate)(input[in_i]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -132,6 +132,8 @@ public:
|
||||
uint32_t local : 1;
|
||||
uint32_t grouped : 1;
|
||||
uint32_t deformable : 1;
|
||||
uint32_t bilinear_interpolation_pad : 1;
|
||||
uint32_t deformable_mask_enabled : 1;
|
||||
} conv;
|
||||
struct fc_t {
|
||||
} fc;
|
||||
@ -288,6 +290,8 @@ public:
|
||||
void EnableLocalConvolution() { key.restrict.val.dedicated.conv.local = 1; }
|
||||
void EnableGroupedConvolution() { key.restrict.val.dedicated.conv.grouped = 1; }
|
||||
void EnableDeformableMode() { key.restrict.val.dedicated.conv.deformable = 1; }
|
||||
void EnableBilinearInterpolationPad() { key.restrict.val.dedicated.conv.bilinear_interpolation_pad = 1; }
|
||||
void EnableDeformableMask() { key.restrict.val.dedicated.conv.deformable_mask_enabled = 1; }
|
||||
|
||||
void EnableQuantizePackedBinaryOutput() { key.restrict.val.dedicated.quantize.packed_binary_output = 1; }
|
||||
void EnableQuantizeScaleShiftOpt() { key.restrict.val.dedicated.quantize.scale_shift_opt = 1; }
|
||||
|
@ -96,6 +96,7 @@ std::string deformable_interp_inst::to_string(deformable_interp_node const& node
|
||||
interp_info.add("dilation", dilation.to_string());
|
||||
interp_info.add("deformable_groups", desc->deformable_groups);
|
||||
interp_info.add("groups", desc->groups);
|
||||
interp_info.add("bilinear_interpolation_pad", desc->bilinear_interpolation_pad);
|
||||
|
||||
json_composite ud_out_size_info;
|
||||
ud_out_size_info.add("size", desc->output_size.to_string());
|
||||
|
@ -14,6 +14,8 @@
|
||||
#include "reshape_inst.h"
|
||||
#include "one_hot_inst.h"
|
||||
#include "permute_inst.h"
|
||||
#include "depth_to_space_inst.h"
|
||||
#include "region_yolo_inst.h"
|
||||
|
||||
using namespace cldnn;
|
||||
|
||||
@ -307,33 +309,31 @@ void remove_redundant_reorders::run(program& p) {
|
||||
auto& input = node.input();
|
||||
auto output_layout = node.get_output_layout();
|
||||
|
||||
if (node.is_output())
|
||||
continue;
|
||||
|
||||
if (node.has_mean() || !node.get_primitive()->subtract_per_feature.empty())
|
||||
continue;
|
||||
|
||||
if (!node.get_fused_activations_funcs().empty())
|
||||
continue;
|
||||
|
||||
if (input.get_users().size() != 1 || node.get_users().empty())
|
||||
if (input.get_users().size() != 1)
|
||||
continue;
|
||||
|
||||
bool same_data_type = input.get_output_layout().data_type == output_layout.data_type;
|
||||
bool allowed_dt_conversion_fuse = (input.is_type<one_hot>()) || (input.is_type<permute>());
|
||||
bool allowed_dt_conversion_fuse = (input.is_type<one_hot>() || input.is_type<permute>() ||
|
||||
input.is_type<depth_to_space>() || input.is_type<region_yolo>());
|
||||
if (!same_data_type && !allowed_dt_conversion_fuse)
|
||||
continue;
|
||||
|
||||
if (!lo.can_fuse_reorder_to_prev(input, *node.get_users().front(), input.get_output_layout().format, output_layout.format))
|
||||
auto next_node = node.get_users().empty() ? nullptr : node.get_users().front();
|
||||
if (!lo.can_fuse_reorder_to_prev(input, next_node, input.get_output_layout().format, output_layout.format))
|
||||
continue;
|
||||
|
||||
auto old_output_layout_of_input = input.get_output_layout();
|
||||
input.set_output_layout(output_layout, false);
|
||||
if (input.type()->does_possible_implementation_exist(input)) {
|
||||
p.replace_all_usages(node, input);
|
||||
node.can_be_optimized(true);
|
||||
p.add_optimized_primitive_info(node.id());
|
||||
p.remove_all_connections(node);
|
||||
p.remove_if_dangling(node);
|
||||
p.extract_and_remove(node);
|
||||
} else {
|
||||
input.set_output_layout(old_output_layout_of_input, false);
|
||||
}
|
||||
|
@ -81,6 +81,11 @@ public:
|
||||
if (primitive->deformable_mode) {
|
||||
conv_params.inputs.push_back(convert_data_tensor(arg.trans().get_output_layout()));
|
||||
conv_params.deformable_mode = true;
|
||||
if (primitive->input.size() == 3) {
|
||||
conv_params.inputs.push_back(convert_data_tensor(arg.mask().get_output_layout()));
|
||||
conv_params.deformable_mask_enabled = true;
|
||||
}
|
||||
conv_params.bilinear_interpolation_pad = arg.bilinear_interpolation_pad();
|
||||
}
|
||||
|
||||
conv_params.transposed = transposed;
|
||||
|
@ -111,6 +111,11 @@ public:
|
||||
conv_params.weights = convert_weights_tensor(weights_layout);
|
||||
|
||||
conv_params.inputs.push_back(convert_data_tensor(arg.trans().get_output_layout()));
|
||||
if (primitive->input.size() == 3) {
|
||||
conv_params.inputs.push_back(convert_data_tensor(arg.mask().get_output_layout()));
|
||||
conv_params.deformable_mask_enabled = true;
|
||||
}
|
||||
conv_params.bilinear_interpolation_pad = primitive->bilinear_interpolation_pad;
|
||||
conv_params.deformable_groups = deformable_groups;
|
||||
|
||||
conv_params.padding = {(uint32_t)std::max(pad.spatial[0], 0),
|
||||
|
@ -63,6 +63,10 @@ attach_depth_to_space_impl::attach_depth_to_space_impl() {
|
||||
std::make_tuple(data_types::f16, format::b_fs_yx_fsv16),
|
||||
std::make_tuple(data_types::u8, format::b_fs_yx_fsv16),
|
||||
std::make_tuple(data_types::i8, format::b_fs_yx_fsv16),
|
||||
std::make_tuple(data_types::f32, format::b_fs_yx_fsv32),
|
||||
std::make_tuple(data_types::f16, format::b_fs_yx_fsv32),
|
||||
std::make_tuple(data_types::u8, format::b_fs_yx_fsv32),
|
||||
std::make_tuple(data_types::i8, format::b_fs_yx_fsv32),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -55,6 +55,10 @@ attach_region_yolo_impl::attach_region_yolo_impl() {
|
||||
std::make_tuple(data_types::f16, format::bfyx),
|
||||
std::make_tuple(data_types::f32, format::byxf),
|
||||
std::make_tuple(data_types::f16, format::byxf),
|
||||
std::make_tuple(data_types::f32, format::b_fs_yx_fsv16),
|
||||
std::make_tuple(data_types::f16, format::b_fs_yx_fsv16),
|
||||
std::make_tuple(data_types::f32, format::b_fs_yx_fsv32),
|
||||
std::make_tuple(data_types::f16, format::b_fs_yx_fsv32),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,12 @@ public:
|
||||
void set_deformable_groups(uint32_t node_deformable_groups) { deformable_groups = node_deformable_groups; }
|
||||
uint32_t get_deformable_groups() const { return deformable_groups; }
|
||||
|
||||
int32_t get_trans_dep_offset() const { return deformable_mode ? 1 : 0; }
|
||||
int32_t get_deform_conv_dep_offset() const {
|
||||
auto offset = deformable_mode ? 1 : 0;
|
||||
if (get_primitive()->input.size() == 3)
|
||||
offset++;
|
||||
return offset;
|
||||
}
|
||||
|
||||
program_node& input() const { return get_dependency(0); }
|
||||
|
||||
@ -52,21 +57,21 @@ public:
|
||||
if (static_cast<int32_t>(idx) >= this->get_split())
|
||||
throw std::range_error("weights offset too big");
|
||||
|
||||
return get_dependency(1 + idx + get_trans_dep_offset());
|
||||
return get_dependency(1 + idx + get_deform_conv_dep_offset());
|
||||
}
|
||||
|
||||
program_node& bias(size_t idx = 0) const {
|
||||
if (static_cast<int32_t>(idx) >= this->get_split())
|
||||
throw std::range_error("bias offset too big");
|
||||
|
||||
return get_dependency(1 + this->get_split() + idx + get_trans_dep_offset());
|
||||
return get_dependency(1 + this->get_split() + idx + get_deform_conv_dep_offset());
|
||||
}
|
||||
|
||||
program_node& weights_zero_points(size_t idx = 0) const {
|
||||
if (static_cast<int32_t>(idx) >= this->get_split())
|
||||
throw std::range_error("weights zero points offset too big");
|
||||
|
||||
return get_dependency(1 + (1 + 1 * bias_term()) * this->get_split() + idx + get_trans_dep_offset());
|
||||
return get_dependency(1 + (1 + 1 * bias_term()) * this->get_split() + idx + get_deform_conv_dep_offset());
|
||||
}
|
||||
|
||||
program_node& activations_zero_points(size_t idx = 0) const {
|
||||
@ -74,7 +79,7 @@ public:
|
||||
throw std::range_error("activations zero points offset too big");
|
||||
|
||||
return get_dependency(1 + (1 + 1 * bias_term() + 1 * weights_zero_points_term()) * this->get_split() + idx +
|
||||
get_trans_dep_offset());
|
||||
get_deform_conv_dep_offset());
|
||||
}
|
||||
|
||||
program_node& compensation(size_t idx = 0) const {
|
||||
@ -82,7 +87,7 @@ public:
|
||||
throw std::range_error("activations zero points offset too big");
|
||||
|
||||
return get_dependency(1 + (1 + 1 * bias_term() + 1 * weights_zero_points_term() + 1*activations_zero_points_term()) * this->get_split()
|
||||
+ idx + get_trans_dep_offset());
|
||||
+ idx + get_deform_conv_dep_offset());
|
||||
}
|
||||
|
||||
program_node& trans() const {
|
||||
@ -92,6 +97,23 @@ public:
|
||||
return get_dependency(1);
|
||||
}
|
||||
|
||||
program_node& mask() const {
|
||||
if (!deformable_mode)
|
||||
throw std::range_error("Mask input exists only in deformable mode");
|
||||
|
||||
return get_dependency(2);
|
||||
}
|
||||
|
||||
bool bilinear_interpolation_pad() const {
|
||||
if (!deformable_mode)
|
||||
throw std::range_error("bilinear_interpolation_pad exists only in deformable mode");
|
||||
return get_primitive()->bilinear_interpolation_pad;
|
||||
}
|
||||
|
||||
bool get_deformable_mode() const {
|
||||
return deformable_mode;
|
||||
}
|
||||
|
||||
bool bias_term() const { return get_primitive()->bias.size() > 0; }
|
||||
|
||||
bool weights_zero_points_term() const { return get_primitive()->weights_zero_points.size() > 0; }
|
||||
@ -124,9 +146,9 @@ public:
|
||||
if (node.get_groups() == 1) {
|
||||
if (static_cast<int32_t>(index) >= node.get_split())
|
||||
throw std::range_error("weights offset too big");
|
||||
return dep_memory_ptr(1 + index + node.get_trans_dep_offset());
|
||||
return dep_memory_ptr(1 + index + node.get_deform_conv_dep_offset());
|
||||
} else { // all weights are in one buffer
|
||||
return dep_memory_ptr(1 + node.get_trans_dep_offset());
|
||||
return dep_memory_ptr(1 + node.get_deform_conv_dep_offset());
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,20 +156,20 @@ public:
|
||||
if (node.get_groups() == 1) {
|
||||
if (static_cast<int32_t>(index) >= node.get_split())
|
||||
throw std::range_error("bias offset too big");
|
||||
return dep_memory_ptr(1 + node.get_split() + index + node.get_trans_dep_offset());
|
||||
return dep_memory_ptr(1 + node.get_split() + index + node.get_deform_conv_dep_offset());
|
||||
} else { // all bias are in one buffer
|
||||
return dep_memory_ptr(2 + node.get_trans_dep_offset());
|
||||
return dep_memory_ptr(2 + node.get_deform_conv_dep_offset());
|
||||
}
|
||||
}
|
||||
|
||||
memory::ptr weights_zero_points_memory(size_t) const {
|
||||
if (node.get_split() > 1)
|
||||
throw std::range_error("Split is unsupported for quantized convolutions");
|
||||
return dep_memory_ptr(2 + 1 * bias_term() + node.get_trans_dep_offset());
|
||||
return dep_memory_ptr(2 + 1 * bias_term() + node.get_deform_conv_dep_offset());
|
||||
}
|
||||
|
||||
memory::ptr trans_memory() const {
|
||||
if (!node.get_trans_dep_offset())
|
||||
if (!node.get_deform_conv_dep_offset())
|
||||
throw std::range_error("trans input exists only in deformable mode");
|
||||
return dep_memory_ptr(1);
|
||||
}
|
||||
@ -155,13 +177,13 @@ public:
|
||||
memory::ptr activations_zero_points_memory(size_t) const {
|
||||
if (node.get_split() > 1)
|
||||
throw std::range_error("Split is unsupported for quantized convolutions");
|
||||
return dep_memory_ptr(2 + 1 * bias_term() + 1 * weights_zero_points_term() + node.get_trans_dep_offset());
|
||||
return dep_memory_ptr(2 + 1 * bias_term() + 1 * weights_zero_points_term() + node.get_deform_conv_dep_offset());
|
||||
}
|
||||
|
||||
memory::ptr compensation_memory(size_t) const {
|
||||
if (node.get_split() > 1)
|
||||
throw std::range_error("Split is unsupported for quantized convolutions");
|
||||
return dep_memory_ptr(2 + 1 * bias_term() + 1 * weights_zero_points_term() + 1*activations_zero_points_term() + node.get_trans_dep_offset());
|
||||
return dep_memory_ptr(2 + 1 * bias_term() + 1 * weights_zero_points_term() + 1*activations_zero_points_term() + node.get_deform_conv_dep_offset());
|
||||
}
|
||||
|
||||
bool bias_term() const { return node.bias_term(); }
|
||||
|
@ -133,6 +133,7 @@ public:
|
||||
|
||||
program_node& input() const { return get_dependency(0); }
|
||||
program_node& trans() const { return get_dependency(1); }
|
||||
program_node& mask() const { return get_dependency(2); }
|
||||
|
||||
private:
|
||||
int32_t split;
|
||||
@ -156,6 +157,7 @@ public:
|
||||
typed_primitive_inst(network& network, deformable_interp_node const& node);
|
||||
|
||||
memory& trans_memory() const { return dep_memory(1); }
|
||||
memory& mask_memory() const { return dep_memory(2); }
|
||||
};
|
||||
|
||||
using deformable_interp_inst = typed_primitive_inst<deformable_interp>;
|
||||
|
@ -189,7 +189,7 @@ public:
|
||||
// Returns whether reorder between "prev" with format fmt_prev and "next" with format fmt_next
|
||||
// can be fused into next.
|
||||
bool can_fuse_reorder(program_node& prev, program_node& next, format fmt_prev, format fmt_next);
|
||||
bool can_fuse_reorder_to_prev(program_node& prev, program_node& next, format fmt_prev, format fmt_next);
|
||||
bool can_fuse_reorder_to_prev(program_node& prev, program_node* next, format fmt_prev, format fmt_next);
|
||||
|
||||
void set_optimization_attribute(optimization_attributes_type attribute, int32_t val);
|
||||
optimization_attributes get_optimization_attributes() { return _optimization_attributes; }
|
||||
|
@ -18,6 +18,8 @@
|
||||
#include "permute_inst.h"
|
||||
#include "quantize_inst.h"
|
||||
#include "mvn_inst.h"
|
||||
#include "depth_to_space_inst.h"
|
||||
#include "region_yolo_inst.h"
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
@ -347,9 +349,14 @@ bool layout_optimizer::can_fuse_reorder(program_node& prev, program_node& next,
|
||||
return false;
|
||||
}
|
||||
|
||||
bool layout_optimizer::can_fuse_reorder_to_prev(program_node& prev, program_node& next, format fmt_prev, format fmt_next) {
|
||||
bool layout_optimizer::can_fuse_reorder_to_prev(program_node& prev, program_node* next, format fmt_prev, format fmt_next) {
|
||||
if (next == nullptr) {
|
||||
// Ref kernels are the main for depth_to_space and region_yolo. It can do anything
|
||||
return prev.is_type<depth_to_space>() || prev.is_type<region_yolo>();
|
||||
}
|
||||
|
||||
auto dt_prev = prev.get_output_layout().data_type;
|
||||
auto dt_next = next.get_output_layout().data_type;
|
||||
auto dt_next = next->get_output_layout().data_type;
|
||||
auto use_onednn_impls = _optimization_attributes.use_onednn_impls;
|
||||
|
||||
if (prev.is_type<reorder>())
|
||||
|
@ -344,8 +344,7 @@ TEST(deformable_convolution_f32_fw_gpu, basic_deformable_convolution_def_group1_
|
||||
data("biases", biases),
|
||||
convolution(
|
||||
"conv",
|
||||
"input",
|
||||
"trans",
|
||||
{"input", "trans"},
|
||||
{ "weights" },
|
||||
{ "biases" },
|
||||
1,
|
||||
@ -476,8 +475,7 @@ TEST(deformable_convolution_f32_fw_gpu, basic_deformable_convolution_def_group1)
|
||||
data("biases", biases),
|
||||
convolution(
|
||||
"conv",
|
||||
"input",
|
||||
"trans",
|
||||
{"input", "trans"},
|
||||
{ "weights" },
|
||||
{ "biases" },
|
||||
1,
|
||||
@ -640,8 +638,7 @@ TEST(deformable_convolution_f32_fw_gpu, basic_deformable_convolution) {
|
||||
data("biases", biases),
|
||||
convolution(
|
||||
"conv",
|
||||
"input",
|
||||
"trans",
|
||||
{"input", "trans"},
|
||||
{ "weights" },
|
||||
{ "biases" },
|
||||
1,
|
||||
|
@ -11,4 +11,7 @@ ie_cpack_add_component(licensing)
|
||||
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
DESTINATION .
|
||||
COMPONENT licensing
|
||||
PATTERN CMakeLists.txt EXCLUDE)
|
||||
PATTERN CMakeLists.txt EXCLUDE
|
||||
PATTERN dev-third-party-programs.txt EXCLUDE
|
||||
PATTERN documentation-third-party-programs.txt EXCLUDE
|
||||
PATTERN third-party-programs.txt EXCLUDE)
|
||||
|
@ -1,9 +0,0 @@
|
||||
# Copyright (C) 2018-2021 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
ie_add_sample(NAME object_detection_sample_ssd_c
|
||||
SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/main.c"
|
||||
HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/object_detection_sample_ssd.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/c_w_dirent.h"
|
||||
DEPENDENCIES opencv_c_wrapper)
|
@ -1,171 +0,0 @@
|
||||
# Object Detection SSD C Sample {#openvino_inference_engine_ie_bridges_c_samples_object_detection_sample_ssd_README}
|
||||
|
||||
This sample demonstrates how to execute an inference of object detection networks like SSD-VGG using Asynchronous Inference Request API and [input reshape feature](../../../docs/IE_DG/ShapeInference.md).
|
||||
|
||||
Object Detection SSD C sample application demonstrates how to use the following Inference Engine C API in applications:
|
||||
|
||||
| Feature | API | Description |
|
||||
|:--- |:--- |:---
|
||||
|Asynchronous Infer |[ie_infer_request_infer_async][ie_infer_request_wait]| Do Asynchronous inference
|
||||
|Inference Engine Version| [ie_c_api_version] | Get Inference Engine API version
|
||||
|Available Devices| [ie_core_get_versions] | Get version information of the devices for inference
|
||||
|Custom Extension Kernels|[ie_core_add_extension] [ie_core_set_config]| Load extension library and config to the device
|
||||
|Network Operations|[ie_network_get_inputs_number] [ie_network_get_input_dims] [ie_network_get_input_shapes] [ie_network_get_outputs_number] [ie_network_get_output_dims]| Managing of network
|
||||
|Blob Operations|[ie_blob_get_buffer]| Work with memory container for storing inputs, outputs of the network, weights and biases of the layers
|
||||
|Input Reshape|[ie_network_reshape]| Set the batch size equal to the number of input images
|
||||
|
||||
Basic Inference Engine API is covered by [Hello Classification C sample](../hello_classification/README.md).
|
||||
|
||||
> **NOTE**: This sample uses `ie_network_reshape()` to set the batch size. While supported by SSD networks, reshape may not work with arbitrary topologies. See [Shape Inference Guide](../../../docs/IE_DG/ShapeInference.md) for more info.
|
||||
|
||||
| Options | Values |
|
||||
|:--- |:---
|
||||
| Validated Models | [person-detection-retail-0013](@ref omz_models_model_person_detection_retail_0013)
|
||||
| Model Format | Inference Engine Intermediate Representation (.xml + .bin), ONNX (.onnx)
|
||||
| Validated images | The sample uses OpenCV* to [read input image](https://docs.opencv.org/master/d4/da8/group__imgcodecs.html#ga288b8b3da0892bd651fce07b3bbd3a56) (.bmp, .png, .jpg)
|
||||
| Supported devices | [All](../../../docs/IE_DG/supported_plugins/Supported_Devices.md) |
|
||||
| Other language realization | [C++](../../../samples/cpp/object_detection_sample_ssd/README.md) |
|
||||
|
||||
## How It Works
|
||||
|
||||
Upon the start-up the sample application reads command line parameters, loads specified network and image(s) to the Inference
|
||||
Engine plugin. Then, the sample creates an asynchronous inference request object. When inference is done, the application creates output image(s) and output data to the standard output stream.
|
||||
|
||||
You can see the explicit description of
|
||||
each sample step at [Integration Steps](../../../docs/IE_DG/Integrate_with_customer_application_new_API.md) section of "Integrate the Inference Engine with Your Application" guide.
|
||||
|
||||
## Building
|
||||
|
||||
To build the sample, please use instructions available at [Build the Sample Applications](../../../docs/IE_DG/Samples_Overview.md) section in Inference Engine Samples guide.
|
||||
|
||||
## Running
|
||||
|
||||
To run the sample, you need specify a model and image:
|
||||
|
||||
- you can use [public](@ref omz_models_group_public) or [Intel's](@ref omz_models_group_intel) pre-trained models from the Open Model Zoo. The models can be downloaded using the [Model Downloader](@ref omz_tools_downloader).
|
||||
- you can use images from the media files collection available at https://storage.openvinotoolkit.org/data/test_data.
|
||||
|
||||
Running the application with the `-h` option yields the following usage message:
|
||||
|
||||
```
|
||||
<path_to_sample>/object_detection_sample_ssd_c -h
|
||||
[ INFO ] InferenceEngine:
|
||||
<version><number>
|
||||
[ INFO ] Parsing input parameters
|
||||
|
||||
object_detection_sample_ssd_c [OPTION]
|
||||
Options:
|
||||
|
||||
-h Print a usage message.
|
||||
-m "<path>" Required. Path to an .xml file with a trained model.
|
||||
-i "<path>" Required. Path to one or more images or folder with images.
|
||||
-l "<absolute_path>" Required for CPU plugin custom layers. Absolute path to a shared library with the kernels implementations.
|
||||
Or
|
||||
-c "<absolute_path>" Required for GPU, MYRIAD, HDDL custom kernels. Absolute path to the .xml config file
|
||||
with the kernels descriptions.
|
||||
-d "<device>" Optional. Specify the target device to infer. Default value is CPU.
|
||||
Use "-d HETERO:<comma-separated_devices_list>" format to specify HETERO plugin. Sample will look for a suitable plugin for device specified
|
||||
-g Path to the configuration file. Default value: "config".
|
||||
```
|
||||
|
||||
> **NOTES**:
|
||||
>
|
||||
> - 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).
|
||||
>
|
||||
> - 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.
|
||||
|
||||
### Example
|
||||
1. Download a pre-trained model using [Model Downloader](@ref omz_tools_downloader):
|
||||
```
|
||||
python <path_to_omz_tools>/downloader.py --name person-detection-retail-0013
|
||||
```
|
||||
|
||||
2. `person-detection-retail-0013` model does not need to be converted, because it is already in necessary format, so you can skip this step. If you want to use a other model that is not in the Inference Engine IR or ONNX format, you can convert it using the model converter script:
|
||||
|
||||
```
|
||||
python <path_to_omz_tools>/converter.py --name <model_name>
|
||||
```
|
||||
|
||||
3. For example, to perform inference on a CPU with the OpenVINO™ toolkit person detection SSD models, run one of the following commands:
|
||||
|
||||
- with one image and [person-detection-retail-0013](https://docs.openvinotoolkit.org/latest/omz_models_intel_person_detection_retail_0013_description_person_detection_retail_0013.html) model
|
||||
|
||||
```
|
||||
<path_to_sample>/object_detection_sample_ssd_c -i <path_to_image>/inputImage.bmp -m <path_to_model>/person-detection-retail-0013.xml -d CPU
|
||||
```
|
||||
|
||||
- with some images and [person-detection-retail-0013](https://docs.openvinotoolkit.org/latest/omz_models_intel_person_detection_retail_0013_description_person_detection_retail_0013.html) model
|
||||
|
||||
```
|
||||
<path_to_sample>/object_detection_sample_ssd_c -i <path_to_image>/inputImage1.bmp <path_to_image>/inputImage2.bmp ... -m <path_to_model>/person-detection-retail-0013.xml -d CPU
|
||||
```
|
||||
|
||||
- with [person-detection-retail-0002](https://docs.openvinotoolkit.org/latest/omz_models_intel_person_detection_retail_0002_description_person_detection_retail_0002.html) model
|
||||
|
||||
```
|
||||
<path_to_sample>/object_detection_sample_ssd_c -i <path_to_folder_with_images> -m <path_to_model>/person-detection-retail-0002.xml -d CPU
|
||||
```
|
||||
|
||||
## Sample Output
|
||||
|
||||
The application outputs several images (`out_0.bmp`, `out_1.bmp`, ... ) with detected objects enclosed in rectangles. It outputs the list of
|
||||
classes of the detected objects along with the respective confidence values and the coordinates of the rectangles to the standard output stream.
|
||||
|
||||
```
|
||||
<path_to_sample>/object_detection_sample_ssd_c -m person-detection-retail-0013.xml -i image_1.png image_2.jpg
|
||||
|
||||
[ INFO ] InferenceEngine:
|
||||
<version><number>
|
||||
[ INFO ] Parsing input parameters
|
||||
[ INFO ] Files were added: 2
|
||||
[ INFO ] image_1.png
|
||||
[ INFO ] image_2.jpg
|
||||
[ INFO ] Loading Inference Engine
|
||||
[ INFO ] Device info:
|
||||
CPU
|
||||
MKLDNNPlugin version ......... <version><number>
|
||||
Build ......... <version><number>
|
||||
[ INFO ] Loading network:
|
||||
person-detection-retail-0013.xml
|
||||
[ INFO ] Preparing input blobs
|
||||
[ WARNING ] Image is resized from (1699, 960) to (544, 320)
|
||||
[ WARNING ] Image is resized from (614, 346) to (544, 320)
|
||||
[ INFO ] Batch size is 2
|
||||
[ INFO ] Preparing output blobs
|
||||
[ INFO ] Loading model to the device
|
||||
[ INFO ] Create infer request
|
||||
[ INFO ] Start inference
|
||||
[ INFO ] Processing output blobs
|
||||
[0, 1] element, prob = 0.999090 (370, 201)-(634, 762) batch id : 0 WILL BE PRINTED!
|
||||
[1, 1] element, prob = 0.997386 (836, 192)-(999, 663) batch id : 0 WILL BE PRINTED!
|
||||
[2, 1] element, prob = 0.314753 (192, 2)-(265, 172) batch id : 0
|
||||
...
|
||||
[ INFO ] Image out_0.bmp created!
|
||||
[ INFO ] Image out_1.bmp created!
|
||||
[ INFO ] Execution successful
|
||||
|
||||
This sample is an API example, for any performance measurements please use the dedicated benchmark_app tool
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
- [Integrate the Inference Engine with Your Application](../../../docs/IE_DG/Integrate_with_customer_application_new_API.md)
|
||||
- [Using Inference Engine Samples](../../../docs/IE_DG/Samples_Overview.md)
|
||||
- [Model Downloader](@ref omz_tools_downloader)
|
||||
- [Model Optimizer](../../../docs/MO_DG/Deep_Learning_Model_Optimizer_DevGuide.md)
|
||||
|
||||
[ie_infer_request_infer_async]:https://docs.openvinotoolkit.org/latest/ie_c_api/group__InferRequest.html#gad2351010e292b6faec959a3d5a8fb60e
|
||||
[ie_infer_request_wait]:https://docs.openvinotoolkit.org/latest/ie_c_api/group__InferRequest.html#ga0c05e63e63c8d9cdd92900e82b0137c9
|
||||
[ie_c_api_version]:https://docs.openvinotoolkit.org/latest/ie_c_api/ie__c__api_8h.html#a8fe3efe9cc606dcc7bec203102043e68
|
||||
[ie_core_get_versions]:https://docs.openvinotoolkit.org/latest/ie_c_api/group__Core.html#ga2932e188a690393f5d594572ac5d237b
|
||||
[ie_core_add_extension]:https://docs.openvinotoolkit.org/latest/ie_c_api/group__Core.html#gadded2444ba81d2d396516b72c2478f8e
|
||||
[ie_core_set_config]:https://docs.openvinotoolkit.org/latest/ie_c_api/group__Core.html#gaf09d1e77cc264067e4e22ddf99f21ec1
|
||||
[ie_network_get_inputs_number]:https://docs.openvinotoolkit.org/latest/ie_c_api/group__Network.html#ga6a3349bca66c4ba8b41a434061fccf52
|
||||
[ie_network_get_input_dims]:https://docs.openvinotoolkit.org/latest/ie_c_api/group__Network.html#gac621a654b89d413041cbc2288627f6a5
|
||||
[ie_network_get_input_shapes]:https://docs.openvinotoolkit.org/latest/ie_c_api/group__Network.html#ga5409734f25ffbb1379e876217c0bc6f3
|
||||
[ie_network_get_outputs_number]:https://docs.openvinotoolkit.org/latest/ie_c_api/group__Network.html#ga869b8c309797f1e09f73ddffd1b57509
|
||||
[ie_network_get_output_dims]:https://docs.openvinotoolkit.org/latest/ie_c_api/group__Network.html#ga8de7bf2f626f19eba08a2f043fc1b5d2
|
||||
[ie_network_reshape]:https://docs.openvinotoolkit.org/latest/ie_c_api/group__Network.html#gac4f690afd0c2221f7db2ff9be4aa0637
|
||||
[ie_blob_get_buffer]:https://docs.openvinotoolkit.org/latest/ie_c_api/group__Blob.html#ga948e0186cea6a393c113d5c399cfcb4c
|
@ -1,189 +0,0 @@
|
||||
// Copyright (C) 2018-2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
||||
# ifndef WIN32_LEAN_AND_MEAN
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# define WIN32_LEAN_AND_MEAN_UNDEF
|
||||
# endif
|
||||
|
||||
# ifndef NOMINMAX
|
||||
# define NOMINMAX
|
||||
# define NOMINMAX_UNDEF
|
||||
# endif
|
||||
|
||||
# if defined(_M_IX86) && !defined(_X86_) && !defined(_AMD64_)
|
||||
# define _X86_
|
||||
# endif
|
||||
|
||||
# if defined(_M_X64) && !defined(_X86_) && !defined(_AMD64_)
|
||||
# define _AMD64_
|
||||
# endif
|
||||
|
||||
# if defined(_M_ARM) && !defined(_ARM_) && !defined(_ARM64_)
|
||||
# define _ARM_
|
||||
# endif
|
||||
|
||||
# if defined(_M_ARM64) && !defined(_ARM_) && !defined(_ARM64_)
|
||||
# define _ARM64_
|
||||
# endif
|
||||
|
||||
// clang-format off
|
||||
#include <string.h>
|
||||
#include <windef.h>
|
||||
#include <fileapi.h>
|
||||
#include <Winbase.h>
|
||||
#include <sys/stat.h>
|
||||
// clang-format on
|
||||
|
||||
// Copied from linux libc sys/stat.h:
|
||||
# define S_ISREG(m) (((m)&S_IFMT) == S_IFREG)
|
||||
# define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
|
||||
|
||||
/// @brief structure to store directory names
|
||||
typedef struct dirent {
|
||||
char* d_name;
|
||||
} dirent;
|
||||
|
||||
/**
|
||||
* @brief Add directory to directory names struct
|
||||
* @param int argc - count of args
|
||||
* @param char *argv[] - array values of args
|
||||
* @param char *opts - array of options
|
||||
* @return pointer to directory names struct
|
||||
*/
|
||||
static dirent* createDirent(const wchar_t* wsFilePath) {
|
||||
dirent* d = (dirent*)malloc(sizeof(dirent));
|
||||
size_t i;
|
||||
size_t slen = wcslen(wsFilePath);
|
||||
d->d_name = (char*)(malloc(slen + 1));
|
||||
wcstombs_s(&i, d->d_name, slen + 1, wsFilePath, slen);
|
||||
return d;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Free directory names struct
|
||||
* @param point to directory names structure
|
||||
* @return none
|
||||
*/
|
||||
static void freeDirent(dirent** d) {
|
||||
free((*d)->d_name);
|
||||
(*d)->d_name = NULL;
|
||||
free(*d);
|
||||
*d = NULL;
|
||||
}
|
||||
|
||||
/// @brief structure to store directory data (files meta)
|
||||
typedef struct DIR {
|
||||
WIN32_FIND_DATAA FindFileData;
|
||||
HANDLE hFind;
|
||||
dirent* next;
|
||||
} DIR;
|
||||
|
||||
/**
|
||||
* @brief Compare two string, second string is the end of the first
|
||||
* @param string to compare
|
||||
* @param end string to find
|
||||
* @return status 1(success) or 0(fail)
|
||||
*/
|
||||
static int endsWith(const char* src, const char* with) {
|
||||
int wl = (int)(strlen(with));
|
||||
int so = (int)(strlen(with)) - wl;
|
||||
if (so < 0)
|
||||
return 0;
|
||||
if (strncmp(with, &(src[so]), wl) == 0)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check file handler is valid
|
||||
* @param struct of directory data
|
||||
* @return status 1(success) or 0(fail)
|
||||
*/
|
||||
static int isValid(DIR* dp) {
|
||||
if (dp->hFind != INVALID_HANDLE_VALUE && dp->FindFileData.dwReserved0) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Create directory data struct element
|
||||
* @param string directory path
|
||||
* @return pointer to directory data struct element
|
||||
*/
|
||||
static DIR* opendir(const char* dirPath) {
|
||||
DIR* dp = (DIR*)malloc(sizeof(DIR));
|
||||
dp->next = NULL;
|
||||
char* ws = (char*)(malloc(strlen(dirPath) + 1));
|
||||
strcpy(ws, dirPath);
|
||||
if (endsWith(ws, "\\"))
|
||||
strcat(ws, "*");
|
||||
else
|
||||
strcat(ws, "\\*");
|
||||
dp->hFind = FindFirstFileA(ws, &dp->FindFileData);
|
||||
dp->FindFileData.dwReserved0 = dp->hFind != INVALID_HANDLE_VALUE;
|
||||
free(ws);
|
||||
if (isValid(dp)) {
|
||||
free(dp);
|
||||
return NULL;
|
||||
}
|
||||
return dp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Walk throw directory data struct
|
||||
* @param pointer to directory data struct
|
||||
* @return pointer to directory data struct next element
|
||||
*/
|
||||
static struct dirent* readdir(DIR* dp) {
|
||||
if (dp->next != NULL)
|
||||
freeDirent(&(dp->next));
|
||||
|
||||
if (!dp->FindFileData.dwReserved0)
|
||||
return NULL;
|
||||
|
||||
wchar_t wbuf[4096];
|
||||
|
||||
size_t outSize;
|
||||
mbstowcs_s(&outSize, wbuf, 4094, dp->FindFileData.cFileName, 4094);
|
||||
dp->next = createDirent(wbuf);
|
||||
dp->FindFileData.dwReserved0 = FindNextFileA(dp->hFind, &(dp->FindFileData));
|
||||
return dp->next;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Remove directory data struct
|
||||
* @param pointer to struct directory data
|
||||
* @return none
|
||||
*/
|
||||
static void closedir(DIR* dp) {
|
||||
if (dp->next) {
|
||||
freeDirent(&(dp->next));
|
||||
}
|
||||
free(dp);
|
||||
}
|
||||
|
||||
# ifdef WIN32_LEAN_AND_MEAN_UNDEF
|
||||
# undef WIN32_LEAN_AND_MEAN
|
||||
# undef WIN32_LEAN_AND_MEAN_UNDEF
|
||||
# endif
|
||||
|
||||
# ifdef NOMINMAX_UNDEF
|
||||
# undef NOMINMAX_UNDEF
|
||||
# undef NOMINMAX
|
||||
# endif
|
||||
|
||||
#else
|
||||
|
||||
# include <dirent.h>
|
||||
# include <sys/types.h>
|
||||
|
||||
#endif
|
@ -1,852 +0,0 @@
|
||||
// Copyright (C) 2018-2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <c_api/ie_c_api.h>
|
||||
#include <opencv_c_wrapper.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "object_detection_sample_ssd.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
# include "c_w_dirent.h"
|
||||
#else
|
||||
# include <dirent.h>
|
||||
#endif
|
||||
|
||||
#define MAX_IMAGES 20
|
||||
|
||||
static const char* img_msg = NULL;
|
||||
static const char* input_model = NULL;
|
||||
static const char* device_name = "CPU";
|
||||
static const char* custom_plugin_cfg_msg = NULL;
|
||||
static const char* custom_ex_library_msg = NULL;
|
||||
static const char* config_msg = NULL;
|
||||
static int file_num = 0;
|
||||
static char** file_paths = NULL;
|
||||
|
||||
const char* info = "[ INFO ] ";
|
||||
const char* warn = "[ WARNING ] ";
|
||||
|
||||
/**
|
||||
* @brief Parse and check command line arguments
|
||||
* @param int argc - count of args
|
||||
* @param char *argv[] - array values of args
|
||||
* @return int - status 1(success) or -1(fail)
|
||||
*/
|
||||
int ParseAndCheckCommandLine(int argc, char* argv[]) {
|
||||
int opt = 0;
|
||||
int help = 0;
|
||||
char* string = "hi:m:d:c:l:g:";
|
||||
|
||||
printf("%sParsing input parameters\n", info);
|
||||
|
||||
while ((opt = getopt(argc, argv, string)) != -1) {
|
||||
switch (opt) {
|
||||
case 'h':
|
||||
showUsage();
|
||||
help = 1;
|
||||
break;
|
||||
case 'i':
|
||||
img_msg = optarg;
|
||||
break;
|
||||
case 'm':
|
||||
input_model = optarg;
|
||||
break;
|
||||
case 'd':
|
||||
device_name = optarg;
|
||||
break;
|
||||
case 'c':
|
||||
custom_plugin_cfg_msg = optarg;
|
||||
break;
|
||||
case 'l':
|
||||
custom_ex_library_msg = optarg;
|
||||
break;
|
||||
case 'g':
|
||||
config_msg = optarg;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Unknown argument `%c`. Please use -h option.\n", opt);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (help)
|
||||
return -1;
|
||||
if (input_model == NULL) {
|
||||
fprintf(stderr, "Model is required but not set. Please set -m option.\n");
|
||||
return -1;
|
||||
}
|
||||
if (img_msg == NULL) {
|
||||
fprintf(stderr, "Input is required but not set.Please set -i option.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function checks input args and existence of specified files in a
|
||||
* given folder. Updated the file_paths and file_num.
|
||||
* @param arg path to a file to be checked for existence
|
||||
* @return none.
|
||||
*/
|
||||
void readInputFilesArgument(const char* arg) {
|
||||
struct stat sb;
|
||||
if (stat(arg, &sb) != 0) {
|
||||
fprintf(stderr, "%sFile %s cannot be opened!\n", warn, arg);
|
||||
return;
|
||||
}
|
||||
if (S_ISDIR(sb.st_mode)) {
|
||||
DIR* dp;
|
||||
dp = opendir(arg);
|
||||
if (dp == NULL) {
|
||||
fprintf(stderr, "%sFile %s cannot be opened!\n", warn, arg);
|
||||
return;
|
||||
}
|
||||
|
||||
struct dirent* ep;
|
||||
while (NULL != (ep = readdir(dp))) {
|
||||
const char* fileName = ep->d_name;
|
||||
if (strcmp(fileName, ".") == 0 || strcmp(fileName, "..") == 0)
|
||||
continue;
|
||||
char* file_path = (char*)calloc(strlen(arg) + strlen(ep->d_name) + 2, sizeof(char));
|
||||
memcpy(file_path, arg, strlen(arg));
|
||||
memcpy(file_path + strlen(arg), "/", strlen("/"));
|
||||
memcpy(file_path + strlen(arg) + strlen("/"), ep->d_name, strlen(ep->d_name) + 1);
|
||||
|
||||
if (file_num == 0) {
|
||||
file_paths = (char**)calloc(1, sizeof(char*));
|
||||
file_paths[0] = file_path;
|
||||
++file_num;
|
||||
} else {
|
||||
char** temp = (char**)realloc(file_paths, sizeof(char*) * (file_num + 1));
|
||||
if (temp) {
|
||||
file_paths = temp;
|
||||
file_paths[file_num++] = file_path;
|
||||
} else {
|
||||
int i;
|
||||
for (i = 0; i < file_num; ++i) {
|
||||
free(file_paths[i]);
|
||||
}
|
||||
free(file_path);
|
||||
free(file_paths);
|
||||
file_num = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir(dp);
|
||||
dp = NULL;
|
||||
} else {
|
||||
char* file_path = (char*)calloc(strlen(arg) + 1, sizeof(char));
|
||||
memcpy(file_path, arg, strlen(arg) + 1);
|
||||
if (file_num == 0) {
|
||||
file_paths = (char**)calloc(1, sizeof(char*));
|
||||
}
|
||||
file_paths[file_num++] = file_path;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function find -i key in input args. It's necessary to process
|
||||
* multiple values for single key
|
||||
* @return none.
|
||||
*/
|
||||
void parseInputFilesArguments(int argc, char** argv) {
|
||||
int readArguments = 0, i;
|
||||
for (i = 0; i < argc; ++i) {
|
||||
if (strcmp(argv[i], "-i") == 0) {
|
||||
readArguments = 1;
|
||||
continue;
|
||||
}
|
||||
if (!readArguments) {
|
||||
continue;
|
||||
}
|
||||
if (argv[i][0] == '-') {
|
||||
break;
|
||||
}
|
||||
readInputFilesArgument(argv[i]);
|
||||
}
|
||||
|
||||
if (file_num < MAX_IMAGES) {
|
||||
printf("%sFiles were added: %d\n", info, file_num);
|
||||
for (i = 0; i < file_num; ++i) {
|
||||
printf("%s %s\n", info, file_paths[i]);
|
||||
}
|
||||
} else {
|
||||
printf("%sFiles were added: %d. Too many to display each of them.\n", info, file_num);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Convert the contents of configuration file to the ie_config_t struct.
|
||||
* @param config_file File path.
|
||||
* @param comment Separator symbol.
|
||||
* @return A pointer to the ie_config_t instance.
|
||||
*/
|
||||
ie_config_t* parseConfig(const char* config_file, char comment) {
|
||||
FILE* file = fopen(config_file, "r");
|
||||
if (!file) {
|
||||
fprintf(stderr, "ERROR file `%s` opening failure\n", config_file);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ie_config_t* cfg = NULL;
|
||||
char key[256], value[256];
|
||||
|
||||
if (fscanf(file, "%s", key) != EOF && fscanf(file, "%s", value) != EOF) {
|
||||
char* cfg_name = (char*)calloc(strlen(key) + 1, sizeof(char));
|
||||
char* cfg_value = (char*)calloc(strlen(value) + 1, sizeof(char));
|
||||
memcpy(cfg_name, key, strlen(key) + 1);
|
||||
memcpy(cfg_value, value, strlen(value) + 1);
|
||||
ie_config_t* cfg_t = (ie_config_t*)calloc(1, sizeof(ie_config_t));
|
||||
cfg_t->name = cfg_name;
|
||||
cfg_t->value = cfg_value;
|
||||
cfg_t->next = NULL;
|
||||
cfg = cfg_t;
|
||||
}
|
||||
if (cfg) {
|
||||
ie_config_t* cfg_temp = cfg;
|
||||
while (fscanf(file, "%s", key) != EOF && fscanf(file, "%s", value) != EOF) {
|
||||
if (strlen(key) == 0 || key[0] == comment) {
|
||||
continue;
|
||||
}
|
||||
char* cfg_name = (char*)calloc(strlen(key) + 1, sizeof(char));
|
||||
char* cfg_value = (char*)calloc(strlen(value) + 1, sizeof(char));
|
||||
memcpy(cfg_name, key, strlen(key) + 1);
|
||||
memcpy(cfg_value, value, strlen(value) + 1);
|
||||
ie_config_t* cfg_t = (ie_config_t*)calloc(1, sizeof(ie_config_t));
|
||||
cfg_t->name = cfg_name;
|
||||
cfg_t->value = cfg_value;
|
||||
cfg_t->next = NULL;
|
||||
cfg_temp->next = cfg_t;
|
||||
cfg_temp = cfg_temp->next;
|
||||
}
|
||||
}
|
||||
fclose(file);
|
||||
|
||||
return cfg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Releases memory occupied by config
|
||||
* @param config A pointer to the config to free memory.
|
||||
* @return none
|
||||
*/
|
||||
void config_free(ie_config_t* config) {
|
||||
while (config) {
|
||||
ie_config_t* temp = config;
|
||||
if (config->name) {
|
||||
free((char*)config->name);
|
||||
config->name = NULL;
|
||||
}
|
||||
if (config->value) {
|
||||
free((char*)config->value);
|
||||
config->value = NULL;
|
||||
}
|
||||
if (config->next) {
|
||||
config = config->next;
|
||||
}
|
||||
|
||||
free(temp);
|
||||
temp = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Convert the numbers to char *;
|
||||
* @param str A pointer to the converted string.
|
||||
* @param num The number to convert.
|
||||
* @return none.
|
||||
*/
|
||||
void int2str(char* str, int num) {
|
||||
int i = 0, j;
|
||||
if (num == 0) {
|
||||
str[0] = '0';
|
||||
str[1] = '\0';
|
||||
return;
|
||||
}
|
||||
|
||||
while (num != 0) {
|
||||
str[i++] = num % 10 + '0';
|
||||
num = num / 10;
|
||||
}
|
||||
|
||||
str[i] = '\0';
|
||||
--i;
|
||||
for (j = 0; j < i; ++j, --i) {
|
||||
char temp = str[j];
|
||||
str[j] = str[i];
|
||||
str[i] = temp;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
/** This sample covers certain topology and cannot be generalized for any
|
||||
* object detection one **/
|
||||
// ------------------------------ Get Inference Engine API version
|
||||
// ---------------------------------
|
||||
ie_version_t version = ie_c_api_version();
|
||||
printf("%sInferenceEngine: \n", info);
|
||||
printf("%s\n", version.api_version);
|
||||
ie_version_free(&version);
|
||||
|
||||
// ------------------------------ Parsing and validation of input args
|
||||
// ---------------------------------
|
||||
|
||||
char** argv_temp = (char**)calloc(argc, sizeof(char*));
|
||||
if (!argv_temp) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
int i, j;
|
||||
for (i = 0; i < argc; ++i) {
|
||||
argv_temp[i] = argv[i];
|
||||
}
|
||||
|
||||
char *input_weight = NULL, *imageInputName = NULL, *imInfoInputName = NULL, *output_name = NULL;
|
||||
ie_core_t* core = NULL;
|
||||
ie_network_t* network = NULL;
|
||||
ie_executable_network_t* exe_network = NULL;
|
||||
ie_infer_request_t* infer_request = NULL;
|
||||
ie_blob_t *imageInput = NULL, *output_blob = NULL;
|
||||
|
||||
if (ParseAndCheckCommandLine(argc, argv) < 0) {
|
||||
free(argv_temp);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
// --------------------------- Read input
|
||||
// -----------------------------------------------------------
|
||||
/** This file_paths stores paths to the processed images **/
|
||||
parseInputFilesArguments(argc, argv_temp);
|
||||
if (!file_num) {
|
||||
fprintf(stderr, "No suitable images were found\n");
|
||||
free(argv_temp);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
// --------------------------- Step 1. Initialize inference engine core
|
||||
// -------------------------------------
|
||||
|
||||
printf("%sLoading Inference Engine\n", info);
|
||||
IEStatusCode status = ie_core_create("", &core);
|
||||
if (status != OK) {
|
||||
fprintf(stderr, "ERROR ie_core_create status %d, line %d\n", status, __LINE__);
|
||||
goto err;
|
||||
}
|
||||
|
||||
// ------------------------------ Get Available Devices
|
||||
// ------------------------------------------------------
|
||||
ie_core_versions_t ver;
|
||||
printf("%sDevice info: \n", info);
|
||||
status = ie_core_get_versions(core, device_name, &ver);
|
||||
if (status != OK) {
|
||||
fprintf(stderr, "ERROR ie_core_get_versions status %d, line %d\n", status, __LINE__);
|
||||
goto err;
|
||||
}
|
||||
for (i = 0; i < ver.num_vers; ++i) {
|
||||
printf(" %s\n", ver.versions[i].device_name);
|
||||
printf(" %s version ......... %zu.%zu\n",
|
||||
ver.versions[i].description,
|
||||
ver.versions[i].major,
|
||||
ver.versions[i].minor);
|
||||
printf(" Build ......... %s\n", ver.versions[i].build_number);
|
||||
}
|
||||
ie_core_versions_free(&ver);
|
||||
|
||||
if (custom_ex_library_msg) {
|
||||
// Custom CPU extension is loaded as a shared library and passed as a
|
||||
// pointer to base extension
|
||||
status = ie_core_add_extension(core, custom_ex_library_msg, "CPU");
|
||||
if (status != OK) {
|
||||
fprintf(stderr, "ERROR ie_core_add_extension status %d, line %d\n", status, __LINE__);
|
||||
goto err;
|
||||
}
|
||||
printf("%sCustom extension loaded: %s\n", info, custom_ex_library_msg);
|
||||
}
|
||||
|
||||
if (custom_plugin_cfg_msg &&
|
||||
(strcmp(device_name, "GPU") == 0 || strcmp(device_name, "MYRIAD") == 0 || strcmp(device_name, "HDDL") == 0)) {
|
||||
// Config for device plugin custom extension is loaded from an .xml
|
||||
// description
|
||||
ie_config_t cfg = {"CONFIG_FILE", custom_plugin_cfg_msg, NULL};
|
||||
status = ie_core_set_config(core, &cfg, device_name);
|
||||
if (status != OK) {
|
||||
fprintf(stderr, "ERROR ie_core_set_config status %d, line %d\n", status, __LINE__);
|
||||
goto err;
|
||||
}
|
||||
printf("%sConfig for device plugin custom extension loaded: %s\n", info, custom_plugin_cfg_msg);
|
||||
}
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
// Step 2. Read a model in OpenVINO Intermediate Representation (.xml and .bin
|
||||
// files) or ONNX (.onnx file) format
|
||||
printf("%sLoading network:\n", info);
|
||||
printf("\t%s\n", input_model);
|
||||
status = ie_core_read_network(core, input_model, NULL, &network);
|
||||
if (status != OK) {
|
||||
fprintf(stderr, "ERROR ie_core_read_network status %d, line %d\n", status, __LINE__);
|
||||
goto err;
|
||||
}
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
// --------------------------- Step 3. Configure input & output
|
||||
// ---------------------------------------------
|
||||
// --------------------------- Prepare input blobs
|
||||
// -----------------------------------------------------
|
||||
printf("%sPreparing input blobs\n", info);
|
||||
|
||||
/** SSD network has one input and one output **/
|
||||
size_t input_num = 0;
|
||||
status = ie_network_get_inputs_number(network, &input_num);
|
||||
if (status != OK || (input_num != 1 && input_num != 2)) {
|
||||
fprintf(stderr, "Sample supports topologies only with 1 or 2 inputs\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
/**
|
||||
* Some networks have SSD-like output format (ending with DetectionOutput
|
||||
* layer), but having 2 inputs as Faster-RCNN: one for image and one for
|
||||
* "image info".
|
||||
*
|
||||
* Although object_datection_sample_ssd's main task is to support clean SSD,
|
||||
* it could score the networks with two inputs as well. For such networks
|
||||
* imInfoInputName will contain the "second" input name.
|
||||
*/
|
||||
size_t input_width = 0, input_height = 0;
|
||||
|
||||
/** Stores input image **/
|
||||
|
||||
/** Iterating over all input blobs **/
|
||||
for (i = 0; i < input_num; ++i) {
|
||||
char* name = NULL;
|
||||
status |= ie_network_get_input_name(network, i, &name);
|
||||
dimensions_t input_dim;
|
||||
status |= ie_network_get_input_dims(network, name, &input_dim);
|
||||
if (status != OK)
|
||||
goto err;
|
||||
|
||||
/** Working with first input tensor that stores image **/
|
||||
if (input_dim.ranks == 4) {
|
||||
imageInputName = name;
|
||||
input_height = input_dim.dims[2];
|
||||
input_width = input_dim.dims[3];
|
||||
|
||||
/** Creating first input blob **/
|
||||
status = ie_network_set_input_precision(network, name, U8);
|
||||
if (status != OK)
|
||||
goto err;
|
||||
} else if (input_dim.ranks == 2) {
|
||||
imInfoInputName = name;
|
||||
|
||||
status = ie_network_set_input_precision(network, name, FP32);
|
||||
if (status != OK || (input_dim.dims[1] != 3 && input_dim.dims[1] != 6)) {
|
||||
fprintf(stderr, "Invalid input info. Should be 3 or 6 values length\n");
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (imageInputName == NULL) {
|
||||
status = ie_network_get_input_name(network, 0, &imageInputName);
|
||||
if (status != OK)
|
||||
goto err;
|
||||
dimensions_t input_dim;
|
||||
status = ie_network_get_input_dims(network, imageInputName, &input_dim);
|
||||
if (status != OK)
|
||||
goto err;
|
||||
input_height = input_dim.dims[2];
|
||||
input_width = input_dim.dims[3];
|
||||
}
|
||||
|
||||
/** Collect images data **/
|
||||
c_mat_t* originalImages = (c_mat_t*)calloc(file_num, sizeof(c_mat_t));
|
||||
c_mat_t* images = (c_mat_t*)calloc(file_num, sizeof(c_mat_t));
|
||||
|
||||
if (!originalImages || !images)
|
||||
goto err;
|
||||
|
||||
int image_num = 0;
|
||||
for (i = 0; i < file_num; ++i) {
|
||||
c_mat_t img = {NULL, 0, 0, 0, 0, 0};
|
||||
if (image_read(file_paths[i], &img) == -1) {
|
||||
fprintf(stderr, "%sImage %s cannot be read!\n", warn, file_paths[i]);
|
||||
continue;
|
||||
}
|
||||
/** Store image data **/
|
||||
c_mat_t resized_img = {NULL, 0, 0, 0, 0, 0};
|
||||
if ((input_width == img.mat_width) && (input_height == img.mat_height)) {
|
||||
resized_img.mat_data_size = img.mat_data_size;
|
||||
resized_img.mat_channels = img.mat_channels;
|
||||
resized_img.mat_width = img.mat_width;
|
||||
resized_img.mat_height = img.mat_height;
|
||||
resized_img.mat_type = img.mat_type;
|
||||
resized_img.mat_data = calloc(1, resized_img.mat_data_size);
|
||||
if (resized_img.mat_data == NULL) {
|
||||
image_free(&img);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (j = 0; j < resized_img.mat_data_size; ++j)
|
||||
resized_img.mat_data[j] = img.mat_data[j];
|
||||
} else {
|
||||
printf("%sImage is resized from (%d, %d) to (%zu, %zu)\n",
|
||||
warn,
|
||||
img.mat_width,
|
||||
img.mat_height,
|
||||
input_width,
|
||||
input_height);
|
||||
|
||||
if (image_resize(&img, &resized_img, (int)input_width, (int)input_height) == -1) {
|
||||
printf("%sImage %s cannot be resized!\n", warn, file_paths[i]);
|
||||
image_free(&img);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
originalImages[image_num] = img;
|
||||
images[image_num] = resized_img;
|
||||
++image_num;
|
||||
}
|
||||
|
||||
if (!image_num) {
|
||||
fprintf(stderr, "Valid input images were not found!\n");
|
||||
free(originalImages);
|
||||
free(images);
|
||||
goto err;
|
||||
}
|
||||
|
||||
input_shapes_t shapes;
|
||||
status = ie_network_get_input_shapes(network, &shapes);
|
||||
if (status != OK) {
|
||||
fprintf(stderr, "ERROR ie_network_get_input_shapes status %d, line %d\n", status, __LINE__);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/** Using ie_network_reshape() to set the batch size equal to the number of
|
||||
* input images **/
|
||||
/** For input with NCHW/NHWC layout the first dimension N is the batch size
|
||||
* **/
|
||||
shapes.shapes[0].shape.dims[0] = image_num;
|
||||
status = ie_network_reshape(network, shapes);
|
||||
if (status != OK) {
|
||||
fprintf(stderr, "ERROR ie_network_reshape status %d, line %d\n", status, __LINE__);
|
||||
goto err;
|
||||
}
|
||||
ie_network_input_shapes_free(&shapes);
|
||||
|
||||
input_shapes_t shapes2;
|
||||
status = ie_network_get_input_shapes(network, &shapes2);
|
||||
if (status != OK) {
|
||||
fprintf(stderr, "ERROR ie_network_get_input_shapes status %d, line %d\n", status, __LINE__);
|
||||
goto err;
|
||||
}
|
||||
size_t batchSize = shapes2.shapes[0].shape.dims[0];
|
||||
ie_network_input_shapes_free(&shapes2);
|
||||
printf("%sBatch size is %zu\n", info, batchSize);
|
||||
|
||||
// --------------------------- Prepare output blobs
|
||||
// ----------------------------------------------------
|
||||
printf("%sPreparing output blobs\n", info);
|
||||
|
||||
size_t output_num = 0;
|
||||
status = ie_network_get_outputs_number(network, &output_num);
|
||||
|
||||
if (status != OK || !output_num) {
|
||||
fprintf(stderr, "Can't find a DetectionOutput layer in the topology\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
status = ie_network_get_output_name(network, output_num - 1, &output_name);
|
||||
if (status != OK) {
|
||||
fprintf(stderr, "ERROR ie_network_get_output_name status %d, line %d\n", status, __LINE__);
|
||||
goto err;
|
||||
}
|
||||
|
||||
dimensions_t output_dim;
|
||||
status = ie_network_get_output_dims(network, output_name, &output_dim);
|
||||
if (status != OK) {
|
||||
fprintf(stderr, "ERROR ie_network_get_output_dims status %d, line %d\n", status, __LINE__);
|
||||
goto err;
|
||||
}
|
||||
if (output_dim.ranks != 4) {
|
||||
fprintf(stderr, "Incorrect output dimensions for SSD model\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
const int maxProposalCount = (int)output_dim.dims[2];
|
||||
const int objectSize = (int)output_dim.dims[3];
|
||||
|
||||
if (objectSize != 7) {
|
||||
printf("Output item should have 7 as a last dimension\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
/** Set the precision of output data provided by the user, should be called
|
||||
* before load of the network to the device **/
|
||||
status = ie_network_set_output_precision(network, output_name, FP32);
|
||||
if (status != OK) {
|
||||
fprintf(stderr, "ERROR ie_network_set_output_precision status %d, line %d\n", status, __LINE__);
|
||||
goto err;
|
||||
}
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
// --------------------------- Step 4. Loading model to the device
|
||||
// ------------------------------------------
|
||||
printf("%sLoading model to the device\n", info);
|
||||
if (config_msg) {
|
||||
ie_config_t* config = parseConfig(config_msg, '#');
|
||||
status = ie_core_load_network(core, network, device_name, config, &exe_network);
|
||||
config_free(config);
|
||||
if (status != OK) {
|
||||
fprintf(stderr, "ERROR ie_core_load_network status %d, line %d\n", status, __LINE__);
|
||||
goto err;
|
||||
}
|
||||
} else {
|
||||
ie_config_t cfg = {NULL, NULL, NULL};
|
||||
status = ie_core_load_network(core, network, device_name, &cfg, &exe_network);
|
||||
if (status != OK) {
|
||||
fprintf(stderr, "ERROR ie_core_load_network status %d, line %d\n", status, __LINE__);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
// --------------------------- Step 5. Create infer request
|
||||
// -------------------------------------------------
|
||||
printf("%sCreate infer request\n", info);
|
||||
status = ie_exec_network_create_infer_request(exe_network, &infer_request);
|
||||
if (status != OK) {
|
||||
fprintf(stderr, "ERROR ie_exec_network_create_infer_request status %d, line %d\n", status, __LINE__);
|
||||
goto err;
|
||||
}
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
// --------------------------- Step 6. Prepare input
|
||||
// --------------------------------------------------------
|
||||
|
||||
/** Creating input blob **/
|
||||
status = ie_infer_request_get_blob(infer_request, imageInputName, &imageInput);
|
||||
if (status != OK) {
|
||||
fprintf(stderr, "ERROR ie_infer_request_get_blob status %d, line %d\n", status, __LINE__);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/** Filling input tensor with images. First b channel, then g and r channels
|
||||
* **/
|
||||
dimensions_t input_tensor_dims;
|
||||
status = ie_blob_get_dims(imageInput, &input_tensor_dims);
|
||||
if (status != OK) {
|
||||
fprintf(stderr, "ERROR ie_blob_get_dims status %d, line %d\n", status, __LINE__);
|
||||
goto err;
|
||||
}
|
||||
size_t num_channels = input_tensor_dims.dims[1];
|
||||
size_t image_size = input_tensor_dims.dims[3] * input_tensor_dims.dims[2];
|
||||
|
||||
ie_blob_buffer_t blob_buffer;
|
||||
status = ie_blob_get_buffer(imageInput, &blob_buffer);
|
||||
if (status != OK) {
|
||||
fprintf(stderr, "ERROR ie_blob_get_buffer status %d, line %d\n", status, __LINE__);
|
||||
goto err;
|
||||
}
|
||||
unsigned char* data = (unsigned char*)(blob_buffer.buffer);
|
||||
|
||||
/** Iterate over all input images **/
|
||||
int image_id, pid, ch, k;
|
||||
for (image_id = 0; image_id < batchSize; ++image_id) {
|
||||
/** Iterate over all pixel in image (b,g,r) **/
|
||||
for (pid = 0; pid < image_size; ++pid) {
|
||||
/** Iterate over all channels **/
|
||||
for (ch = 0; ch < num_channels; ++ch) {
|
||||
/** [images stride + channels stride + pixel id ] all in bytes
|
||||
* **/
|
||||
data[image_id * image_size * num_channels + ch * image_size + pid] =
|
||||
images[image_id].mat_data[pid * num_channels + ch];
|
||||
}
|
||||
}
|
||||
image_free(&images[image_id]);
|
||||
}
|
||||
free(images);
|
||||
ie_blob_free(&imageInput);
|
||||
|
||||
if (imInfoInputName != NULL) {
|
||||
ie_blob_t* input2 = NULL;
|
||||
status = ie_infer_request_get_blob(infer_request, imInfoInputName, &input2);
|
||||
|
||||
dimensions_t imInfoDim;
|
||||
status |= ie_blob_get_dims(input2, &imInfoDim);
|
||||
// Fill input tensor with values
|
||||
ie_blob_buffer_t info_blob_buffer;
|
||||
status |= ie_blob_get_buffer(input2, &info_blob_buffer);
|
||||
if (status != OK) {
|
||||
fprintf(stderr, "ERROR ie_blob_get_buffer status %d, line %d\n", status, __LINE__);
|
||||
ie_blob_free(&input2);
|
||||
goto err;
|
||||
}
|
||||
float* p = (float*)(info_blob_buffer.buffer);
|
||||
for (image_id = 0; image_id < batchSize; ++image_id) {
|
||||
p[image_id * imInfoDim.dims[1] + 0] = (float)input_height;
|
||||
p[image_id * imInfoDim.dims[1] + 1] = (float)input_width;
|
||||
|
||||
for (k = 2; k < imInfoDim.dims[1]; k++) {
|
||||
p[image_id * imInfoDim.dims[1] + k] = 1.0f; // all scale factors are set to 1.0
|
||||
}
|
||||
}
|
||||
ie_blob_free(&input2);
|
||||
}
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
// --------------------------- Step 7. Do inference
|
||||
// --------------------------------------------------------
|
||||
printf("%sStart inference\n", info);
|
||||
status = ie_infer_request_infer_async(infer_request);
|
||||
status |= ie_infer_request_wait(infer_request, -1);
|
||||
if (status != OK) {
|
||||
fprintf(stderr, "ERROR ie_infer_request_infer_async status %d, line %d\n", status, __LINE__);
|
||||
goto err;
|
||||
}
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
// --------------------------- Step 8. Process output
|
||||
// ------------------------------------------------------
|
||||
printf("%sProcessing output blobs\n", info);
|
||||
|
||||
status = ie_infer_request_get_blob(infer_request, output_name, &output_blob);
|
||||
if (status != OK) {
|
||||
fprintf(stderr, "ERROR ie_infer_request_get_blob status %d, line %d\n", status, __LINE__);
|
||||
goto err;
|
||||
}
|
||||
|
||||
ie_blob_buffer_t output_blob_buffer;
|
||||
status = ie_blob_get_cbuffer(output_blob, &output_blob_buffer);
|
||||
if (status != OK) {
|
||||
fprintf(stderr, "ERROR ie_blob_get_cbuffer status %d, line %d\n", status, __LINE__);
|
||||
goto err;
|
||||
}
|
||||
const float* detection = (float*)(output_blob_buffer.cbuffer);
|
||||
|
||||
int** classes = (int**)calloc(image_num, sizeof(int*));
|
||||
rectangle_t** boxes = (rectangle_t**)calloc(image_num, sizeof(rectangle_t*));
|
||||
int* object_num = (int*)calloc(image_num, sizeof(int));
|
||||
for (i = 0; i < image_num; ++i) {
|
||||
classes[i] = (int*)calloc(maxProposalCount, sizeof(int));
|
||||
boxes[i] = (rectangle_t*)calloc(maxProposalCount, sizeof(rectangle_t));
|
||||
object_num[i] = 0;
|
||||
}
|
||||
|
||||
/* Each detection has image_id that denotes processed image */
|
||||
int curProposal;
|
||||
for (curProposal = 0; curProposal < maxProposalCount; curProposal++) {
|
||||
image_id = (int)(detection[curProposal * objectSize + 0]);
|
||||
if (image_id < 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
float confidence = detection[curProposal * objectSize + 2];
|
||||
int label = (int)(detection[curProposal * objectSize + 1]);
|
||||
int xmin = (int)(detection[curProposal * objectSize + 3] * originalImages[image_id].mat_width);
|
||||
int ymin = (int)(detection[curProposal * objectSize + 4] * originalImages[image_id].mat_height);
|
||||
int xmax = (int)(detection[curProposal * objectSize + 5] * originalImages[image_id].mat_width);
|
||||
int ymax = (int)(detection[curProposal * objectSize + 6] * originalImages[image_id].mat_height);
|
||||
|
||||
printf("[%d, %d] element, prob = %f (%d, %d)-(%d, %d) batch id : %d",
|
||||
curProposal,
|
||||
label,
|
||||
confidence,
|
||||
xmin,
|
||||
ymin,
|
||||
xmax,
|
||||
ymax,
|
||||
image_id);
|
||||
|
||||
if (confidence > 0.5) {
|
||||
/** Drawing only objects with >50% probability **/
|
||||
classes[image_id][object_num[image_id]] = label;
|
||||
boxes[image_id][object_num[image_id]].x_min = xmin;
|
||||
boxes[image_id][object_num[image_id]].y_min = ymin;
|
||||
boxes[image_id][object_num[image_id]].rect_width = xmax - xmin;
|
||||
boxes[image_id][object_num[image_id]].rect_height = ymax - ymin;
|
||||
printf(" WILL BE PRINTED!");
|
||||
++object_num[image_id];
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
/** Adds rectangles to the image and save **/
|
||||
int batch_id;
|
||||
for (batch_id = 0; batch_id < batchSize; ++batch_id) {
|
||||
if (object_num[batch_id] > 0) {
|
||||
image_add_rectangles(&originalImages[batch_id],
|
||||
boxes[batch_id],
|
||||
classes[batch_id],
|
||||
object_num[batch_id],
|
||||
2);
|
||||
}
|
||||
const char* out = "out_";
|
||||
char str_num[16] = {0};
|
||||
int2str(str_num, batch_id);
|
||||
char* img_path = (char*)calloc(strlen(out) + strlen(str_num) + strlen(".bmp") + 1, sizeof(char));
|
||||
memcpy(img_path, out, strlen(out));
|
||||
memcpy(img_path + strlen(out), str_num, strlen(str_num));
|
||||
memcpy(img_path + strlen(out) + strlen(str_num), ".bmp", strlen(".bmp") + 1);
|
||||
image_save(img_path, &originalImages[batch_id]);
|
||||
printf("%sImage %s created!\n", info, img_path);
|
||||
free(img_path);
|
||||
image_free(&originalImages[batch_id]);
|
||||
}
|
||||
free(originalImages);
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
printf("%sExecution successful\n", info);
|
||||
printf("\nThis sample is an API example,"
|
||||
" for any performance measurements please use the dedicated benchmark_"
|
||||
"app tool\n");
|
||||
|
||||
for (i = 0; i < image_num; ++i) {
|
||||
free(classes[i]);
|
||||
free(boxes[i]);
|
||||
}
|
||||
free(classes);
|
||||
free(boxes);
|
||||
free(object_num);
|
||||
ie_blob_free(&output_blob);
|
||||
ie_infer_request_free(&infer_request);
|
||||
ie_exec_network_free(&exe_network);
|
||||
ie_network_free(&network);
|
||||
ie_core_free(&core);
|
||||
ie_network_name_free(&imageInputName);
|
||||
ie_network_name_free(&imInfoInputName);
|
||||
ie_network_name_free(&output_name);
|
||||
free(input_weight);
|
||||
free(argv_temp);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
err:
|
||||
free(argv_temp);
|
||||
if (input_weight)
|
||||
free(input_weight);
|
||||
if (core)
|
||||
ie_core_free(&core);
|
||||
if (network)
|
||||
ie_network_free(&network);
|
||||
if (imageInputName)
|
||||
ie_network_name_free(&imageInputName);
|
||||
if (imInfoInputName)
|
||||
ie_network_name_free(&imInfoInputName);
|
||||
if (output_name)
|
||||
ie_network_name_free(&output_name);
|
||||
if (exe_network)
|
||||
ie_exec_network_free(&exe_network);
|
||||
if (imageInput)
|
||||
ie_blob_free(&imageInput);
|
||||
if (output_blob)
|
||||
ie_blob_free(&output_blob);
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
@ -1,114 +0,0 @@
|
||||
// Copyright (C) 2018-2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
/// @brief message for help argument
|
||||
static const char* help_message = "Print a usage message.";
|
||||
|
||||
/// @brief message for model argument
|
||||
static const char* model_message = "Required. Path to an .xml file with a trained model.";
|
||||
|
||||
/// @brief message for images argument
|
||||
static const char* image_message = "Required. Path to one or more images or folder with images.";
|
||||
|
||||
/// @brief message for assigning cnn calculation to device
|
||||
static const char* target_device_message =
|
||||
"Optional. Specify the target device to infer. "
|
||||
"Default value is CPU. Use \"-d HETERO:<comma-separated_devices_list>\" format to specify "
|
||||
"HETERO plugin. "
|
||||
"Sample will look for a suitable plugin for device specified.";
|
||||
|
||||
/// @brief message for plugin custom kernels desc
|
||||
static const char* custom_plugin_config_message =
|
||||
"Required for GPU, MYRIAD, HDDL custom kernels. "
|
||||
"Absolute path to the .xml config file with the kernels descriptions.";
|
||||
|
||||
/// @brief message for user extension library argument
|
||||
static const char* custom_ex_library_message = "Required for CPU plugin custom layers. "
|
||||
"Absolute path to a shared library with the kernels implementations.";
|
||||
|
||||
/// @brief message for config argument
|
||||
static const char* config_message = "Path to the configuration file. Default value: \"config\".";
|
||||
/**
|
||||
* \brief This function show a help message
|
||||
*/
|
||||
static void showUsage() {
|
||||
printf("\nobject_detection_sample_ssd_c [OPTION]\n");
|
||||
printf("Options:\n\n");
|
||||
printf(" -h %s\n", help_message);
|
||||
printf(" -m \"<path>\" %s\n", model_message);
|
||||
printf(" -i \"<path>\" %s\n", image_message);
|
||||
printf(" -l \"<absolute_path>\" %s\n", custom_ex_library_message);
|
||||
printf(" Or\n");
|
||||
printf(" -c \"<absolute_path>\" %s\n", custom_plugin_config_message);
|
||||
printf(" -d \"<device>\" %s\n", target_device_message);
|
||||
printf(" -g %s\n", config_message);
|
||||
}
|
||||
|
||||
int opterr = 1;
|
||||
int optind = 1;
|
||||
int optopt;
|
||||
char* optarg;
|
||||
|
||||
#define ERR(s, c) \
|
||||
if (opterr) { \
|
||||
fputs(argv[0], stderr); \
|
||||
fputs(s, stderr); \
|
||||
fputc('\'', stderr); \
|
||||
fputc(c, stderr); \
|
||||
fputs("\'\n", stderr); \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check command line arguments with available options
|
||||
* @param int argc - count of args
|
||||
* @param char *argv[] - array values of args
|
||||
* @param char *opts - array of options
|
||||
* @return option name or -1(fail)
|
||||
*/
|
||||
static int getopt(int argc, char** argv, char* opts) {
|
||||
static int sp = 1;
|
||||
register int c = 0;
|
||||
register char* cp = NULL;
|
||||
|
||||
if (sp == 1) {
|
||||
if (optind >= argc || argv[optind][0] != '-' || argv[optind][1] == '\0')
|
||||
return -1;
|
||||
else if (strcmp(argv[optind], "--") == 0) {
|
||||
optind++;
|
||||
return -1;
|
||||
}
|
||||
optopt = c = argv[optind][sp];
|
||||
if (c == ':' || (cp = strchr(opts, c)) == 0) {
|
||||
ERR(": unrecognized option -- ", c);
|
||||
showUsage();
|
||||
if (argv[optind][++sp] == '\0') {
|
||||
optind++;
|
||||
sp = 1;
|
||||
}
|
||||
return ('?');
|
||||
}
|
||||
if (*++cp == ':') {
|
||||
if (argv[optind][sp + 1] != '\0')
|
||||
optarg = &argv[optind++][sp + 1];
|
||||
else if (++optind >= argc) {
|
||||
ERR(": option requires an argument -- ", c);
|
||||
sp = 1;
|
||||
return ('?');
|
||||
} else
|
||||
optarg = argv[optind++];
|
||||
sp = 1;
|
||||
} else {
|
||||
if (argv[optind][++sp] == '\0') {
|
||||
sp = 1;
|
||||
optind++;
|
||||
}
|
||||
optarg = NULL;
|
||||
}
|
||||
}
|
||||
return (c);
|
||||
}
|
@ -20,7 +20,7 @@ Basic Inference Engine API is covered by [Hello Classification C++ sample](../he
|
||||
| Model Format | Inference Engine Intermediate Representation (\*.xml + \*.bin), ONNX (\*.onnx)
|
||||
| Validated images | The sample uses OpenCV\* to [read input image](https://docs.opencv.org/master/d4/da8/group__imgcodecs.html#ga288b8b3da0892bd651fce07b3bbd3a56) (\*.bmp, \*.png)
|
||||
| Supported devices | [All](../../../docs/IE_DG/supported_plugins/Supported_Devices.md) |
|
||||
| Other language realization | [C](../../ie_bridges/c/samples/object_detection_sample_ssd/README.md), [Python](../../../samples/python/hello_reshape_ssd/README.md) |
|
||||
| Other language realization | [Python](../../../samples/python/hello_reshape_ssd/README.md) |
|
||||
|
||||
## How It Works
|
||||
|
||||
|
@ -1,8 +0,0 @@
|
||||
# Copyright (C) 2018-2021 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
ie_add_sample(NAME object_detection_sample_ssd
|
||||
SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp"
|
||||
HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/object_detection_sample_ssd.h"
|
||||
DEPENDENCIES format_reader ie_samples_utils)
|
@ -1,150 +0,0 @@
|
||||
# Object Detection SSD C++ Sample {#openvino_inference_engine_samples_object_detection_sample_ssd_README}
|
||||
|
||||
This sample demonstrates how to execute an inference of object detection networks like SSD-VGG using Synchronous Inference Request API.
|
||||
|
||||
Object Detection SSD C++ sample application demonstrates how to use the following Inference Engine C++ API in applications:
|
||||
|
||||
| Feature | API | Description |
|
||||
|:--- |:--- |:---
|
||||
|Inference Engine Version| `InferenceEngine::GetInferenceEngineVersion` | Get Inference Engine API version
|
||||
|Available Devices|`InferenceEngine::Core::GetAvailableDevices`| Get version information of the devices for inference
|
||||
|Custom Extension Kernels|`InferenceEngine::Core::AddExtension`, `InferenceEngine::Core::SetConfig`| Load extension library and config to the device
|
||||
| Network Operations | `InferenceEngine::CNNNetwork::getBatchSize`, `InferenceEngine::CNNNetwork::getFunction` | Managing of network, operate with its batch size.
|
||||
|nGraph Functions|`ngraph::Function::get_ops`, `ngraph::Node::get_friendly_name`, `ngraph::Node::get_type_info`| Go thru network nGraph
|
||||
|
||||
Basic Inference Engine API is covered by [Hello Classification C++ sample](../hello_classification/README.md).
|
||||
|
||||
| Options | Values |
|
||||
|:--- |:---
|
||||
| Validated Models | [person-detection-retail-0013](@ref omz_models_model_person_detection_retail_0013)
|
||||
| Model Format | Inference Engine Intermediate Representation (\*.xml + \*.bin), ONNX (\*.onnx)
|
||||
| Validated images | The sample uses OpenCV\* to [read input image](https://docs.opencv.org/master/d4/da8/group__imgcodecs.html#ga288b8b3da0892bd651fce07b3bbd3a56) (\*.bmp, \*.png)
|
||||
| Supported devices | [All](../../../docs/IE_DG/supported_plugins/Supported_Devices.md) |
|
||||
| Other language realization | [C](../../../samples/c/object_detection_sample_ssd/README.md) |
|
||||
|
||||
## How It Works
|
||||
|
||||
Upon the start-up the sample application reads command line parameters, loads specified network and image to the Inference
|
||||
Engine plugin. Then, the sample creates an synchronous inference request object. When inference is done, the application creates output image and output data to the standard output stream.
|
||||
|
||||
You can see the explicit description of
|
||||
each sample step at [Integration Steps](../../../docs/IE_DG/Integrate_with_customer_application_new_API.md) section of "Integrate the Inference Engine with Your Application" guide.
|
||||
|
||||
## Building
|
||||
|
||||
To build the sample, please use instructions available at [Build the Sample Applications](../../../docs/IE_DG/Samples_Overview.md) section in Inference Engine Samples guide.
|
||||
|
||||
## Running
|
||||
|
||||
To run the sample, you need specify a model and image:
|
||||
|
||||
- you can use [public](@ref omz_models_group_public) or [Intel's](@ref omz_models_group_intel) pre-trained models from the Open Model Zoo. The models can be downloaded using the [Model Downloader](@ref omz_tools_downloader).
|
||||
- you can use images from the media files collection available at https://storage.openvinotoolkit.org/data/test_data.
|
||||
|
||||
Running the application with the `-h` option yields the following usage message:
|
||||
|
||||
```
|
||||
./object_detection_sample_ssd -h
|
||||
InferenceEngine:
|
||||
API version ............ <version>
|
||||
Build .................. <build>
|
||||
Description ....... API
|
||||
|
||||
object_detection_sample_ssd [OPTION]
|
||||
Options:
|
||||
|
||||
-h Print a usage message.
|
||||
-m "<path>" Required. Path to an .xml file with a trained model.
|
||||
-i "<path>" Required. Path to an image.
|
||||
-l "<absolute_path>" Required for CPU custom layers. Absolute path to a shared library with the kernels implementations.
|
||||
Or
|
||||
-c "<absolute_path>" Required for GPU, MYRIAD, HDDL custom kernels. Absolute path to the .xml config file with the kernels descriptions.
|
||||
-d "<device>" Optional. Specify the target device to infer on (the list of available devices is shown below). Default value is CPU. Use "-d HETERO:<comma_separated_devices_list>" format to specify HETERO plugin. Sample will look for a suitable plugin for device specified.
|
||||
|
||||
Available target devices: <devices>
|
||||
|
||||
```
|
||||
|
||||
Running the application with the empty list of options yields the usage message given above and an error message.
|
||||
|
||||
> **NOTES**:
|
||||
>
|
||||
> - 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).
|
||||
>
|
||||
> - 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.
|
||||
|
||||
### Example
|
||||
1. Download a pre-trained model using [Model Downloader](@ref omz_tools_downloader):
|
||||
```
|
||||
python <path_to_omz_tools>/downloader.py --name person-detection-retail-0013
|
||||
```
|
||||
|
||||
2. `person-detection-retail-0013` model does not need to be converted, because it is already in necessary format, so you can skip this step. If you want to use a other model that is not in the Inference Engine IR or ONNX format, you can convert it using the model converter script:
|
||||
|
||||
```
|
||||
python <path_to_omz_tools>/converter.py --name <model_name>
|
||||
```
|
||||
|
||||
3. For example, to do inference on a CPU with the OpenVINO™ toolkit person detection SSD models, run one of the following commands:
|
||||
|
||||
- with one image and [person-detection-retail-0013](https://docs.openvinotoolkit.org/latest/omz_models_intel_person_detection_retail_0013_description_person_detection_retail_0013.html) model
|
||||
|
||||
```
|
||||
<path_to_sample>/object_detection_sample_ssd -m <path_to_model>/person-detection-retail-0013.xml -i <path_to_image>/person_detection.png -d CPU
|
||||
```
|
||||
|
||||
- with one image and [person-detection-retail-0002](https://docs.openvinotoolkit.org/latest/omz_models_intel_person_detection_retail_0002_description_person_detection_retail_0002.html) model
|
||||
|
||||
```
|
||||
<path_to_sample>/object_detection_sample_ssd -m <path_to_model>/person-detection-retail-0002.xml -i <path_to_image>/person_detection.png -d GPU
|
||||
```
|
||||
|
||||
## Sample Output
|
||||
|
||||
The application outputs an image (`out_0.bmp`) with detected objects enclosed in rectangles. It outputs the list of classes
|
||||
of the detected objects along with the respective confidence values and the coordinates of the
|
||||
rectangles to the standard output stream.
|
||||
|
||||
```
|
||||
object_detection_sample_ssd -m person-detection-retail-0013\FP16\person-detection-retail-0013.xml -i person_detection.png
|
||||
[ INFO ] InferenceEngine:
|
||||
API version ............ <version>
|
||||
Build .................. <build>
|
||||
Description ....... API
|
||||
Parsing input parameters
|
||||
[ INFO ] Files were added: 1
|
||||
[ INFO ] person_detection.png
|
||||
[ INFO ] Loading Inference Engine
|
||||
[ INFO ] Device info:
|
||||
CPU
|
||||
MKLDNNPlugin version ......... <version>
|
||||
Build ........... <build>
|
||||
[ INFO ] Loading network files:
|
||||
person-detection-retail-0013\FP16\person-detection-retail-0013.xml
|
||||
[ INFO ] Preparing input blobs
|
||||
[ INFO ] Batch size is 1
|
||||
[ INFO ] Preparing output blobs
|
||||
[ INFO ] Loading model to the device
|
||||
[ INFO ] Create infer request
|
||||
[ WARNING ] Image is resized from (1699, 960) to (544, 320)
|
||||
[ INFO ] Batch size is 1
|
||||
[ INFO ] Start inference
|
||||
[ INFO ] Processing output blobs
|
||||
[0,1] element, prob = 0.99909 (370,201)-(634,762) batch id : 0 WILL BE PRINTED!
|
||||
[1,1] element, prob = 0.997386 (836,192)-(999,663) batch id : 0 WILL BE PRINTED!
|
||||
[2,1] element, prob = 0.314753 (192,2)-(265,172) batch id : 0
|
||||
...
|
||||
[ INFO ] Image out_0.bmp created!
|
||||
[ INFO ] Execution successful
|
||||
|
||||
[ INFO ] This sample is an API example, for any performance measurements please use the dedicated benchmark_app tool
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
- [Integrate the Inference Engine with Your Application](../../../docs/IE_DG/Integrate_with_customer_application_new_API.md)
|
||||
- [Using Inference Engine Samples](../../../docs/IE_DG/Samples_Overview.md)
|
||||
- [Model Downloader](@ref omz_tools_downloader)
|
||||
- [Model Optimizer](../../../docs/MO_DG/Deep_Learning_Model_Optimizer_DevGuide.md)
|
@ -1,417 +0,0 @@
|
||||
// Copyright (C) 2018-2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <format_reader_ptr.h>
|
||||
#include <gflags/gflags.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <inference_engine.hpp>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <ngraph/ngraph.hpp>
|
||||
#include <samples/args_helper.hpp>
|
||||
#include <samples/common.hpp>
|
||||
#include <samples/slog.hpp>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "object_detection_sample_ssd.h"
|
||||
|
||||
using namespace InferenceEngine;
|
||||
|
||||
/**
|
||||
* @brief Checks input args
|
||||
* @param argc number of args
|
||||
* @param argv list of input arguments
|
||||
* @return bool status true(Success) or false(Fail)
|
||||
*/
|
||||
bool ParseAndCheckCommandLine(int argc, char* argv[]) {
|
||||
gflags::ParseCommandLineNonHelpFlags(&argc, &argv, true);
|
||||
if (FLAGS_h) {
|
||||
showUsage();
|
||||
showAvailableDevices();
|
||||
return false;
|
||||
}
|
||||
|
||||
slog::info << "Parsing input parameters" << slog::endl;
|
||||
|
||||
if (FLAGS_m.empty()) {
|
||||
showUsage();
|
||||
throw std::logic_error("Model is required but not set. Please set -m option.");
|
||||
}
|
||||
|
||||
if (FLAGS_i.empty()) {
|
||||
showUsage();
|
||||
throw std::logic_error("Input is required but not set. Please set -i option.");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief The entry point for the Inference Engine object_detection sample
|
||||
* application \file object_detection_sample_ssd/main.cpp \example
|
||||
* object_detection_sample_ssd/main.cpp
|
||||
*/
|
||||
int main(int argc, char* argv[]) {
|
||||
try {
|
||||
/** This sample covers certain topology and cannot be generalized for any
|
||||
* object detection one **/
|
||||
// ------------------------------ Get Inference Engine version
|
||||
// ------------------------------------------------------
|
||||
slog::info << "InferenceEngine: " << GetInferenceEngineVersion() << "\n";
|
||||
|
||||
// --------------------------- Parsing and validation of input arguments
|
||||
// ---------------------------------
|
||||
if (!ParseAndCheckCommandLine(argc, argv)) {
|
||||
return 0;
|
||||
}
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
// ------------------------------ Read input
|
||||
// -----------------------------------------------------------
|
||||
/** This vector stores paths to the processed images **/
|
||||
std::vector<std::string> images;
|
||||
parseInputFilesArguments(images);
|
||||
if (images.empty())
|
||||
throw std::logic_error("No suitable images were found");
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
// --------------------------- Step 1. Initialize inference engine core
|
||||
// -------------------------------------
|
||||
slog::info << "Loading Inference Engine" << slog::endl;
|
||||
Core ie;
|
||||
// ------------------------------ Get Available Devices
|
||||
// ------------------------------------------------------
|
||||
slog::info << "Device info: " << slog::endl;
|
||||
slog::info << ie.GetVersions(FLAGS_d) << slog::endl;
|
||||
|
||||
if (!FLAGS_l.empty()) {
|
||||
IExtensionPtr extension_ptr = std::make_shared<Extension>(FLAGS_l);
|
||||
ie.AddExtension(extension_ptr);
|
||||
slog::info << "Extension loaded: " << FLAGS_l << slog::endl;
|
||||
}
|
||||
|
||||
if (!FLAGS_c.empty() && (FLAGS_d == "GPU" || FLAGS_d == "MYRIAD" || FLAGS_d == "HDDL")) {
|
||||
// Config for device plugin custom extension is loaded from an .xml
|
||||
// description
|
||||
ie.SetConfig({{PluginConfigParams::KEY_CONFIG_FILE, FLAGS_c}}, FLAGS_d);
|
||||
slog::info << "Config for " << FLAGS_d << " device plugin custom extension loaded: " << FLAGS_c
|
||||
<< slog::endl;
|
||||
}
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
// Step 2. Read a model in OpenVINO Intermediate Representation (.xml and
|
||||
// .bin files) or ONNX (.onnx file) format
|
||||
slog::info << "Loading network files:" << slog::endl << FLAGS_m << slog::endl;
|
||||
|
||||
/** Read network model **/
|
||||
CNNNetwork network = ie.ReadNetwork(FLAGS_m);
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
// --------------------------- Step 3. Configure input & output
|
||||
// ---------------------------------------------
|
||||
// -------------------------------- Prepare input blobs
|
||||
// --------------------------------------------------
|
||||
slog::info << "Preparing input blobs" << slog::endl;
|
||||
|
||||
/** Taking information about all topology inputs **/
|
||||
InputsDataMap inputsInfo(network.getInputsInfo());
|
||||
|
||||
/**
|
||||
* Some networks have SSD-like output format (ending with DetectionOutput
|
||||
* layer), but having 2 inputs as Faster-RCNN: one for image and one for
|
||||
* "image info".
|
||||
*
|
||||
* Although object_datection_sample_ssd's main task is to support clean SSD,
|
||||
* it could score the networks with two inputs as well. For such networks
|
||||
* imInfoInputName will contain the "second" input name.
|
||||
*/
|
||||
if (inputsInfo.size() != 1 && inputsInfo.size() != 2)
|
||||
throw std::logic_error("Sample supports topologies only with 1 or 2 inputs");
|
||||
|
||||
std::string imageInputName, imInfoInputName;
|
||||
|
||||
InputInfo::Ptr inputInfo = nullptr;
|
||||
|
||||
SizeVector inputImageDims;
|
||||
/** Stores input image **/
|
||||
|
||||
/** Iterating over all input blobs **/
|
||||
for (auto& item : inputsInfo) {
|
||||
/** Working with first input tensor that stores image **/
|
||||
if (item.second->getInputData()->getTensorDesc().getDims().size() == 4) {
|
||||
imageInputName = item.first;
|
||||
|
||||
inputInfo = item.second;
|
||||
|
||||
slog::info << "Batch size is " << std::to_string(network.getBatchSize()) << slog::endl;
|
||||
|
||||
/** Creating first input blob **/
|
||||
Precision inputPrecision = Precision::U8;
|
||||
item.second->setPrecision(inputPrecision);
|
||||
} else if (item.second->getInputData()->getTensorDesc().getDims().size() == 2) {
|
||||
imInfoInputName = item.first;
|
||||
|
||||
Precision inputPrecision = Precision::FP32;
|
||||
item.second->setPrecision(inputPrecision);
|
||||
if ((item.second->getTensorDesc().getDims()[1] != 3 &&
|
||||
item.second->getTensorDesc().getDims()[1] != 6)) {
|
||||
throw std::logic_error("Invalid input info. Should be 3 or 6 values length");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (inputInfo == nullptr) {
|
||||
inputInfo = inputsInfo.begin()->second;
|
||||
}
|
||||
// --------------------------- Prepare output blobs
|
||||
// -------------------------------------------------
|
||||
slog::info << "Preparing output blobs" << slog::endl;
|
||||
|
||||
OutputsDataMap outputsInfo(network.getOutputsInfo());
|
||||
|
||||
std::string outputName;
|
||||
DataPtr outputInfo;
|
||||
|
||||
outputInfo = outputsInfo.begin()->second;
|
||||
outputName = outputInfo->getName();
|
||||
// SSD has an additional post-processing DetectionOutput layer
|
||||
// that simplifies output filtering, try to find it.
|
||||
if (auto ngraphFunction = network.getFunction()) {
|
||||
for (const auto& out : outputsInfo) {
|
||||
for (const auto& op : ngraphFunction->get_ops()) {
|
||||
if (op->get_type_info() == ngraph::op::DetectionOutput::get_type_info_static() &&
|
||||
op->get_friendly_name() == out.second->getName()) {
|
||||
outputName = out.first;
|
||||
outputInfo = out.second;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (outputInfo == nullptr) {
|
||||
throw std::logic_error("Can't find a DetectionOutput layer in the topology");
|
||||
}
|
||||
|
||||
const SizeVector outputDims = outputInfo->getTensorDesc().getDims();
|
||||
|
||||
const int maxProposalCount = outputDims[2];
|
||||
const int objectSize = outputDims[3];
|
||||
|
||||
if (objectSize != 7) {
|
||||
throw std::logic_error("Output item should have 7 as a last dimension");
|
||||
}
|
||||
|
||||
if (outputDims.size() != 4) {
|
||||
throw std::logic_error("Incorrect output dimensions for SSD model");
|
||||
}
|
||||
|
||||
/** Set the precision of output data provided by the user, should be called
|
||||
* before load of the network to the device **/
|
||||
outputInfo->setPrecision(Precision::FP32);
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
// --------------------------- Step 4. Loading model to the device
|
||||
// ------------------------------------------
|
||||
slog::info << "Loading model to the device" << slog::endl;
|
||||
|
||||
ExecutableNetwork executable_network = ie.LoadNetwork(network, FLAGS_d, parseConfig(FLAGS_config));
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
// --------------------------- Step 5. Create infer request
|
||||
// -------------------------------------------------
|
||||
slog::info << "Create infer request" << slog::endl;
|
||||
InferRequest infer_request = executable_network.CreateInferRequest();
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
// --------------------------- Step 6. Prepare input
|
||||
// --------------------------------------------------------
|
||||
/** Collect images data ptrs **/
|
||||
std::vector<std::shared_ptr<unsigned char>> imagesData, originalImagesData;
|
||||
std::vector<size_t> imageWidths, imageHeights;
|
||||
for (auto& i : images) {
|
||||
FormatReader::ReaderPtr reader(i.c_str());
|
||||
if (reader.get() == nullptr) {
|
||||
slog::warn << "Image " + i + " cannot be read!" << slog::endl;
|
||||
continue;
|
||||
}
|
||||
/** Store image data **/
|
||||
std::shared_ptr<unsigned char> originalData(reader->getData());
|
||||
std::shared_ptr<unsigned char> data(
|
||||
reader->getData(inputInfo->getTensorDesc().getDims()[3], inputInfo->getTensorDesc().getDims()[2]));
|
||||
if (data.get() != nullptr) {
|
||||
originalImagesData.push_back(originalData);
|
||||
imagesData.push_back(data);
|
||||
imageWidths.push_back(reader->width());
|
||||
imageHeights.push_back(reader->height());
|
||||
}
|
||||
}
|
||||
if (imagesData.empty())
|
||||
throw std::logic_error("Valid input images were not found!");
|
||||
|
||||
size_t batchSize = network.getBatchSize();
|
||||
slog::info << "Batch size is " << std::to_string(batchSize) << slog::endl;
|
||||
if (batchSize != imagesData.size()) {
|
||||
slog::warn << "Number of images " + std::to_string(imagesData.size()) + " doesn't match batch size " +
|
||||
std::to_string(batchSize)
|
||||
<< slog::endl;
|
||||
batchSize = std::min(batchSize, imagesData.size());
|
||||
slog::warn << "Number of images to be processed is " << std::to_string(batchSize) << slog::endl;
|
||||
}
|
||||
|
||||
/** Creating input blob **/
|
||||
Blob::Ptr imageInput = infer_request.GetBlob(imageInputName);
|
||||
|
||||
/** Filling input tensor with images. First b channel, then g and r channels
|
||||
* **/
|
||||
MemoryBlob::Ptr mimage = as<MemoryBlob>(imageInput);
|
||||
if (!mimage) {
|
||||
slog::err << "We expect image blob to be inherited from MemoryBlob, but "
|
||||
"by fact we were not able "
|
||||
"to cast imageInput to MemoryBlob"
|
||||
<< slog::endl;
|
||||
return 1;
|
||||
}
|
||||
// locked memory holder should be alive all time while access to its buffer
|
||||
// happens
|
||||
auto minputHolder = mimage->wmap();
|
||||
|
||||
size_t num_channels = mimage->getTensorDesc().getDims()[1];
|
||||
size_t image_size = mimage->getTensorDesc().getDims()[3] * mimage->getTensorDesc().getDims()[2];
|
||||
|
||||
unsigned char* data = minputHolder.as<unsigned char*>();
|
||||
|
||||
/** Iterate over all input images limited by batch size **/
|
||||
for (size_t image_id = 0; image_id < std::min(imagesData.size(), batchSize); ++image_id) {
|
||||
/** Iterate over all pixel in image (b,g,r) **/
|
||||
for (size_t pid = 0; pid < image_size; pid++) {
|
||||
/** Iterate over all channels **/
|
||||
for (size_t ch = 0; ch < num_channels; ++ch) {
|
||||
/** [images stride + channels stride + pixel id ] all in
|
||||
* bytes **/
|
||||
data[image_id * image_size * num_channels + ch * image_size + pid] =
|
||||
imagesData.at(image_id).get()[pid * num_channels + ch];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (imInfoInputName != "") {
|
||||
Blob::Ptr input2 = infer_request.GetBlob(imInfoInputName);
|
||||
auto imInfoDim = inputsInfo.find(imInfoInputName)->second->getTensorDesc().getDims()[1];
|
||||
|
||||
/** Fill input tensor with values **/
|
||||
MemoryBlob::Ptr minput2 = as<MemoryBlob>(input2);
|
||||
if (!minput2) {
|
||||
slog::err << "We expect input2 blob to be inherited from MemoryBlob, "
|
||||
"but by fact we were not able "
|
||||
"to cast input2 to MemoryBlob"
|
||||
<< slog::endl;
|
||||
return 1;
|
||||
}
|
||||
// locked memory holder should be alive all time while access to its
|
||||
// buffer happens
|
||||
auto minput2Holder = minput2->wmap();
|
||||
float* p = minput2Holder.as<PrecisionTrait<Precision::FP32>::value_type*>();
|
||||
|
||||
for (size_t image_id = 0; image_id < std::min(imagesData.size(), batchSize); ++image_id) {
|
||||
p[image_id * imInfoDim + 0] =
|
||||
static_cast<float>(inputsInfo[imageInputName]->getTensorDesc().getDims()[2]);
|
||||
p[image_id * imInfoDim + 1] =
|
||||
static_cast<float>(inputsInfo[imageInputName]->getTensorDesc().getDims()[3]);
|
||||
for (size_t k = 2; k < imInfoDim; k++) {
|
||||
p[image_id * imInfoDim + k] = 1.0f; // all scale factors are set to 1.0
|
||||
}
|
||||
}
|
||||
}
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
// --------------------------- Step 7. Do inference
|
||||
// ---------------------------------------------------------
|
||||
slog::info << "Start inference" << slog::endl;
|
||||
infer_request.Infer();
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
// --------------------------- Step 8. Process output
|
||||
// -------------------------------------------------------
|
||||
slog::info << "Processing output blobs" << slog::endl;
|
||||
|
||||
const Blob::Ptr output_blob = infer_request.GetBlob(outputName);
|
||||
MemoryBlob::CPtr moutput = as<MemoryBlob>(output_blob);
|
||||
if (!moutput) {
|
||||
throw std::logic_error("We expect output to be inherited from MemoryBlob, "
|
||||
"but by fact we were not able to cast output to MemoryBlob");
|
||||
}
|
||||
// locked memory holder should be alive all time while access to its buffer
|
||||
// happens
|
||||
auto moutputHolder = moutput->rmap();
|
||||
const float* detection = moutputHolder.as<const PrecisionTrait<Precision::FP32>::value_type*>();
|
||||
|
||||
std::vector<std::vector<int>> boxes(batchSize);
|
||||
std::vector<std::vector<int>> classes(batchSize);
|
||||
|
||||
/* Each detection has image_id that denotes processed image */
|
||||
for (int curProposal = 0; curProposal < maxProposalCount; curProposal++) {
|
||||
auto image_id = static_cast<int>(detection[curProposal * objectSize + 0]);
|
||||
if (image_id < 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
float confidence = detection[curProposal * objectSize + 2];
|
||||
auto label = static_cast<int>(detection[curProposal * objectSize + 1]);
|
||||
auto xmin = static_cast<int>(detection[curProposal * objectSize + 3] * imageWidths[image_id]);
|
||||
auto ymin = static_cast<int>(detection[curProposal * objectSize + 4] * imageHeights[image_id]);
|
||||
auto xmax = static_cast<int>(detection[curProposal * objectSize + 5] * imageWidths[image_id]);
|
||||
auto ymax = static_cast<int>(detection[curProposal * objectSize + 6] * imageHeights[image_id]);
|
||||
|
||||
std::cout << "[" << curProposal << "," << label << "] element, prob = " << confidence << " (" << xmin
|
||||
<< "," << ymin << ")-(" << xmax << "," << ymax << ")"
|
||||
<< " batch id : " << image_id;
|
||||
|
||||
if (confidence > 0.5) {
|
||||
/** Drawing only objects with >50% probability **/
|
||||
classes[image_id].push_back(label);
|
||||
boxes[image_id].push_back(xmin);
|
||||
boxes[image_id].push_back(ymin);
|
||||
boxes[image_id].push_back(xmax - xmin);
|
||||
boxes[image_id].push_back(ymax - ymin);
|
||||
std::cout << " WILL BE PRINTED!";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
for (size_t batch_id = 0; batch_id < batchSize; ++batch_id) {
|
||||
addRectangles(originalImagesData[batch_id].get(),
|
||||
imageHeights[batch_id],
|
||||
imageWidths[batch_id],
|
||||
boxes[batch_id],
|
||||
classes[batch_id],
|
||||
BBOX_THICKNESS);
|
||||
const std::string image_path = "out_" + std::to_string(batch_id) + ".bmp";
|
||||
if (writeOutputBmp(image_path,
|
||||
originalImagesData[batch_id].get(),
|
||||
imageHeights[batch_id],
|
||||
imageWidths[batch_id])) {
|
||||
slog::info << "Image " + image_path + " created!" << slog::endl;
|
||||
} else {
|
||||
throw std::logic_error(std::string("Can't create a file: ") + image_path);
|
||||
}
|
||||
}
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
} catch (const std::exception& error) {
|
||||
slog::err << error.what() << slog::endl;
|
||||
return 1;
|
||||
} catch (...) {
|
||||
slog::err << "Unknown/internal exception happened." << slog::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
slog::info << "Execution successful" << slog::endl;
|
||||
slog::info << slog::endl
|
||||
<< "This sample is an API example, for any performance measurements "
|
||||
"please use the dedicated benchmark_app tool"
|
||||
<< slog::endl;
|
||||
return 0;
|
||||
}
|
@ -1,85 +0,0 @@
|
||||
// Copyright (C) 2018-2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <gflags/gflags.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
/* thickness of a line (in pixels) to be used for bounding boxes */
|
||||
#define BBOX_THICKNESS 2
|
||||
|
||||
/// @brief message for help argument
|
||||
static const char help_message[] = "Print a usage message.";
|
||||
|
||||
/// @brief message for model argument
|
||||
static const char model_message[] = "Required. Path to an .xml file with a trained model.";
|
||||
|
||||
/// @brief message for images argument
|
||||
static const char image_message[] = "Required. Path to an image.";
|
||||
|
||||
/// @brief message for assigning cnn calculation to device
|
||||
static const char target_device_message[] =
|
||||
"Optional. Specify the target device to infer on (the list of available devices is shown "
|
||||
"below). "
|
||||
"Default value is CPU. Use \"-d HETERO:<comma_separated_devices_list>\" format to specify "
|
||||
"HETERO plugin. "
|
||||
"Sample will look for a suitable plugin for device specified.";
|
||||
|
||||
/// @brief message for plugin custom kernels desc
|
||||
static const char custom_plugin_cfg_message[] = "Required for GPU, MYRIAD, HDDL custom kernels. "
|
||||
"Absolute path to the .xml config file with the kernels descriptions.";
|
||||
|
||||
/// @brief message for user library argument
|
||||
static const char custom_ex_library_message[] = "Required for CPU plugin custom layers. "
|
||||
"Absolute path to a shared library with the kernels implementations.";
|
||||
|
||||
/// @brief message for config argument
|
||||
static constexpr char config_message[] = "Path to the configuration file.";
|
||||
|
||||
/// \brief Define flag for showing help message <br>
|
||||
DEFINE_bool(h, false, help_message);
|
||||
|
||||
/// \brief Define parameter for set image file <br>
|
||||
/// It is a required parameter
|
||||
DEFINE_string(i, "", image_message);
|
||||
|
||||
/// \brief Define parameter for set model file <br>
|
||||
/// It is a required parameter
|
||||
DEFINE_string(m, "", model_message);
|
||||
|
||||
/// \brief device the target device to infer on <br>
|
||||
/// It is an optional parameter
|
||||
DEFINE_string(d, "CPU", target_device_message);
|
||||
|
||||
/// @brief Define parameter for plugin custom kernels path <br>
|
||||
/// It is an optional parameter
|
||||
DEFINE_string(c, "", custom_plugin_cfg_message);
|
||||
|
||||
/// @brief Absolute path to CPU extension library with user layers <br>
|
||||
/// It is an optional parameter
|
||||
DEFINE_string(l, "", custom_ex_library_message);
|
||||
|
||||
/// @brief Define path to plugin config
|
||||
DEFINE_string(config, "", config_message);
|
||||
|
||||
/**
|
||||
* \brief This function show a help message
|
||||
*/
|
||||
static void showUsage() {
|
||||
std::cout << std::endl;
|
||||
std::cout << "object_detection_sample_ssd [OPTION]" << std::endl;
|
||||
std::cout << "Options:" << std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout << " -h " << help_message << std::endl;
|
||||
std::cout << " -m \"<path>\" " << model_message << std::endl;
|
||||
std::cout << " -i \"<path>\" " << image_message << std::endl;
|
||||
std::cout << " -l \"<absolute_path>\" " << custom_ex_library_message << std::endl;
|
||||
std::cout << " Or" << std::endl;
|
||||
std::cout << " -c \"<absolute_path>\" " << custom_plugin_cfg_message << std::endl;
|
||||
std::cout << " -d \"<device>\" " << target_device_message << std::endl;
|
||||
}
|
@ -13,14 +13,14 @@
|
||||
/// @brief message for help argument
|
||||
static const char help_message[] = "Print a usage message.";
|
||||
|
||||
/// @brief message for images argument
|
||||
/// @brief message for input data argument
|
||||
static const char input_message[] =
|
||||
"Required. Paths to input files. Example of usage: <file1.ark,file2.ark> or <file.ark> or <file.npz>.";
|
||||
|
||||
/// @brief message for model argument
|
||||
static const char model_message[] = "Required. Path to an .xml file with a trained model (required if -rg is missing).";
|
||||
|
||||
/// @brief message for assigning cnn calculation to device
|
||||
/// @brief message for assigning calculation to device
|
||||
static const char target_device_message[] =
|
||||
"Optional. Specify a target device to infer on. CPU, GPU, MYRIAD, GNA_AUTO, GNA_HW, "
|
||||
"GNA_HW_WITH_SW_FBACK, GNA_SW_FP32, "
|
||||
@ -36,7 +36,7 @@ static const char execution_target_message[] =
|
||||
"or the latest fully supported generation by the software. "
|
||||
"See the GNA Plugin's GNA_EXEC_TARGET config option description.";
|
||||
|
||||
/// @brief message for execution target
|
||||
/// @brief message for compile target
|
||||
static const char compile_target_message[] = "Optional. Specify GNA compile target generation. "
|
||||
"May be one of GNA_TARGET_2_0, GNA_TARGET_3_0. "
|
||||
"By default, generation corresponds to the GNA HW available in the system "
|
||||
|
@ -1,8 +0,0 @@
|
||||
# Copyright (C) 2018-2021 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
ie_add_sample(NAME style_transfer_sample
|
||||
SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp"
|
||||
HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/style_transfer_sample.h"
|
||||
DEPENDENCIES format_reader ie_samples_utils)
|
@ -1,138 +0,0 @@
|
||||
# Style Transfer C++ Sample {#openvino_inference_engine_samples_style_transfer_sample_README}
|
||||
|
||||
This sample demonstrates how to execute an inference of style transfer models using Synchronous Inference Request API.
|
||||
|
||||
Style Transfer C++ sample application demonstrates how to use the following Inference Engine C++ API in applications:
|
||||
|
||||
| Feature | API | Description |
|
||||
|:--- |:--- |:---
|
||||
|Inference Engine Version| `InferenceEngine::GetInferenceEngineVersion` | Get Inference Engine API version
|
||||
|Available Devices|`InferenceEngine::Core::GetAvailableDevices`| Get version information of the devices for inference
|
||||
|Custom Extension Kernels|`InferenceEngine::Core::AddExtension`, `InferenceEngine::Core::SetConfig`| Load extension library and config to the device
|
||||
| Network Operations | `InferenceEngine::CNNNetwork::setBatchSize`, `InferenceEngine::CNNNetwork::getBatchSize` | Managing of network, operate with its batch size. Setting batch size using input image count.
|
||||
|
||||
Basic Inference Engine API is covered by [Hello Classification C++ sample](../hello_classification/README.md).
|
||||
|
||||
| Options | Values |
|
||||
|:--- |:---
|
||||
| Validated Models | [fast-neural-style-mosaic-onnx](@ref omz_models_model_fast_neural_style_mosaic_onnx)
|
||||
| Model Format | Inference Engine Intermediate Representation (\*.xml + \*.bin), ONNX (\*.onnx)
|
||||
| Validated images | The sample uses OpenCV\* to [read input image](https://docs.opencv.org/master/d4/da8/group__imgcodecs.html#ga288b8b3da0892bd651fce07b3bbd3a56) (\*.bmp, \*.png)
|
||||
| Supported devices | [All](../../../docs/IE_DG/supported_plugins/Supported_Devices.md) |
|
||||
| Other language realization | [Python](../../../samples/python/style_transfer_sample/README.md) |
|
||||
|
||||
## How It Works
|
||||
|
||||
Upon the start-up the sample application reads command line parameters, loads specified network and image(s) to the Inference
|
||||
Engine plugin. Then, the sample creates an synchronous inference request object. When inference is done, the application creates output image(s), logging each step in a standard output stream.
|
||||
|
||||
You can see the explicit description of
|
||||
each sample step at [Integration Steps](../../../docs/IE_DG/Integrate_with_customer_application_new_API.md) section of "Integrate the Inference Engine with Your Application" guide.
|
||||
|
||||
## Building
|
||||
|
||||
To build the sample, please use instructions available at [Build the Sample Applications](../../../docs/IE_DG/Samples_Overview.md) section in Inference Engine Samples guide.
|
||||
|
||||
## Running
|
||||
|
||||
To run the sample, you need specify a model and image:
|
||||
|
||||
- you can use [public](@ref omz_models_group_public) or [Intel's](@ref omz_models_group_intel) pre-trained models from the Open Model Zoo. The models can be downloaded using the [Model Downloader](@ref omz_tools_downloader).
|
||||
- you can use images from the media files collection available at https://storage.openvinotoolkit.org/data/test_data.
|
||||
|
||||
Running the application with the `-h` option yields the following usage message:
|
||||
|
||||
```
|
||||
[ INFO ] InferenceEngine:
|
||||
API version ............<version>
|
||||
Build ..................<build>
|
||||
Description ....... API
|
||||
[ INFO ] Parsing input parameters
|
||||
|
||||
style_transfer_sample [OPTION]
|
||||
Options:
|
||||
|
||||
-h Print a usage message.
|
||||
-i "<path>" Path to a folder with images or paths to image files.
|
||||
-m "<path>" Required. Path to an .xml file with a trained model.
|
||||
-l "<absolute_path>" Required for CPU plugin custom layers. Absolute path to a shared library with the kernels implementations.
|
||||
Or
|
||||
-c "<absolute_path>" Required for GPU, MYRIAD, HDDL custom kernels. Absolute path to the .xml config file with the kernels descriptions.
|
||||
-d "<device>" Optional. Specify the target device to infer on (the list of available devices is shown below). Default value is CPU. Use "-d HETERO:<comma_separated_devices_list>" format to specify HETERO plugin. Sample will look for a suitable plugin for device specified.
|
||||
-mean_val_r,
|
||||
-mean_val_g,
|
||||
-mean_val_b Mean values. Required if the model needs mean values for preprocessing and postprocessing.
|
||||
|
||||
Available target devices: <devices>
|
||||
```
|
||||
|
||||
Running the application with the empty list of options yields the usage message given above and an error message.
|
||||
|
||||
> **NOTES**:
|
||||
>
|
||||
> - 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).
|
||||
>
|
||||
> - 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.
|
||||
|
||||
### Example
|
||||
1. Download a pre-trained model using [Model Downloader](@ref omz_tools_downloader):
|
||||
```
|
||||
python <path_to_omz_tools>/downloader.py --name fast-neural-style-mosaic-onnx
|
||||
```
|
||||
|
||||
2. `fast-neural-style-mosaic-onnx` model does not need to be converted, because it is already in necessary format, so you can skip this step. If you want to use a other model that is not in the Inference Engine IR or ONNX format, you can convert it using the model converter script:
|
||||
|
||||
```
|
||||
python <path_to_omz_tools>/converter.py --name <model_name>
|
||||
```
|
||||
|
||||
3. Perform inference of `car.bmp` and `cat.jpg` using `fast-neural-style-mosaic-onnx` model on a `GPU`, for example:
|
||||
|
||||
```
|
||||
<path_to_sample>/style_transfer_sample -m <path_to_model>/fast-neural-style-mosaic-onnx.onnx -i <path_to_image>/car.bmp <path_to_image>/cat.jpg -d GPU
|
||||
```
|
||||
|
||||
## Sample Output
|
||||
|
||||
The sample application logs each step in a standard output stream and creates an image (`out1.bmp`) or a sequence of images (`out1.bmp`, ..., `out<N>.bmp`) which are redrawn in style of the style transfer model used for the sample.
|
||||
|
||||
```
|
||||
[ INFO ] InferenceEngine:
|
||||
IE version ......... 2021.4.0
|
||||
Build ........... 2021.4.0-3839-cd81789d294-releases/2021/4
|
||||
[ INFO ] Parsing input parameters
|
||||
[ INFO ] Files were added: 2
|
||||
[ INFO ] C:\images\car.bmp
|
||||
[ INFO ] C:\images\cat.jpg
|
||||
[ INFO ] Loading Inference Engine
|
||||
[ INFO ] Device info:
|
||||
GPU
|
||||
clDNNPlugin version ......... 2021.4.0
|
||||
Build ........... 2021.4.0-3839-cd81789d294-releases/2021/4
|
||||
|
||||
[ INFO ] Loading network files:
|
||||
[ INFO ] C:\openvino\deployment_tools\open_model_zoo\tools\downloader\public\fast-neural-style-mosaic-onnx\fast-neural-style-mosaic-onnx.onnx
|
||||
[ INFO ] Preparing input blobs
|
||||
[ WARNING ] Image is resized from (749, 637) to (224, 224)
|
||||
[ WARNING ] Image is resized from (300, 300) to (224, 224)
|
||||
[ INFO ] Batch size is 2
|
||||
[ INFO ] Preparing output blobs
|
||||
[ INFO ] Loading model to the device
|
||||
[ INFO ] Create infer request
|
||||
[ INFO ] Start inference
|
||||
[ INFO ] Output size [N,C,H,W]: 2, 3, 224, 224
|
||||
[ INFO ] Image out1.bmp created!
|
||||
[ INFO ] Image out2.bmp created!
|
||||
[ INFO ] Execution successful
|
||||
|
||||
[ INFO ] This sample is an API example, for any performance measurements please use the dedicated benchmark_app tool
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
- [Integrate the Inference Engine with Your Application](../../../docs/IE_DG/Integrate_with_customer_application_new_API.md)
|
||||
- [Using Inference Engine Samples](../../../docs/IE_DG/Samples_Overview.md)
|
||||
- [Model Downloader](@ref omz_tools_downloader)
|
||||
- [Model Optimizer](../../../docs/MO_DG/Deep_Learning_Model_Optimizer_DevGuide.md)
|
@ -1,308 +0,0 @@
|
||||
// Copyright (C) 2018-2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <format_reader_ptr.h>
|
||||
|
||||
#include <inference_engine.hpp>
|
||||
#include <memory>
|
||||
#include <samples/args_helper.hpp>
|
||||
#include <samples/common.hpp>
|
||||
#include <samples/slog.hpp>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "style_transfer_sample.h"
|
||||
|
||||
using namespace InferenceEngine;
|
||||
|
||||
/**
|
||||
* @brief Checks input args
|
||||
* @param argc number of args
|
||||
* @param argv list of input arguments
|
||||
* @return bool status true(Success) or false(Fail)
|
||||
*/
|
||||
bool ParseAndCheckCommandLine(int argc, char* argv[]) {
|
||||
slog::info << "Parsing input parameters" << slog::endl;
|
||||
|
||||
gflags::ParseCommandLineNonHelpFlags(&argc, &argv, true);
|
||||
if (FLAGS_h) {
|
||||
showUsage();
|
||||
showAvailableDevices();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (FLAGS_m.empty()) {
|
||||
showUsage();
|
||||
throw std::logic_error("Model is required but not set. Please set -m option.");
|
||||
}
|
||||
|
||||
if (FLAGS_i.empty()) {
|
||||
showUsage();
|
||||
throw std::logic_error("Input is required but not set. Please set -i option.");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief The entry point for inference engine deconvolution sample application
|
||||
* @file style_transfer_sample/main.cpp
|
||||
* @example style_transfer_sample/main.cpp
|
||||
*/
|
||||
int main(int argc, char* argv[]) {
|
||||
try {
|
||||
// ------------------------------ Get Inference Engine version
|
||||
// ------------------------------------------------------
|
||||
slog::info << "InferenceEngine: " << GetInferenceEngineVersion() << slog::endl;
|
||||
// ------------------------------ Parsing and validation of input arguments
|
||||
// ---------------------------------
|
||||
if (!ParseAndCheckCommandLine(argc, argv)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** This vector stores paths to the processed images **/
|
||||
std::vector<std::string> imageNames;
|
||||
parseInputFilesArguments(imageNames);
|
||||
if (imageNames.empty())
|
||||
throw std::logic_error("No suitable images were found");
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
// --------------------------- Step 1. Initialize inference engine core
|
||||
// -------------------------------------
|
||||
slog::info << "Loading Inference Engine" << slog::endl;
|
||||
Core ie;
|
||||
|
||||
// ------------------------------ Get Available Devices
|
||||
// ------------------------------------------------------
|
||||
slog::info << "Device info: " << slog::endl;
|
||||
slog::info << ie.GetVersions(FLAGS_d) << slog::endl;
|
||||
|
||||
if (!FLAGS_l.empty()) {
|
||||
IExtensionPtr extension_ptr = std::make_shared<Extension>(FLAGS_l);
|
||||
ie.AddExtension(extension_ptr);
|
||||
slog::info << "Extension loaded: " << FLAGS_l << slog::endl;
|
||||
}
|
||||
if (!FLAGS_c.empty() && (FLAGS_d == "GPU" || FLAGS_d == "MYRIAD" || FLAGS_d == "HDDL")) {
|
||||
// Config for device plugin custom extension is loaded from an .xml
|
||||
// description
|
||||
ie.SetConfig({{PluginConfigParams::KEY_CONFIG_FILE, FLAGS_c}}, "GPU");
|
||||
slog::info << "Config for " << FLAGS_d << " device plugin custom extension loaded: " << FLAGS_c
|
||||
<< slog::endl;
|
||||
}
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
// Step 2. Read a model in OpenVINO Intermediate Representation (.xml and
|
||||
// .bin files) or ONNX (.onnx file) format
|
||||
slog::info << "Loading network files:" << slog::endl << FLAGS_m << slog::endl;
|
||||
|
||||
/** Read network model **/
|
||||
CNNNetwork network = ie.ReadNetwork(FLAGS_m);
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
// --------------------------- Step 3. Configure input & output
|
||||
// ---------------------------------------------
|
||||
|
||||
// --------------------------- Prepare input blobs
|
||||
// -----------------------------------------------------
|
||||
slog::info << "Preparing input blobs" << slog::endl;
|
||||
|
||||
/** Taking information about all topology inputs **/
|
||||
InputsDataMap inputInfo(network.getInputsInfo());
|
||||
|
||||
if (inputInfo.size() != 1)
|
||||
throw std::logic_error("Sample supports topologies only with 1 input");
|
||||
auto inputInfoItem = *inputInfo.begin();
|
||||
|
||||
/** Iterate over all the input blobs **/
|
||||
std::vector<std::shared_ptr<uint8_t>> imagesData;
|
||||
|
||||
/** Specifying the precision of input data.
|
||||
* This should be called before load of the network to the device **/
|
||||
inputInfoItem.second->setPrecision(Precision::FP32);
|
||||
|
||||
/** Collect images data ptrs **/
|
||||
for (auto& i : imageNames) {
|
||||
FormatReader::ReaderPtr reader(i.c_str());
|
||||
if (reader.get() == nullptr) {
|
||||
slog::warn << "Image " + i + " cannot be read!" << slog::endl;
|
||||
continue;
|
||||
}
|
||||
/** Store image data **/
|
||||
std::shared_ptr<unsigned char> data(reader->getData(inputInfoItem.second->getTensorDesc().getDims()[3],
|
||||
inputInfoItem.second->getTensorDesc().getDims()[2]));
|
||||
if (data.get() != nullptr) {
|
||||
imagesData.push_back(data);
|
||||
}
|
||||
}
|
||||
if (imagesData.empty())
|
||||
throw std::logic_error("Valid input images were not found!");
|
||||
|
||||
/** Setting batch size using image count **/
|
||||
network.setBatchSize(imagesData.size());
|
||||
slog::info << "Batch size is " << std::to_string(network.getBatchSize()) << slog::endl;
|
||||
|
||||
// ------------------------------ Prepare output blobs
|
||||
// -------------------------------------------------
|
||||
slog::info << "Preparing output blobs" << slog::endl;
|
||||
|
||||
OutputsDataMap outputInfo(network.getOutputsInfo());
|
||||
// BlobMap outputBlobs;
|
||||
std::string firstOutputName;
|
||||
|
||||
const float meanValues[] = {static_cast<const float>(FLAGS_mean_val_r),
|
||||
static_cast<const float>(FLAGS_mean_val_g),
|
||||
static_cast<const float>(FLAGS_mean_val_b)};
|
||||
|
||||
for (auto& item : outputInfo) {
|
||||
if (firstOutputName.empty()) {
|
||||
firstOutputName = item.first;
|
||||
}
|
||||
DataPtr outputData = item.second;
|
||||
if (!outputData) {
|
||||
throw std::logic_error("output data pointer is not valid");
|
||||
}
|
||||
|
||||
item.second->setPrecision(Precision::FP32);
|
||||
}
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
// --------------------------- Step 4. Loading model to the device
|
||||
// ------------------------------------------
|
||||
slog::info << "Loading model to the device" << slog::endl;
|
||||
ExecutableNetwork executable_network = ie.LoadNetwork(network, FLAGS_d);
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
// --------------------------- Step 5. Create infer request
|
||||
// -------------------------------------------------
|
||||
slog::info << "Create infer request" << slog::endl;
|
||||
InferRequest infer_request = executable_network.CreateInferRequest();
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
// --------------------------- Step 6. Prepare input
|
||||
// --------------------------------------------------------
|
||||
/** Iterate over all the input blobs **/
|
||||
for (const auto& item : inputInfo) {
|
||||
MemoryBlob::Ptr minput = as<MemoryBlob>(infer_request.GetBlob(item.first));
|
||||
if (!minput) {
|
||||
slog::err << "We expect input blob to be inherited from MemoryBlob, "
|
||||
<< "but by fact we were not able to cast it to MemoryBlob" << slog::endl;
|
||||
return 1;
|
||||
}
|
||||
// locked memory holder should be alive all time while access to its
|
||||
// buffer happens
|
||||
auto ilmHolder = minput->wmap();
|
||||
|
||||
/** Filling input tensor with images. First b channel, then g and r
|
||||
* channels **/
|
||||
size_t num_channels = minput->getTensorDesc().getDims()[1];
|
||||
size_t image_size = minput->getTensorDesc().getDims()[3] * minput->getTensorDesc().getDims()[2];
|
||||
|
||||
auto data = ilmHolder.as<PrecisionTrait<Precision::FP32>::value_type*>();
|
||||
if (data == nullptr)
|
||||
throw std::runtime_error("Input blob has not allocated buffer");
|
||||
/** Iterate over all input images **/
|
||||
for (size_t image_id = 0; image_id < imagesData.size(); ++image_id) {
|
||||
/** Iterate over all pixel in image (b,g,r) **/
|
||||
for (size_t pid = 0; pid < image_size; pid++) {
|
||||
/** Iterate over all channels **/
|
||||
for (size_t ch = 0; ch < num_channels; ++ch) {
|
||||
/** [images stride + channels stride + pixel id ] all in
|
||||
* bytes **/
|
||||
data[image_id * image_size * num_channels + ch * image_size + pid] =
|
||||
imagesData.at(image_id).get()[pid * num_channels + ch] - meanValues[ch];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
// --------------------------- Step 7. Do inference
|
||||
// ---------------------------------------------------------
|
||||
slog::info << "Start inference" << slog::endl;
|
||||
infer_request.Infer();
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
// --------------------------- Step 8. Process output
|
||||
// -------------------------------------------------------
|
||||
MemoryBlob::CPtr moutput = as<MemoryBlob>(infer_request.GetBlob(firstOutputName));
|
||||
if (!moutput) {
|
||||
throw std::logic_error("We expect output to be inherited from MemoryBlob, "
|
||||
"but by fact we were not able to cast it to MemoryBlob");
|
||||
}
|
||||
// locked memory holder should be alive all time while access to its buffer
|
||||
// happens
|
||||
auto lmoHolder = moutput->rmap();
|
||||
const auto output_data = lmoHolder.as<const PrecisionTrait<Precision::FP32>::value_type*>();
|
||||
|
||||
size_t num_images = moutput->getTensorDesc().getDims()[0];
|
||||
size_t num_channels = moutput->getTensorDesc().getDims()[1];
|
||||
size_t H = moutput->getTensorDesc().getDims()[2];
|
||||
size_t W = moutput->getTensorDesc().getDims()[3];
|
||||
size_t nPixels = W * H;
|
||||
|
||||
slog::info << "Output size [N,C,H,W]: " << num_images << ", " << num_channels << ", " << H << ", " << W
|
||||
<< slog::endl;
|
||||
|
||||
{
|
||||
std::vector<float> data_img(nPixels * num_channels);
|
||||
|
||||
for (size_t n = 0; n < num_images; n++) {
|
||||
for (size_t i = 0; i < nPixels; i++) {
|
||||
data_img[i * num_channels] =
|
||||
static_cast<float>(output_data[i + n * nPixels * num_channels] + meanValues[0]);
|
||||
data_img[i * num_channels + 1] =
|
||||
static_cast<float>(output_data[(i + nPixels) + n * nPixels * num_channels] + meanValues[1]);
|
||||
data_img[i * num_channels + 2] =
|
||||
static_cast<float>(output_data[(i + 2 * nPixels) + n * nPixels * num_channels] + meanValues[2]);
|
||||
|
||||
float temp = data_img[i * num_channels];
|
||||
data_img[i * num_channels] = data_img[i * num_channels + 2];
|
||||
data_img[i * num_channels + 2] = temp;
|
||||
|
||||
if (data_img[i * num_channels] < 0)
|
||||
data_img[i * num_channels] = 0;
|
||||
if (data_img[i * num_channels] > 255)
|
||||
data_img[i * num_channels] = 255;
|
||||
|
||||
if (data_img[i * num_channels + 1] < 0)
|
||||
data_img[i * num_channels + 1] = 0;
|
||||
if (data_img[i * num_channels + 1] > 255)
|
||||
data_img[i * num_channels + 1] = 255;
|
||||
|
||||
if (data_img[i * num_channels + 2] < 0)
|
||||
data_img[i * num_channels + 2] = 0;
|
||||
if (data_img[i * num_channels + 2] > 255)
|
||||
data_img[i * num_channels + 2] = 255;
|
||||
}
|
||||
std::string out_img_name = std::string("out" + std::to_string(n + 1) + ".bmp");
|
||||
std::ofstream outFile;
|
||||
outFile.open(out_img_name.c_str(), std::ios_base::binary);
|
||||
if (!outFile.is_open()) {
|
||||
throw new std::runtime_error("Cannot create " + out_img_name);
|
||||
}
|
||||
std::vector<unsigned char> data_img2;
|
||||
for (float i : data_img) {
|
||||
data_img2.push_back(static_cast<unsigned char>(i));
|
||||
}
|
||||
writeOutputBmp(data_img2.data(), H, W, outFile);
|
||||
outFile.close();
|
||||
slog::info << "Image " << out_img_name << " created!" << slog::endl;
|
||||
}
|
||||
}
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
} catch (const std::exception& error) {
|
||||
slog::err << error.what() << slog::endl;
|
||||
return 1;
|
||||
} catch (...) {
|
||||
slog::err << "Unknown/internal exception happened" << slog::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
slog::info << "Execution successful" << slog::endl;
|
||||
slog::info << slog::endl
|
||||
<< "This sample is an API example, for any performance measurements "
|
||||
"please use the dedicated benchmark_app tool"
|
||||
<< slog::endl;
|
||||
return 0;
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
// Copyright (C) 2018-2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <gflags/gflags.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
/// @brief message for help argument
|
||||
static const char help_message[] = "Print a usage message.";
|
||||
|
||||
/// @brief message for images argument
|
||||
static const char image_message[] = "Path to a folder with images or paths to image files.";
|
||||
|
||||
/// @brief message for model argument
|
||||
static const char model_message[] = "Required. Path to an .xml file with a trained model.";
|
||||
|
||||
/// @brief message for assigning cnn calculation to device
|
||||
static const char target_device_message[] =
|
||||
"Optional. Specify the target device to infer on (the list of available devices is shown "
|
||||
"below). "
|
||||
"Default value is CPU. Use \"-d HETERO:<comma_separated_devices_list>\" format to specify "
|
||||
"HETERO plugin. "
|
||||
"Sample will look for a suitable plugin for device specified";
|
||||
|
||||
/// @brief message for plugin custom kernels desc
|
||||
static const char custom_plugin_cfg_message[] = "Required for GPU, MYRIAD, HDDL custom kernels. "
|
||||
"Absolute path to the .xml config file with the kernels descriptions.";
|
||||
|
||||
/// @brief message for user library argument
|
||||
static const char custom_ex_library_message[] = "Required for CPU plugin custom layers. "
|
||||
"Absolute path to a shared library with the kernels implementations.";
|
||||
|
||||
/// @brief message for mean values arguments
|
||||
static const char preprocess_data_message[] =
|
||||
"Mean values. Required if the model needs mean values for preprocessing and postprocessing.";
|
||||
|
||||
/// @brief Define flag for showing help message <br>
|
||||
DEFINE_bool(h, false, help_message);
|
||||
|
||||
/// @brief Define parameter for set image file or folder with images <br>
|
||||
/// It is a required parameter
|
||||
DEFINE_string(i, "", image_message);
|
||||
|
||||
/// @brief Define parameter for set model file <br>
|
||||
/// It is a required parameter
|
||||
DEFINE_string(m, "", model_message);
|
||||
|
||||
/// @brief device the target device to infer on <br>
|
||||
/// It is an optional parameter
|
||||
DEFINE_string(d, "CPU", target_device_message);
|
||||
|
||||
/// @brief Define parameter for plugin custom kernels path <br>
|
||||
/// It is an optional parameter
|
||||
DEFINE_string(c, "", custom_plugin_cfg_message);
|
||||
|
||||
/// @brief Absolute path to CPU extension library with user layers <br>
|
||||
/// It is an optional parameter
|
||||
DEFINE_string(l, "", custom_ex_library_message);
|
||||
|
||||
/// @brief Define parameter preprocess_data for rgb channels <br>
|
||||
/// (default 0) for each channels
|
||||
/// It is an optional parameter
|
||||
DEFINE_double(mean_val_r, 0.0, preprocess_data_message);
|
||||
DEFINE_double(mean_val_g, 0.0, preprocess_data_message);
|
||||
DEFINE_double(mean_val_b, 0.0, preprocess_data_message);
|
||||
|
||||
/**
|
||||
* @brief This function show a help message
|
||||
*/
|
||||
static void showUsage() {
|
||||
std::cout << std::endl;
|
||||
std::cout << "style_transfer_sample [OPTION]" << std::endl;
|
||||
std::cout << "Options:" << std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout << " -h " << help_message << std::endl;
|
||||
std::cout << " -i \"<path>\" " << image_message << std::endl;
|
||||
std::cout << " -m \"<path>\" " << model_message << std::endl;
|
||||
std::cout << " -l \"<absolute_path>\" " << custom_ex_library_message << std::endl;
|
||||
std::cout << " Or" << std::endl;
|
||||
std::cout << " -c \"<absolute_path>\" " << custom_plugin_cfg_message << std::endl;
|
||||
std::cout << " -d \"<device>\" " << target_device_message << std::endl;
|
||||
std::cout << " -mean_val_r," << std::endl;
|
||||
std::cout << " -mean_val_g," << std::endl;
|
||||
std::cout << " -mean_val_b " << preprocess_data_message << std::endl;
|
||||
}
|
@ -1,146 +0,0 @@
|
||||
# Style Transfer Python* Sample {#openvino_inference_engine_ie_bridges_python_sample_style_transfer_sample_README}
|
||||
|
||||
This sample demonstrates how to do synchronous inference of style transfer networks using Network Batch Size Feature.
|
||||
You can specify multiple images to input, a network batch size will be set equal to their number automatically.
|
||||
Models with only 1 input and output are supported.
|
||||
|
||||
The following Inference Engine Python API is used in the application:
|
||||
|
||||
| Feature | API | Description |
|
||||
| :----------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------- |
|
||||
| Network Operations | [IENetwork.batch_size] | Managing of network: configure input and output blobs |
|
||||
| Custom Extension Kernels | [IECore.add_extension], [IECore.set_config] | Load extension library and config to the device |
|
||||
|
||||
Basic Inference Engine API is covered by [Hello Classification Python* Sample](../hello_classification/README.md).
|
||||
|
||||
| Options | Values |
|
||||
| :------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Validated Models | [fast-neural-style-mosaic-onnx](@ref omz_models_model_fast_neural_style_mosaic_onnx) |
|
||||
| Model Format | Inference Engine Intermediate Representation (.xml + .bin), ONNX (.onnx) |
|
||||
| Supported devices | [All](../../../docs/IE_DG/supported_plugins/Supported_Devices.md) |
|
||||
| Other language realization | [C++](../../../samples/cpp/style_transfer_sample/README.md) |
|
||||
|
||||
## How It Works
|
||||
|
||||
At startup, the sample application reads command-line parameters, prepares input data, loads a specified model and image(s) to the Inference Engine plugin, performs synchronous inference, and processes output data.
|
||||
As a result, the program creates an output image(s), logging each step in a standard output stream.
|
||||
|
||||
You can see the explicit description of
|
||||
each sample step at [Integration Steps](../../../docs/IE_DG/Integrate_with_customer_application_new_API.md) section of "Integrate the Inference Engine with Your Application" guide.
|
||||
|
||||
## Running
|
||||
|
||||
Run the application with the `-h` option to see the usage message:
|
||||
|
||||
```
|
||||
python <path_to_sample>/style_transfer_sample.py -h
|
||||
```
|
||||
|
||||
Usage message:
|
||||
|
||||
```
|
||||
usage: style_transfer_sample.py [-h] -m MODEL -i INPUT [INPUT ...]
|
||||
[-l EXTENSION] [-c CONFIG] [-d DEVICE]
|
||||
[--original_size] [--mean_val_r MEAN_VAL_R]
|
||||
[--mean_val_g MEAN_VAL_G]
|
||||
[--mean_val_b MEAN_VAL_B]
|
||||
|
||||
Options:
|
||||
-h, --help Show this help message and exit.
|
||||
-m MODEL, --model MODEL
|
||||
Required. Path to an .xml or .onnx file with a trained
|
||||
model.
|
||||
-i INPUT [INPUT ...], --input INPUT [INPUT ...]
|
||||
Required. Path to an image file.
|
||||
-l EXTENSION, --extension EXTENSION
|
||||
Optional. Required by the CPU Plugin for executing the
|
||||
custom operation on a CPU. Absolute path to a shared
|
||||
library with the kernels implementations.
|
||||
-c CONFIG, --config CONFIG
|
||||
Optional. Required by GPU or VPU Plugins for the
|
||||
custom operation kernel. Absolute path to operation
|
||||
description file (.xml).
|
||||
-d DEVICE, --device DEVICE
|
||||
Optional. Specify the target device to infer on; CPU,
|
||||
GPU, MYRIAD, HDDL or HETERO: is acceptable. The sample
|
||||
will look for a suitable plugin for device specified.
|
||||
Default value is CPU.
|
||||
--original_size Optional. Resize an output image to original image
|
||||
size.
|
||||
--mean_val_r MEAN_VAL_R
|
||||
Optional. Mean value of red channel for mean value
|
||||
subtraction in postprocessing.
|
||||
--mean_val_g MEAN_VAL_G
|
||||
Optional. Mean value of green channel for mean value
|
||||
subtraction in postprocessing.
|
||||
--mean_val_b MEAN_VAL_B
|
||||
Optional. Mean value of blue channel for mean value
|
||||
subtraction in postprocessing.
|
||||
```
|
||||
|
||||
To run the sample, you need specify a model and image:
|
||||
- you can use [public](@ref omz_models_group_public) or [Intel's](@ref omz_models_group_intel) pre-trained models from the Open Model Zoo. The models can be downloaded using the [Model Downloader](@ref omz_tools_downloader).
|
||||
- you can use images from the media files collection available at https://storage.openvinotoolkit.org/data/test_data.
|
||||
|
||||
> **NOTES**:
|
||||
>
|
||||
> - 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).
|
||||
>
|
||||
> - 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.
|
||||
|
||||
### Example
|
||||
1. Download a pre-trained model using [Model Downloader](@ref omz_tools_downloader):
|
||||
```
|
||||
python <path_to_omz_tools>/downloader.py --name fast-neural-style-mosaic-onnx
|
||||
```
|
||||
|
||||
2. `fast-neural-style-mosaic-onnx` model does not need to be converted, because it is already in necessary format, so you can skip this step. If you want to use a other model that is not in the Inference Engine IR or ONNX format, you can convert it using the model converter script:
|
||||
|
||||
```
|
||||
python <path_to_omz_tools>/converter.py --name <model_name>
|
||||
```
|
||||
|
||||
3. Perform inference of `car.bmp` and `cat.jpg` using `fast-neural-style-mosaic-onnx` model on a `GPU`, for example:
|
||||
|
||||
```
|
||||
python <path_to_sample>/style_transfer_sample.py -m <path_to_model>/fast-neural-style-mosaic-onnx.onnx -i <path_to_image>/car.bmp <path_to_image>/cat.jpg -d GPU
|
||||
```
|
||||
|
||||
## Sample Output
|
||||
|
||||
The sample application logs each step in a standard output stream and creates an output image (`out_0.bmp`) or a sequence of images (`out_0.bmp`, .., `out_<n>.bmp`) that are redrawn in the style of the style transfer model used.
|
||||
|
||||
```
|
||||
[ INFO ] Creating Inference Engine
|
||||
[ INFO ] Reading the network: c:\openvino\deployment_tools\open_model_zoo\tools\downloader\public\fast-neural-style-mosaic-onnx\fast-neural-style-mosaic-onnx.onnx
|
||||
[ INFO ] Configuring input and output blobs
|
||||
[ INFO ] Loading the model to the plugin
|
||||
[ WARNING ] Image c:\images\car.bmp is resized from (637, 749) to (224, 224)
|
||||
[ WARNING ] Image c:\images\cat.jpg is resized from (300, 300) to (224, 224)
|
||||
[ INFO ] Starting inference in synchronous mode
|
||||
[ INFO ] Image out_0.bmp created!
|
||||
[ INFO ] Image out_1.bmp created!
|
||||
[ INFO ] This sample is an API example, for any performance measurements please use the dedicated benchmark_app tool
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
- [Integrate the Inference Engine with Your Application](../../../docs/IE_DG/Integrate_with_customer_application_new_API.md)
|
||||
- [Using Inference Engine Samples](../../../docs/IE_DG/Samples_Overview.md)
|
||||
- [Model Downloader](@ref omz_tools_downloader)
|
||||
- [Model Optimizer](../../../docs/MO_DG/Deep_Learning_Model_Optimizer_DevGuide.md)
|
||||
|
||||
[IECore]:https://docs.openvinotoolkit.org/latest/ie_python_api/classie__api_1_1IECore.html
|
||||
[IECore.add_extension]:https://docs.openvinotoolkit.org/latest/ie_python_api/classie__api_1_1IECore.html#a8a4b671a9928c7c059bd1e76d2333967
|
||||
[IECore.set_config]:https://docs.openvinotoolkit.org/latest/ie_python_api/classie__api_1_1IECore.html#a2c738cee90fca27146e629825c039a05
|
||||
[IECore.read_network]:https://docs.openvinotoolkit.org/latest/ie_python_api/classie__api_1_1IECore.html#a0d69c298618fab3a08b855442dca430f
|
||||
[IENetwork.input_info]:https://docs.openvinotoolkit.org/latest/ie_python_api/classie__api_1_1IENetwork.html#data_fields
|
||||
[IENetwork.outputs]:https://docs.openvinotoolkit.org/latest/ie_python_api/classie__api_1_1IENetwork.html#data_fields
|
||||
[InputInfoPtr.precision]:https://docs.openvinotoolkit.org/latest/ie_python_api/classie__api_1_1InputInfoPtr.html#data_fields
|
||||
[DataPtr.precision]:https://docs.openvinotoolkit.org/latest/ie_python_api/classie__api_1_1DataPtr.html#data_fields
|
||||
[IENetwork.batch_size]:https://docs.openvinotoolkit.org/latest/ie_python_api/classie__api_1_1IENetwork.html#a79a647cb1b49645616eaeb2ca255ef2e
|
||||
[IECore.load_network]:https://docs.openvinotoolkit.org/latest/ie_python_api/classie__api_1_1IECore.html#ac9a2e043d14ccfa9c6bbf626cfd69fcc
|
||||
[InputInfoPtr.input_data.shape]:https://docs.openvinotoolkit.org/latest/ie_python_api/classie__api_1_1InputInfoPtr.html#data_fields
|
||||
[ExecutableNetwork.infer]:https://docs.openvinotoolkit.org/latest/ie_python_api/classie__api_1_1ExecutableNetwork.html#aea96e8e534c8e23d8b257bad11063519
|
@ -1,150 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2018-2021 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
import argparse
|
||||
import logging as log
|
||||
import os
|
||||
import sys
|
||||
|
||||
import cv2
|
||||
import numpy as np
|
||||
from openvino.inference_engine import IECore
|
||||
|
||||
|
||||
def parse_args() -> argparse.Namespace:
|
||||
"""Parse and return command line arguments"""
|
||||
parser = argparse.ArgumentParser(add_help=False)
|
||||
args = parser.add_argument_group('Options')
|
||||
# fmt: off
|
||||
args.add_argument('-h', '--help', action='help', help='Show this help message and exit.')
|
||||
args.add_argument('-m', '--model', required=True, type=str,
|
||||
help='Required. Path to an .xml or .onnx file with a trained model.')
|
||||
args.add_argument('-i', '--input', required=True, type=str, nargs='+', help='Required. Path to an image file.')
|
||||
args.add_argument('-l', '--extension', type=str, default=None,
|
||||
help='Optional. Required by the CPU Plugin for executing the custom operation on a CPU. '
|
||||
'Absolute path to a shared library with the kernels implementations.')
|
||||
args.add_argument('-c', '--config', type=str, default=None,
|
||||
help='Optional. Required by GPU or VPU Plugins for the custom operation kernel. '
|
||||
'Absolute path to operation description file (.xml).')
|
||||
args.add_argument('-d', '--device', default='CPU', type=str,
|
||||
help='Optional. Specify the target device to infer on; CPU, GPU, MYRIAD, HDDL or HETERO: '
|
||||
'is acceptable. The sample will look for a suitable plugin for device specified. '
|
||||
'Default value is CPU.')
|
||||
args.add_argument('--original_size', action='store_true', default=False,
|
||||
help='Optional. Resize an output image to original image size.')
|
||||
args.add_argument('--mean_val_r', default=0, type=float,
|
||||
help='Optional. Mean value of red channel for mean value subtraction in postprocessing.')
|
||||
args.add_argument('--mean_val_g', default=0, type=float,
|
||||
help='Optional. Mean value of green channel for mean value subtraction in postprocessing.')
|
||||
args.add_argument('--mean_val_b', default=0, type=float,
|
||||
help='Optional. Mean value of blue channel for mean value subtraction in postprocessing.')
|
||||
# fmt: on
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def main():
|
||||
log.basicConfig(format='[ %(levelname)s ] %(message)s', level=log.INFO, stream=sys.stdout)
|
||||
args = parse_args()
|
||||
|
||||
# ---------------------------Step 1. Initialize inference engine core--------------------------------------------------
|
||||
log.info('Creating Inference Engine')
|
||||
ie = IECore()
|
||||
|
||||
if args.extension and args.device == 'CPU':
|
||||
log.info(f'Loading the {args.device} extension: {args.extension}')
|
||||
ie.add_extension(args.extension, args.device)
|
||||
|
||||
if args.config and args.device in ('GPU', 'MYRIAD', 'HDDL'):
|
||||
log.info(f'Loading the {args.device} configuration: {args.config}')
|
||||
ie.set_config({'CONFIG_FILE': args.config}, args.device)
|
||||
|
||||
# ---------------------------Step 2. Read a model in OpenVINO Intermediate Representation or ONNX format---------------
|
||||
log.info(f'Reading the network: {args.model}')
|
||||
# (.xml and .bin files) or (.onnx file)
|
||||
net = ie.read_network(model=args.model)
|
||||
|
||||
if len(net.input_info) != 1:
|
||||
log.error('Sample supports only single input topologies')
|
||||
return -1
|
||||
if len(net.outputs) != 1:
|
||||
log.error('Sample supports only single output topologies')
|
||||
return -1
|
||||
|
||||
# ---------------------------Step 3. Configure input & output----------------------------------------------------------
|
||||
log.info('Configuring input and output blobs')
|
||||
# Get names of input and output blobs
|
||||
input_blob = next(iter(net.input_info))
|
||||
out_blob = next(iter(net.outputs))
|
||||
|
||||
# Set input and output precision manually
|
||||
net.input_info[input_blob].precision = 'U8'
|
||||
net.outputs[out_blob].precision = 'FP32'
|
||||
|
||||
# Set a batch size to a equal number of input images
|
||||
net.batch_size = len(args.input)
|
||||
|
||||
# ---------------------------Step 4. Loading model to the device-------------------------------------------------------
|
||||
log.info('Loading the model to the plugin')
|
||||
exec_net = ie.load_network(network=net, device_name=args.device)
|
||||
|
||||
# ---------------------------Step 5. Create infer request--------------------------------------------------------------
|
||||
# load_network() method of the IECore class with a specified number of requests (default 1) returns an ExecutableNetwork
|
||||
# instance which stores infer requests. So you already created Infer requests in the previous step.
|
||||
|
||||
# ---------------------------Step 6. Prepare input---------------------------------------------------------------------
|
||||
original_images = []
|
||||
|
||||
n, c, h, w = net.input_info[input_blob].input_data.shape
|
||||
input_data = np.ndarray(shape=(n, c, h, w))
|
||||
|
||||
for i in range(n):
|
||||
image = cv2.imread(args.input[i])
|
||||
original_images.append(image)
|
||||
|
||||
if image.shape[:-1] != (h, w):
|
||||
log.warning(f'Image {args.input[i]} is resized from {image.shape[:-1]} to {(h, w)}')
|
||||
image = cv2.resize(image, (w, h))
|
||||
|
||||
# Change data layout from HWC to CHW
|
||||
image = image.transpose((2, 0, 1))
|
||||
|
||||
input_data[i] = image
|
||||
|
||||
# ---------------------------Step 7. Do inference----------------------------------------------------------------------
|
||||
log.info('Starting inference in synchronous mode')
|
||||
res = exec_net.infer(inputs={input_blob: input_data})
|
||||
|
||||
# ---------------------------Step 8. Process output--------------------------------------------------------------------
|
||||
res = res[out_blob]
|
||||
|
||||
for i in range(n):
|
||||
output_image = res[i]
|
||||
# Change data layout from CHW to HWC
|
||||
output_image = output_image.transpose((1, 2, 0))
|
||||
# Convert BGR color order to RGB
|
||||
output_image = cv2.cvtColor(output_image, cv2.COLOR_BGR2RGB)
|
||||
|
||||
# Apply mean argument values
|
||||
output_image = output_image[::] - (args.mean_val_r, args.mean_val_g, args.mean_val_b)
|
||||
# Set pixel values bitween 0 and 255
|
||||
output_image = np.clip(output_image, 0, 255)
|
||||
|
||||
# Resize a output image to original size
|
||||
if args.original_size:
|
||||
h, w, _ = original_images[i].shape
|
||||
output_image = cv2.resize(output_image, (w, h))
|
||||
|
||||
cv2.imwrite(f'out_{i}.bmp', output_image)
|
||||
if os.path.exists(f'out_{i}.bmp'):
|
||||
log.info(f'Image out_{i}.bmp created!')
|
||||
else:
|
||||
log.error(f'Image out_{i}.bmp was not created. Check your permissions.')
|
||||
|
||||
# ----------------------------------------------------------------------------------------------------------------------
|
||||
log.info('This sample is an API example, for any performance measurements please use the dedicated benchmark_app tool\n')
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
@ -22,8 +22,8 @@ target_compile_definitions(${TARGET_NAME}
|
||||
DATA_PATH=\"${DATA_PATH}\"
|
||||
MODELS_PATH=\"${MODELS_PATH}\" )
|
||||
|
||||
if(ENABLE_MULTI)
|
||||
add_dependencies(${TARGET_NAME} MultiDevicePlugin)
|
||||
if(ENABLE_AUTO OR ENABLE_MULTI)
|
||||
add_dependencies(${TARGET_NAME} ov_auto_plugin)
|
||||
endif()
|
||||
|
||||
if(ENABLE_BATCH)
|
||||
|
@ -80,7 +80,70 @@ void regclass_graph_Node(py::module m) {
|
||||
}
|
||||
return "<" + type_name + ": '" + self.get_friendly_name() + "' (" + shapes_ss.str() + ")>";
|
||||
});
|
||||
node.def(
|
||||
"evaluate",
|
||||
[](const ov::Node& self,
|
||||
ov::runtime::TensorVector& output_values,
|
||||
const ov::runtime::TensorVector& input_values,
|
||||
const ov::EvaluationContext& evaluationContext) -> bool {
|
||||
return self.evaluate(output_values, input_values, evaluationContext);
|
||||
},
|
||||
py::arg("output_values"),
|
||||
py::arg("input_values"),
|
||||
py::arg("evaluationContext"),
|
||||
R"(
|
||||
Evaluate the node on inputs, putting results in outputs
|
||||
Parameters
|
||||
----------
|
||||
output_tensors : List[op.Tensor]
|
||||
Tensors for the outputs to compute. One for each result.
|
||||
input_tensors : List[op.Tensor]
|
||||
Tensors for the inputs. One for each inputs.
|
||||
evaluation_context: PyRTMap
|
||||
Storage of additional settings and attributes that can be used
|
||||
when evaluating the function. This additional information can be shared across nodes.
|
||||
Returns
|
||||
----------
|
||||
evaluate : bool
|
||||
)");
|
||||
node.def(
|
||||
"evaluate",
|
||||
[](const ov::Node& self,
|
||||
ov::runtime::TensorVector& output_values,
|
||||
const ov::runtime::TensorVector& input_values) -> bool {
|
||||
return self.evaluate(output_values, input_values);
|
||||
},
|
||||
py::arg("output_values"),
|
||||
py::arg("input_values"),
|
||||
R"(
|
||||
Evaluate the function on inputs, putting results in outputs
|
||||
Parameters
|
||||
----------
|
||||
output_tensors : List[op.Tensor]
|
||||
Tensors for the outputs to compute. One for each result.
|
||||
input_tensors : List[op.Tensor]
|
||||
Tensors for the inputs. One for each inputs.
|
||||
Returns
|
||||
----------
|
||||
evaluate : bool
|
||||
)");
|
||||
node.def("get_input_tensor",
|
||||
&ov::Node::get_input_tensor,
|
||||
py::arg("i"),
|
||||
py::return_value_policy::reference_internal,
|
||||
R"(
|
||||
Returns the tensor for the node's input with index i
|
||||
|
||||
Parameters
|
||||
----------
|
||||
i : int
|
||||
Index of Input.
|
||||
|
||||
Returns
|
||||
----------
|
||||
input_tensor : descriptor.Tensor
|
||||
Tensor of the input i
|
||||
)");
|
||||
node.def("get_element_type",
|
||||
&ov::Node::get_element_type,
|
||||
R"(
|
||||
@ -91,6 +154,42 @@ void regclass_graph_Node(py::module m) {
|
||||
get_element_type : Type
|
||||
Type of the output.
|
||||
)");
|
||||
node.def("input_values",
|
||||
&ov::Node::input_values,
|
||||
R"(
|
||||
Returns list of node's inputs, in order.
|
||||
|
||||
Returns
|
||||
----------
|
||||
inputs : List[Input]
|
||||
List of node's inputs
|
||||
)");
|
||||
node.def("input_value",
|
||||
&ov::Node::input_value,
|
||||
py::arg("i"),
|
||||
R"(
|
||||
Returns input of the node with index i
|
||||
|
||||
Parameters
|
||||
----------
|
||||
i : int
|
||||
Index of Input.
|
||||
|
||||
Returns
|
||||
----------
|
||||
input : Input
|
||||
Input of this node.
|
||||
)");
|
||||
node.def("get_input_size",
|
||||
&ov::Node::get_input_size,
|
||||
R"(
|
||||
Returns the number of inputs to the node.
|
||||
|
||||
Returns
|
||||
----------
|
||||
input_size : int
|
||||
Number of inputs.
|
||||
)");
|
||||
node.def("get_output_size",
|
||||
&ov::Node::get_output_size,
|
||||
R"(
|
||||
@ -98,7 +197,7 @@ void regclass_graph_Node(py::module m) {
|
||||
|
||||
Returns
|
||||
----------
|
||||
get_element_type : int
|
||||
output_size : int
|
||||
Number of outputs.
|
||||
)");
|
||||
node.def("get_output_element_type",
|
||||
|
@ -7,27 +7,59 @@
|
||||
#include <pybind11/pybind11.h>
|
||||
#include <pybind11/stl.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "openvino/pass/constant_folding.hpp"
|
||||
#include "openvino/pass/pass.hpp"
|
||||
#include "openvino/pass/serialize.hpp"
|
||||
#include "openvino/pass/validate.hpp"
|
||||
#include "pyopenvino/graph/passes/manager.hpp"
|
||||
|
||||
namespace py = pybind11;
|
||||
|
||||
using Version = ov::pass::Serialize::Version;
|
||||
using FilePaths = std::pair<const std::string, const std::string>;
|
||||
|
||||
inline Version convert_to_version(const std::string& version) {
|
||||
if (version == "UNSPECIFIED")
|
||||
return Version::UNSPECIFIED;
|
||||
if (version == "IR_V10")
|
||||
return Version::IR_V10;
|
||||
if (version == "IR_V11")
|
||||
return Version::IR_V11;
|
||||
throw ov::Exception("Invoked with wrong version argument: '" + version +
|
||||
"'! The supported versions are: 'UNSPECIFIED'(default), 'IR_V10', 'IR_V11'.");
|
||||
}
|
||||
|
||||
namespace {
|
||||
class ManagerWrapper : public ov::pass::Manager {
|
||||
public:
|
||||
ManagerWrapper() {}
|
||||
~ManagerWrapper() {}
|
||||
void register_pass(std::string pass_name) {
|
||||
|
||||
void register_pass(const std::string& pass_name) {
|
||||
if (pass_name == "ConstantFolding")
|
||||
push_pass<ov::pass::ConstantFolding>();
|
||||
|
||||
if (m_per_pass_validation) {
|
||||
if (m_per_pass_validation)
|
||||
push_pass<ov::pass::Validate>();
|
||||
return;
|
||||
}
|
||||
|
||||
void register_pass(const std::string& pass_name, const FilePaths& file_paths, const std::string& version) {
|
||||
if (pass_name == "Serialize") {
|
||||
push_pass<ov::pass::Serialize>(file_paths.first, file_paths.second, convert_to_version(version));
|
||||
}
|
||||
return;
|
||||
}
|
||||
void register_pass(const std::string& pass_name,
|
||||
const std::string& xml_path,
|
||||
const std::string& bin_path,
|
||||
const std::string& version) {
|
||||
if (pass_name == "Serialize")
|
||||
push_pass<ov::pass::Serialize>(xml_path, bin_path, convert_to_version(version));
|
||||
return;
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
|
||||
@ -39,5 +71,77 @@ void regclass_graph_passes_Manager(py::module m) {
|
||||
|
||||
manager.def("set_per_pass_validation", &ManagerWrapper::set_per_pass_validation);
|
||||
manager.def("run_passes", &ManagerWrapper::run_passes);
|
||||
manager.def("register_pass", (void (ManagerWrapper::*)(std::string)) & ManagerWrapper::register_pass);
|
||||
manager.def("register_pass",
|
||||
(void (ManagerWrapper::*)(const std::string&)) & ManagerWrapper::register_pass,
|
||||
py::arg("pass_name"),
|
||||
R"(
|
||||
Set the type of register pass for pass manager.
|
||||
Parameters
|
||||
----------
|
||||
pass_name : str
|
||||
string to set the type of a pass
|
||||
// )");
|
||||
|
||||
manager.def("register_pass",
|
||||
(void (ManagerWrapper::*)(const std::string&, const FilePaths&, const std::string&)) &
|
||||
ManagerWrapper::register_pass,
|
||||
py::arg("pass_name"),
|
||||
py::arg("output_files"),
|
||||
py::arg("version") = "UNSPECIFIED",
|
||||
R"(
|
||||
Set the type of register pass for pass manager.
|
||||
Parameters
|
||||
----------
|
||||
pass_name : str
|
||||
string to set the type of a pass
|
||||
output_files : Tuple[str, str]
|
||||
tuple which contains paths where .xml and .bin files will be saved
|
||||
version : str
|
||||
sets the version of the IR which will be generated.
|
||||
Supported versions are:
|
||||
- "UNSPECIFIED" (default) : Use the latest or function version
|
||||
- "IR_V10" : v10 IR
|
||||
- "IR_V11" : v11 IR
|
||||
Examples
|
||||
----------
|
||||
1. Default Version
|
||||
pass_manager = Manager()
|
||||
pass_manager.register_pass("Serialize", output_files=("example.xml", "example.bin"))
|
||||
2. IR version 11
|
||||
pass_manager = Manager()
|
||||
pass_manager.register_pass("Serialize", output_files=("example.xml", "example.bin"), version="IR_V11")
|
||||
// )");
|
||||
manager.def(
|
||||
"register_pass",
|
||||
(void (ManagerWrapper::*)(const std::string&, const std::string&, const std::string&, const std::string&)) &
|
||||
ManagerWrapper::register_pass,
|
||||
py::arg("pass_name"),
|
||||
py::arg("xml_path"),
|
||||
py::arg("bin_path"),
|
||||
py::arg("version") = "UNSPECIFIED",
|
||||
R"(
|
||||
Set the type of register pass for pass manager.
|
||||
Parameters
|
||||
----------
|
||||
pass_name : str
|
||||
string to set the type of a pass
|
||||
xml_path : str
|
||||
path where .xml file will be saved
|
||||
bin_path : str
|
||||
path where .bin file will be saved
|
||||
version : str
|
||||
sets the version of the IR which will be generated.
|
||||
Supported versions are:
|
||||
- "UNSPECIFIED" (default) : Use the latest or function version
|
||||
- "IR_V10" : v10 IR
|
||||
- "IR_V11" : v11 IR
|
||||
Examples
|
||||
----------
|
||||
1. Default Version
|
||||
pass_manager = Manager()
|
||||
pass_manager.register_pass("Serialize", xml_path="example.xml", bin_path="example.bin")
|
||||
2. IR version 11
|
||||
pass_manager = Manager()
|
||||
pass_manager.register_pass("Serialize", xml_path="example.xml", bin_path="example.bin", version="IR_V11")
|
||||
// )");
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user