Skip to content

Commit f0737da

Browse files
committed
add:Using_Hailo8_to_accelerate_facial_recognition & update:Accelerating_the_MediaPipe_models_with_Hailo_NPU
1 parent 24da8cb commit f0737da

2 files changed

Lines changed: 175 additions & 4 deletions

File tree

articles/Chapter_3-Computer_Vision_Projects_and_Practical_Applications/Accelerating_the_MediaPipe_models_with_Hailo_NPU.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ After set your raspberry time, you can update your raspberry.
6868

6969
Add following text to ```/boot/firmware/config.txt```
7070

71-
```
72-
#Enable the PCIe external connector
71+
```bash
72+
# Enable the PCIe external connector
7373

7474
dtparam=pciex1
7575

76-
#Force Gen 3.0 speeds
76+
# Force Gen 3.0 speeds
7777

7878
dtparam=pciex1_gen=3
7979

@@ -121,7 +121,8 @@ git clone https://github.com/AlbertaBeef/blaze_app_python
121121

122122
### Install the hailo model
123123

124-
Input the command below you will see a clip demo:
124+
Input the command below you will download the model:
125+
125126
```
126127
cd blaze_app_python
127128
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
---
2+
sidebar_position: 7
3+
---
4+
5+
# Using Hailo8 to accelerate facial recognition
6+
7+
## Overview
8+
9+
This wiki will guide you through using a reComputer equipped with a `Hailo` NPU to implement real-time facial recognition. In this project, we use `SCRFD-10G` for efficient face detection, capable of quickly and accurately detecting faces of various scales, including small faces, ensuring real-time performance. At the same time, we employ the `ArcFace-MobileFaceNet` model for lightweight face recognition, which leverages the ArcFace loss function to enhance recognition accuracy and enable efficient identity verification.
10+
11+
## Prepare Hardware
12+
13+
<div class="table-center">
14+
<table align="center">
15+
<tr>
16+
<th>reComputer AI Industrial R2000</th>
17+
<th>reComputer AI R2000</th>
18+
</tr>
19+
<tr>
20+
<td><div style={{textAlign:'center'}}><img src="https://media-cdn.seeedstudio.com/media/catalog/product/cache/bb49d3ec4ee05b6f018e93f896b8a25d/2/-/2-114993595-recomputer-ai-industrial-r2135-12.jpg" style={{width:250, height:'auto'}}/></div></td>
21+
<td><div style={{textAlign:'center'}}><img src="https://media-cdn.seeedstudio.com/media/catalog/product/cache/bb49d3ec4ee05b6f018e93f896b8a25d/1/_/1_24_1.jpg" style={{width:250, height:'auto'}}/></div></td>
22+
</tr>
23+
<tr>
24+
<td><div class="get_one_now_container" style={{textAlign: 'center'}}>
25+
<a class="get_one_now_item" href="https://www.seeedstudio.com/reComputer-AI-Industrial-R2135-12-p-6432.html" target="_blank">
26+
<strong><span><font color={'FFFFFF'} size={"4"}> Get One Now 🖱️</font></span></strong>
27+
</a>
28+
</div></td>
29+
<td><div class="get_one_now_container" style={{textAlign: 'center'}}>
30+
<a class="get_one_now_item" href="https://www.seeedstudio.com/reComputer-AI-R2130-12-p-6368.html" target="_blank">
31+
<strong><span><font color={'FFFFFF'} size={"4"}> Get One Now 🖱️</font></span></strong>
32+
</a>
33+
</div></td>
34+
</tr>
35+
</table>
36+
</div>
37+
38+
39+
<div style={{ color: 'red', fontWeight: 'bold' }}>
40+
Note: You need a USB camera as the input.
41+
</div>
42+
43+
44+
## Install Hailo Software & Verify Installation
45+
46+
### update the system
47+
48+
```bash
49+
sudo apt update
50+
sudo apt full-upgrade
51+
```
52+
53+
:::note
54+
Sometimes you may encounter the following issues during updates.
55+
56+
```
57+
Get:1 http://deb.debian.org/debian bookworm InRelease [151 kB]
58+
Get:2 http://deb.debian.org/debian-security bookworm-security InRelease [48.0 kB]
59+
Get:3 http://deb.debian.org/debian bookworm-updates InRelease [55.4 kB]
60+
Get:4 http://archive.raspberrypi.com/debian bookworm InRelease [39.0 kB]
61+
Reading package lists... Done
62+
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.
63+
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.
64+
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.
65+
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.
66+
```
67+
68+
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:
69+
70+
```
71+
# This command only you can connect google.com
72+
sudo date -s "$(wget -qSO- --max-redirect=0 google.com 2>&1 | grep Date: | cut -d' ' -f5-8)Z"
73+
```
74+
75+
After set your raspberry time, you can update your raspberry.
76+
:::
77+
78+
### Set pcie to gen2/gen3(gen3 is faster than gen2)
79+
80+
Add following text to ```/boot/firmware/config.txt```
81+
82+
```bash
83+
# Enable the PCIe external connector
84+
85+
dtparam=pciex1
86+
87+
# Force Gen 3.0 speeds
88+
89+
dtparam=pciex1_gen=3
90+
91+
```
92+
93+
:::note
94+
If you want to use gen2, please comment dtparam=pciex1_gen=3
95+
:::
96+
97+
### Install hailo-all and reboot
98+
99+
Open terminal on the Raspberry Pi5, and input command as follows to install Hailo software.
100+
101+
```bash
102+
sudo apt install hailo-all
103+
sudo apt-get -y install libblas-dev nlohmann-json3-dev
104+
sudo reboot
105+
```
106+
107+
### Check Software and Hardware
108+
109+
Open terminal on the Raspberry Pi5, and input command as follows to check if hailo-all have been installed.
110+
111+
```bash
112+
hailortcli fw-control identify
113+
```
114+
115+
The right result show as bellow:
116+
<p style={{textAlign: 'center'}}><img src="https://files.seeedstudio.com/wiki/reComputer-R1000/YOLOV8/check_software.png" alt="pir" width={1000} height="auto"/></p>
117+
118+
Open terminal on the Raspberry Pi5, and input command as follows to check if hailo-8L have been connected.
119+
120+
```bash
121+
lspci | grep Hailo
122+
```
123+
124+
The right result show as bellow:
125+
<p style={{textAlign: 'center'}}><img src="https://files.seeedstudio.com/wiki/reComputer-R1000/YOLOV8/check_hardware.png" alt="pir" width={1000} height="auto"/></p>
126+
127+
## Run Project
128+
129+
### Install Project
130+
131+
```bash
132+
cd ~ && git clone https://github.com/Seeed-Projects/hailo-apps-infra
133+
cd hailo-apps-infra
134+
./install.sh
135+
source venv_hailo_apps/bin/activate
136+
```
137+
138+
### Add your photo
139+
140+
```bash
141+
cd /resources/face_recon/train
142+
# change name to the name of the person to be recognized
143+
mkdir name
144+
```
145+
146+
<div style={{ color: 'red', fontWeight: 'bold' }}>
147+
Note: Place the photo of the person to be recognized into the folder that was just created.
148+
</div>
149+
150+
### Add information to the database
151+
152+
```bash
153+
cd ~/hailo-apps-infra/hailo_apps/hailo_app_python/apps/face_recognition
154+
python face_recognition.py --mode train
155+
```
156+
157+
The right result show as bellow:
158+
<p style={{textAlign: 'center'}}><img src="https://files.seeedstudio.com/wiki/00_AI_Sensing/Application/face/face_1.png" alt="pir" width={1000} height="auto"/></p>
159+
160+
### Run the project
161+
162+
Input the command below you will see a face recognition demo:
163+
164+
```bash
165+
python face_recognition.py --input usb
166+
```
167+
168+
## Result
169+
170+
[![Alt text](https://img.youtube.com/vi/wcT_ZYsRbAE/0.jpg)](https://www.youtube.com/watch?v=wcT_ZYsRbAE)

0 commit comments

Comments
 (0)