|
| 1 | +--- |
| 2 | +sidebar_position: 4 |
| 3 | +--- |
| 4 | + |
| 5 | +# Accelerating the MediaPipe models with Hailo NPU |
| 6 | + |
| 7 | +## Overview |
| 8 | + |
| 9 | +[MediaPipe](https://github.com/google-ai-edge/mediapipe) is an open-source framework created by Google for constructing machine learning pipelines that handle time-series data, including video and audio. It provides customizable solutions for a wide range of applications, particularly in computer vision and on-device machine learning tasks. |
| 10 | + |
| 11 | +This article outlines the process of deploying a MediaPipe model on an AI Box to enhance hand detection, gesture landmarks, and face landmarks. |
| 12 | + |
| 13 | +## Prepare Hardware |
| 14 | + |
| 15 | +> **Note:** |
| 16 | +> Please connect a USB camera to the AI Box. |
| 17 | +
|
| 18 | +<div class="table-center"> |
| 19 | + <table align="center"> |
| 20 | + <tr> |
| 21 | + <th>reComputer AI R2130</th> |
| 22 | + </tr> |
| 23 | + <tr> |
| 24 | + <td><div style={{textAlign:'center'}}><img src="https://media-cdn.seeedstudio.com/media/catalog/product/cache/bb49d3ec4ee05b6f018e93f896b8a25d/1/_/1_24_1.jpg" style={{width:600, height:'auto'}}/></div></td> |
| 25 | + </tr> |
| 26 | + <tr> |
| 27 | + <td><div class="get_one_now_container" style={{textAlign: 'center'}}> |
| 28 | + <a class="get_one_now_item" href="https://www.seeedstudio.com/reComputer-AI-R2130-12-p-6368.html"> |
| 29 | + <strong><span><font color={'FFFFFF'} size={"4"}> Get One Now 🖱️</font></span></strong> |
| 30 | + </a> |
| 31 | + </div></td> |
| 32 | + </tr> |
| 33 | + </table> |
| 34 | +</div> |
| 35 | + |
| 36 | + |
| 37 | +## Install Hailo Software & Verify Installation |
| 38 | + |
| 39 | +### update the system: |
| 40 | + |
| 41 | +``` |
| 42 | +sudo apt update |
| 43 | +sudo apt full-upgrade |
| 44 | +``` |
| 45 | + |
| 46 | +:::note |
| 47 | +Sometimes you may encounter the following issues during updates. |
| 48 | +``` |
| 49 | +Get:1 http://deb.debian.org/debian bookworm InRelease [151 kB] |
| 50 | +Get:2 http://deb.debian.org/debian-security bookworm-security InRelease [48.0 kB] |
| 51 | +Get:3 http://deb.debian.org/debian bookworm-updates InRelease [55.4 kB] |
| 52 | +Get:4 http://archive.raspberrypi.com/debian bookworm InRelease [39.0 kB] |
| 53 | +Reading package lists... Done |
| 54 | +E: Release file for http://deb.debian.org/debian/dists/bookworm/InRelease is not valid yet (invalid for another 58d 8h 26min 35s). Updates for this repository will not be applied. |
| 55 | +E: Release file for http://deb.debian.org/debian-security/dists/bookworm-security/InRelease is not valid yet (invalid for another 84d 18h 23min 59s). Updates for this repository will not be applied. |
| 56 | +E: Release file for http://archive.raspberrypi.com/debian/dists/bookworm/InRelease is not valid yet (invalid for another 84d 13h 13min 5s). Updates for this repository will not be applied. |
| 57 | +E: Release file for http://deb.debian.org/debian/dists/bookworm-updates/InRelease is not valid yet (invalid for another 85d 0h 52min 29s). Updates for this repository will not be applied. |
| 58 | +``` |
| 59 | +This is because the time on the Raspberry Pi is set incorrectly, and you need to manually set the time on the Raspberry Pi with command below: |
| 60 | +``` |
| 61 | +# This command only you can connect google.com |
| 62 | +sudo date -s "$(wget -qSO- --max-redirect=0 google.com 2>&1 | grep Date: | cut -d' ' -f5-8)Z" |
| 63 | +``` |
| 64 | +After set your raspberry time, you can update your raspberry. |
| 65 | +::: |
| 66 | + |
| 67 | +### Set pcie to gen2/gen3(gen3 is faster than gen2): |
| 68 | + |
| 69 | +Add following text to ```/boot/firmware/config.txt``` |
| 70 | + |
| 71 | +``` |
| 72 | +#Enable the PCIe external connector |
| 73 | +
|
| 74 | +dtparam=pciex1 |
| 75 | +
|
| 76 | +#Force Gen 3.0 speeds |
| 77 | +
|
| 78 | +dtparam=pciex1_gen=3 |
| 79 | +
|
| 80 | +``` |
| 81 | +:::note |
| 82 | +If you want to use gen2, please comment dtparam=pciex1_gen=3 |
| 83 | +::: |
| 84 | + |
| 85 | +### Install hailo-all and reboot: |
| 86 | + |
| 87 | +Open terminal on the AI Box, and input command as follows to install Hailo software. |
| 88 | + |
| 89 | +``` |
| 90 | +sudo apt install hailo-all |
| 91 | +sudo apt-get -y install libblas-dev nlohmann-json3-dev |
| 92 | +sudo reboot |
| 93 | +``` |
| 94 | +### Check Software and Hardware: |
| 95 | + |
| 96 | +Open terminal on the AI Box, and input command as follows to check if hailo-all have been installed. |
| 97 | + |
| 98 | +``` |
| 99 | +hailortcli fw-control identify |
| 100 | +``` |
| 101 | + |
| 102 | +The right result show as bellow: |
| 103 | +<p style={{textAlign: 'center'}}><img src="https://files.seeedstudio.com/wiki/reComputer-R1000/YOLOV8/check_software.png" alt="pir" width={1000} height="auto"/></p> |
| 104 | + |
| 105 | +Open terminal on the AI Box, and input command as follows to check if hailo-8L have been connected. |
| 106 | + |
| 107 | +``` |
| 108 | +lspci | grep Hailo |
| 109 | +``` |
| 110 | + |
| 111 | +The right result show as bellow: |
| 112 | +<p style={{textAlign: 'center'}}><img src="https://files.seeedstudio.com/wiki/reComputer-R1000/YOLOV8/check_hardware.png" alt="pir" width={1000} height="auto"/></p> |
| 113 | + |
| 114 | +## Run Project |
| 115 | + |
| 116 | +### Install Project |
| 117 | + |
| 118 | +``` |
| 119 | +git clone https://github.com/AlbertaBeef/blaze_app_python |
| 120 | +``` |
| 121 | + |
| 122 | +### Install the hailo model |
| 123 | + |
| 124 | +Input the command below you will see a clip demo: |
| 125 | +``` |
| 126 | +cd blaze_app_python |
| 127 | +
|
| 128 | +sudo chmod 755 ./blaze_hailo/models/get_hailo8_models.sh |
| 129 | +
|
| 130 | +./blaze_hailo/models/get_hailo8_models.sh |
| 131 | +
|
| 132 | +unzip ./blaze_hailo/models/blaze_hailo8_models.zip |
| 133 | +
|
| 134 | +mv ./blaze_hailo/models/hailo8/* ./blaze_hailo/models/ |
| 135 | +``` |
| 136 | + |
| 137 | +### Install necessary lib |
| 138 | + |
| 139 | +``` |
| 140 | +python -m venv .env && source .env/bin/activate |
| 141 | +pip install numpy opencv-python plotly |
| 142 | +``` |
| 143 | + |
| 144 | +### Run the project |
| 145 | + |
| 146 | +``` |
| 147 | +cd ./blaze_hailo |
| 148 | +python blaze_detect_live.py --blaze hand -f |
| 149 | +``` |
| 150 | + |
| 151 | +## Result |
| 152 | + |
| 153 | +Coming soon... |
0 commit comments