OpenVINO using Inference Engine Python API in PC environment

Overview

There is a tutorial on Python API code in OpenVINO using Raspberry Pi and Neural Compute Stick on the here site, but if you want to do it in a PC-only environment, I need to make some changes and additions, so I will write a note of it. image.png Image source: Deep learning inference learned from scratch with OpenVINO ™

The following three items are required

-Change target device -Changed FP16 to FP32 -Add library load

Change target device

Just change from MYRAID, which means Neural Compute Stick, to CPU. This is easy.

#Change before
plugin = IEPlugin(device="MYRIAD")
#After change
plugin = IEPlugin(device="CPU")

Change FP16 to FP32

Change the trained model (xml and bin files) from FP16 to FP32 For example, face-detection-retail-0004 for OpenVINO 2019_R3.1 can be downloaded from FP32 on the following site. Intel Open Source Technology Center

By the way, it may work with FP16 as it is, but FP32 is recommended, so it is better to change it. image.png Image source: Intel OpenVINO ™ TOOLKIT official website

Add library load

Depending on the trained model you use, you may get the following errors (such as face recognition):

Traceback (most recent call last):
  File "XXXXXXXX.py", line XXX, in <module>
    exec_net = plugin.load(network=net)
  File "ie_api.pyx", line 547, in openvino.inference_engine.ie_api.IEPlugin.load
  File "ie_api.pyx", line 557, in openvino.inference_engine.ie_api.IEPlugin.load
RuntimeError: Unsupported primitive of type: PriorBoxClustered name: fc7_mbox_priorbox

As a response, it is necessary to add CPU Extensions library reading. The path and file name differ depending on the OS and CPU, so please try various things.

Example of Windows 10 (Intel Core processor)

#Add under target device specification
plugin.add_cpu_extension("C:/Program Files (x86)/IntelSWTools/openvino/deployment_tools/inference_engine/bin/intel64/Release/cpu_extension_avx2.dll")

Linux (Intel Atom Processor) Example

#Add under target device specification
plugin.add_cpu_extension('/opt/intel/openvino/deployment_tools/inference_engine/lib/intel64/libcpu_extension_sse4.so')

Mac example

#Add under target device specification
plugin.add_cpu_extension('/opt/intel/openvino/deployment_tools/inference_engine/lib/intel64/libcpu_extension.dylib')

With this, if you have a PC, you can make deep learning inference for free! see you.

Recommended Posts

OpenVINO using Inference Engine Python API in PC environment
Mouse operation using Windows API in Python
Try using the Wunderlist API in Python
Try using the Kraken API in Python
Using venv in Windows + Docker environment [Python]
Tweet using the Twitter API in Python
Get Youtube data in Python using Youtube Data API
Get image URL using Flickr API in Python
Let's judge emotions using Emotion API in Python
[Environment construction] Dependency analysis using CaboCha in Python 2.7
Try using ChatWork API and Qiita API in Python
Try using the DropBox Core API in Python
Evernote API in Python
virtual environment in python
C API in Python 3
Development environment in Python
Upload JPG file using Google Drive API in Python
Initial settings when using the foursquare API in python
Get LEAD data using Marketo's REST API in Python
Using the National Diet Library Search API in Python
Hit Mastodon's API in Python
Handle environment variables in Python
Blender Python API in Houdini (Python 3)
Translate using googletrans in Python
Using Python mode in Processing
[SAP CP] Web API created with python in CF environment
Predict gender from name using Gender API and Pykakasi in Python
[CLPEX memo] Run DO Python API in COS installed environment
GUI programming in Python using Appjar
Precautions when using pit in Python
Data acquisition using python googlemap api
Hit the Sesami API in Python
[Python3] Google translate google translate without using api
Install scrapy in python anaconda environment
Try using Pleasant's API (python / FastAPI)
Try using LevelDB in Python (plyvel)
Create Gmail in Python without API
install tensorflow in anaconda + python3.5 environment
Using global variables in python functions
Build and try an OpenCV & Python environment in minutes using Docker
Hit the web API in Python
Try to log in to Netflix automatically using python on your PC
Let's see using input in python
Infinite product in Python (using functools)
Edit videos in Python using MoviePy
Try using Python argparse's action API
Quickly implement REST API in Python
Regularly upload files to Google Drive using the Google Drive API in Python
Build a Python execution environment using GPU with GCP Compute engine
Run Ansible from Python using API
Handwriting recognition using KNN in Python
Access the Twitter API in Python
Try using Leap Motion in Python
Depth-first search using stack in Python
[SEO] Flow / sample code when using Google Analytics API in Python
When using regular expressions in Python
Python3.6 environment construction (using Win environment Anaconda)
GUI creation in python using tkinter 2
Development and deployment of REST API in Python using Falcon Web Framework
Detect Japanese characters from images using Google's Cloud Vision API in Python
Notify using Notification Center when the execution environment is macOS in Python