Intel® Distribution of OpenVINO™ Toolkit
Community assistance about the Intel® Distribution of OpenVINO™ toolkit, OpenCV, and all aspects of computer vision-related on Intel® platforms.
6482 Discussions

My goal is to use my custom Keras neural network with a NCS2 on a RPI4. What do I need to install/do exactly?

Felipe
Beginner
2,950 Views

I am confused and all tutorials I've found online they end up with errors somewhere. I would appreciate some help.

 

Regards.

0 Kudos
4 Replies
JAVIERJOSE_A_Intel
2,703 Views

Hi FHern14,

 

Thank you for reaching out.

 

If you have not installed the OpenVINO™ Toolkit, we recommend you to follow the Raspberry Pi* 4 and Intel® Neural Compute Stick 2 Setup official guide. This guide will set up your Raspberry Pi* 4 with Raspbian OS and the tools needed to use the Intel® Neural Compute Stick 2.

 

About your Keras model, you will need to convert it to frozen TensorFlow then use that frozen model to convert to IR format using the model optimizer. The script attached can help you with that process.

 

For example:

 

 

  1. python3 keras_to_tf.py --input_model <keras_model>

 

The Model Optimizer is not included by default in the RPI pre-built package, and you would need a separate system to be able to use it; to convert the model and then transfer the resulting IR to the RPI.

 

There is also a guide that introduces how to use the Model Optimizer on RPI here. However, this guide also requires an OpenVINO™ toolkit installed on a supported system with GNU* or Linux* distribution.

 

 

Regards,

 

Javier A.   

Intel Customer Support Technician   

A Contingent Worker at Intel  

0 Kudos
Felipe
Beginner
2,703 Views

Hi Javier,

 

I am following this tutorial you provided me: https://software.intel.com/en-us/articles/ARM-sbc-and-NCS2.

 

I got currently stuck on this step:

 

mkdir /media/usb

mount /dev/sdX /media/usb

mkdir ~/OpenVINO

cp /media/archive_openvino.tar.gz ~/OpenVINO 

tar xvzf ~/OpenVINO/archive_openvino.tar.gz

 

My device is recognized using lsusb:

Bus 001 Device 004: ID 03e7:2485 Intel Movidius MyriadX

 

But it is not listed using lsblk nor sudo fdisk -l

 

What should I do now?

 

Regards,

Felipe

 

0 Kudos
JAVIERJOSE_A_Intel
2,703 Views

Hi FHern14,

 

Please go to this link to get the script to convert from Keras to TensorFlow.

 

Regards,

 

Javier A.   

Intel Customer Support Technician   

A Contingent Worker at Intel  

 

0 Kudos
JAVIERJOSE_A_Intel
2,703 Views

Hi FHern14,

 

We tried to install the latest version(2020.1) of OpenVINO™ Toolkit on a Raspberry pi 4 model B following the pre-built package guide, and after some changes, we completed the installation successfully. Please try to install OpenVINO™ Toolkit this way.

 

Even though you are installing the OpenVINO™ Toolkit 2020.1 version, you will need to use the models from the OpenVINO™ Toolkit 2019 R3. This is because of a compatibility issue with the 2020 version models with the latest release of OpenVINO™ Toolkit for Raspbian OS.

 

Please follow the steps on this guide:

 

Install the OpenVINO™ Toolkit for Raspbian* OS Package

 

 

  1. cd ~/Downloads/
  2. sudo mkdir -p /opt/intel/openvino_2020
  3. sudo tar -xf l_openvino_toolkit_runtime_raspbian_p_2020.1.023.tgz --strip 1 -C /opt/intel/openvino_2020

 

Install External Software Dependencies

 

  • CMake* version 3.7.2 or higher is required for building the Inference Engine sample application

 

  1. sudo apt install cmake

 

Set the Environment Variables

 

  • You must update several environment variables before you can compile and run OpenVINO toolkit applications or permanently set the environment variables

 

  1. source /opt/intel/openvino_2020/bin/setupvars.sh
  2. echo "source /opt/intel/openvino_2020/bin/setupvars.sh" >> ~/.bashrc

 

Add USB Rules

 

  • Add the current Linux user to the user's group.

 

  1. sudo usermod -a -G users "$(whoami)"

 

  • Log out and log in for it to take effect.
  • To perform inference on the Intel® Movidius™ Neural Compute Stick or Intel® Neural Compute Stick 2, install the USB rules.

 

  1. source /opt/intel/openvino_2020/bin/setupvars.sh
  2. sh /opt/intel/openvino_2020/install_dependencies/install_NCS_udev_rules.sh

 

  • Plug-in your Intel® Movidius™ Neural Compute Stick or Intel® Neural Compute Stick 2.

 

Build and Run Object Detection Sample

 

  • Navigate to a directory that you have write access to and create a samples build directory. This example uses a directory named build then build the Object Detection Sample

 

  1. mkdir build && cd build && mkdir build_c && cd build_c
  2. cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-march=armv7-a" /opt/intel/openvino_2020/deployment_tools/inference_engine/samples/c
  3. cd .. && mkdir build_cpp && cd build_cpp
  4. cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-march=armv7-a" /opt/intel/openvino_2020/deployment_tools/inference_engine/samples/cpp
  5. make -j2 object_detection_sample_ssd

 

  • Download the pre-trained Face Detection model or copy it from the host machine

 

  1. wget --no-check-certificate https://download.01.org/opencv/2019/open_model_zoo/R3/20190905_163000_models_bin/face-detection-adas-0001/FP16/face-detection-adas-0001.bin
  2. wget --no-check-certificate https://download.01.org/opencv/2019/open_model_zoo/R3/20190905_163000_models_bin/face-detection-adas-0001/FP16/face-detection-adas-0001.xml

 

  • Run the sample by specifying the model and the path to the input image (download or use an image and change by the absolute path <path_to_image>) in the following command.

 

  1. ./armv7l/Release/object_detection_sample_ssd -m face-detection-adas-0001.xml -d MYRIAD -i <path_to_image>

 

Run Inference of Face Detection Model Using OpenCV* API

  •  To validate OpenCV* installation, run the OpenCV deep learning module with the Inference Engine backend. Here is a Python* sample, which works with the pre-trained Face Detection model:

 

  1. wget --no-check-certificate https://download.01.org/opencv/2019/open_model_zoo/R3/20190905_163000_models_bin/face-detection-adas-0001/FP16/face-detection-adas-0001.bin
  2. wget --no-check-certificate https://download.01.org/opencv/2019/open_model_zoo/R3/20190905_163000_models_bin/face-detection-adas-0001/FP16/face-detection-adas-0001.xml

 

  • Create a new Python* file named as openvino_fd_myriad.py and copy the following script there and change the absolute path of your input image in </path/to/image>.

 

  1. import cv2 as cv
  2. # Load the model.
  3. net = cv.dnn_DetectionModel('face-detection-adas-0001.xml',
  4. 'face-detection-adas-0001.bin')
  5. # Specify target device.
  6. net.setPreferableTarget(cv.dnn.DNN_TARGET_MYRIAD)
  7. # Read an image.
  8. frame = cv.imread('/path/to/image')
  9. if frame is None:
  10. raise Exception('Image not found!')
  11. # Perform an inference.
  12. _, confidences, boxes = net.detect(frame, confThreshold=0.5)
  13. # Draw detected faces on the frame.
  14. for confidence, box in zip(list(confidences), boxes):
  15. cv.rectangle(frame, box, color=(0, 255, 0))
  16. # Save the frame to an image file.
  17. cv.imwrite('out.png', frame)

 

  • Run the script

 

  1. python3 openvino_fd_myriad.py

 

 

Regards,

 

Javier A.

Intel Customer Support Technician

A Contingent Worker at Intel

0 Kudos
Reply