A memorandum on how to get openvino to work well on macOS Catalina when pyenv is also using pipenv. This is a sequel to "Running OpenVino on macOS Catalina". If you are not using a virtual environment or are good at building an environment, please refer to that. This is a brush-up of the content for beginners who are using the above environment.
macOS Catalina(10.15.4) OpenVino(2020.2.117) Python 3.7.5 cmake 3.17.1
If you install OpenVino and run it according to the tutorial, you will pass the path to opencv made by the user or use pip without permission, so it makes no sense to use pyenv or pipenv accidentally. Look at the sauce first, not as it was said. It's a little annoying, but if you don't write the $ source /opt/intel/openvino/bin/setupvars.sh mystery in .bash_profile etc. and execute it every time you start the terminal, it may conflict with other development environments. It will be lower.
Download and unzip the dmg for macOS from here Run. It is usually installed as the root user. When you're done, you'll be taken to a web page, but don't run the tutorial demo yet here!
Create a project directory and set pyenv and pipenv. The recommended version of python for OpenVino is 3.7.5, so install 3.7.5 for pyenv.
$ pyenv install 3.7.5
$ mkdir ~/Documents/openvino-projects
$ cd ~/Documents/openvino-projects
$ source /opt/intel/openvino/bin/setupvars.sh
[setupvars.sh] OpenVINO environment initialized
We've put together a tutorial demo and some libraries used in other demos. Place the following content in the project directory (here ~ / Documents / openvino-projects) with the name Pipfile.
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
[packages]
tensorflow = "<2.0.0,>=1.2.0"
mxnet = ">=1.0.0,<=1.5.1"
networkx = ">=1.11"
numpy = ">=1.12.0"
protobuf = "==3.6.1"
onnx = ">=1.1.2"
defusedxml = ">=0.5.0"
pyyaml = "*"
requests = "*"
scipy = "*"
[requires]
python_version = "3.7"
Build a virtual environment and enter the shell.
$ cd ~/Documents/openvino-projects
$ pyenv local 3.7.5
$ pipenv --python 3.7.5
........Abbreviation
$ pipenv install
#Locking here..If it doesn't end forever, it's unavoidable (although I can't recommend it very much), so after forcibly terminating,
pipenv install --skip-Let's lock.
........Abbreviation
$ pipenv shell
The tutorial demo on the web page that appears after installation just runs a script that downloads, transforms, and even runs the model, but that does some extra work, so I'll fix it a bit.
$ cd /opt/intel/openvino/deployment_tools/demo/
$ sudo cp ./demo_squeezenet_download_convert_run.sh ./demo_squeezenet_download_convert_run2.sh
Comment out lines 146-150 of demo_squeezenet_download_convert_run2.sh and save (requires root privileges).
demo_squeezenet_download_convert_run2.sh
#if [[ "$OSTYPE" == "darwin"* ]]; then
# $pip_binary install -r $ROOT_DIR/../open_model_zoo/tools/downloader/requirements.in
#else
# sudo -E $pip_binary install -r $ROOT_DIR/../open_model_zoo/tools/downloader/requirements.in
#fi
Run.
$ ./demo_squeezenet_download_convert_run2.sh
........Abbreviation
$ ./demo_security_barrier_camera.sh
........Abbreviation
If there is no error and the result is something like WEB page
Save the following content in your project directory as update_rpath.sh.
update_rpath.sh
install_name_tool -add_rpath '/opt/intel/openvino/opencv/lib' /opt/intel/openvino_2020.2.117/python/python3/cv2.so
install_name_tool -add_rpath '/opt/intel/openvino/inference_engine/lib/intel64' /opt/intel/openvino_2020.2.117/python/python3/cv2.so
install_name_tool -add_rpath '/opt/intel/openvino/deployment_tools/ngraph/lib' /opt/intel/openvino_2020.2.117/python/python3/cv2.so
install_name_tool -add_rpath '/opt/intel/openvino/inference_engine/external/tbb/lib' /opt/intel/openvino/deployment_tools/inference_engine/lib/intel64/libinference_engine_legacy.dylib
install_name_tool -add_rpath '/opt/intel/openvino/inference_engine/lib/intel64' /opt/intel/openvino/deployment_tools/inference_engine/lib/intel64/libMKLDNNPlugin.dylib
install_name_tool -add_rpath '/opt/intel/openvino/inference_engine/lib/intel64' /opt/intel/openvino/python/python3.7/openvino/inference_engine/ie_api.so
install_name_tool -add_rpath '/opt/intel/openvino/inference_engine/external/tbb/lib' /opt/intel/openvino/python/python3.7/openvino/inference_engine/ie_api.so
install_name_tool -add_rpath '/opt/intel/openvino/deployment_tools/ngraph/lib' /opt/intel/openvino/deployment_tools/inference_engine/lib/intel64/libinference_engine.dylib
install_name_tool -add_rpath '/opt/intel/openvino/deployment_tools/ngraph/lib' /opt/intel/openvino/deployment_tools/inference_engine/lib/intel64/libinference_engine_legacy.dylib
Run the above file (see previous post (https://qiita.com/y-fuku/items/ed70fac7f65ef73f80f6) for more information on why this is done).
$ cd ~/Documents/openvino-projects
$ chmod 755 ./update_rpath.sh
$ sudo ./update_rpath.sh
Copy the directory containing the demo files to your project directory.
$ cp -r /opt/intel/openvino/deployment_tools/open_model_zoo/demos .
cmake with the python module option.
$ cd demos
$ cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_PYTHON=ON .
......Abbreviation
However, it will not compile as it is, so edit CmakeCache.txt (line 34).
CMakeCache.txt
...... Omitted ...
//Flags used by the CXX compiler during all build types.
CMAKE_CXX_FLAGS:STRING=-Wno-inconsistent-missing-override
...... Omitted ...
make
$ make -j2
...... Omitted ...
The executable file is built under intel64 / Release. Let's run crossroad_camera_demo. First, take a look at the Explanation page for each sample.
crossroad_camera_demo is the page here. Let's read it carefully for the time being. First of all, you need to download the necessary model files. Download the required model as follows.
$ cd ~/Documents/openvino-projects
$ /opt/intel/openvino/deployment_tools/open_model_zoo/tools/downloader/downloader.py --name person-vehicle-bike-detection-crossroad-0078
...... Omitted ...
$ /opt/intel/openvino/deployment_tools/open_model_zoo/tools/downloader/downloader.py --name person-attributes-recognition-crossroad-0230
...... Omitted ...
$ /opt/intel/openvino/deployment_tools/open_model_zoo/tools/downloader/downloader.py --name person-reidentification-retail-0031
...... Omitted ...
The model will be downloaded under openvino-projects / intel /. crossroad_camera_demo can use a video file or camera as input, but a PC camera is not suitable for taking pictures of passersby, so use a suitable video file. Useful resources for the demo are here.
Let's use people-detection.mp4 here.
$ mkdir sample-videos
# people-detection.Download mp4 and sample-Put it in the videos folder.
$ ./demos/intel64/Release/crossroad_camera_demo \
-i ./sample-videos/people-detection.mp4 \
-m ./intel/person-vehicle-bike-detection-crossroad-0078/FP16/person-vehicle-bike-detection-crossroad-0078.xml \
-m_pa ./intel/person-attributes-recognition-crossroad-0230/FP16/person-attributes-recognition-crossroad-0230.xml \
-m_reid ./intel/person-reidentification-retail-0031/FP16/person-reidentification-retail-0031.xml \
-d CPU -d_pa CPU -d_reid CPU
In this demo, we will use separate models to detect people, estimate attribute information, and perform tracking.
A demo for python can be found under demos / python_demos /. Let's run a demo of Face Recognition. Click here for the Face Recognition explanation page. Similarly, download and run the required model file. This time I will use a PC camera. In this demo, you can use the simple face recognition function with the --run_detector option. Take a photo of the target face.
$ cd ~/Documents/openvino-projects
$ mkdir face-data
#Take a picture of yourself, myname.jpg, etc., face-Put it in data.
#Download model (execute directly under the project directory)
$ /opt/intel/openvino/deployment_tools/open_model_zoo/tools/downloader/downloader.py --name face-detection-retail-0004
$ /opt/intel/openvino/deployment_tools/open_model_zoo/tools/downloader/downloader.py --name landmarks-regression-retail-0009
$ /opt/intel/openvino/deployment_tools/open_model_zoo/tools/downloader/downloader.py --name face-reidentification-retail-0095
#Run demo
$ python3 demos/python_demos/face_recognition_demo/face_recognition_demo.py \
-m_fd ./intel/face-detection-retail-0004/FP16/face-detection-retail-0004.xml \
-m_lm ./intel/landmarks-regression-retail-0009/FP16/landmarks-regression-retail-0009.xml \
-m_reid ./intel/face-reidentification-retail-0095/FP16/face-reidentification-retail-0095.xml \
--verbose --run_detector -fg ./face-data
When you start it, you will be asked to enter your name in the face photo taken on another screen. Enter a name of your choice. Next, another image (what was originally included?) Will be displayed, so answer this as appropriate.
The camera will start and recognize your image.
Recommended Posts