Skip to content

Commit 2bfdb89

Browse files
committed
Add Hailo8 model deployment projects
1 parent fe931da commit 2bfdb89

138 files changed

Lines changed: 16512 additions & 3 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,22 @@ toolchain on the host.
3434

3535
### 1. Host prep (one-time, on the Pi)
3636

37+
#### Install Docker
38+
39+
Run the following commands on the development board to install Docker:
40+
41+
```bash
42+
# Download installation script
43+
curl -fsSL https://get.docker.com -o get-docker.sh
44+
# Install using Aliyun mirror source
45+
sudo sh get-docker.sh --mirror Aliyun
46+
# Start Docker and enable auto-start on boot
47+
sudo systemctl enable docker
48+
sudo systemctl start docker
49+
```
50+
51+
#### Install Hailo toolchain
52+
3753
```bash
3854
sudo apt update
3955
sudo apt install hailo-all

README_zh.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,22 @@ Model Zoo 的其它模型(yolov8s/m、yolov5、yolov8-seg 等)。
3131

3232
### 1. 宿主机准备(首次,一次性)
3333

34+
#### 安装 Docker
35+
36+
在开发板上运行以下命令安装 Docker:
37+
38+
```bash
39+
# 下载安装脚本
40+
curl -fsSL https://get.docker.com -o get-docker.sh
41+
# 使用阿里云镜像源安装
42+
sudo sh get-docker.sh --mirror Aliyun
43+
# 启动 Docker 并配置开机自启
44+
sudo systemctl enable docker
45+
sudo systemctl start docker
46+
```
47+
48+
#### 安装 Hailo 工具链
49+
3450
```bash
3551
sudo apt update
3652
sudo apt install hailo-all
@@ -208,6 +224,10 @@ curl -X POST http://<Pi5_IP>:8000/api/config \
208224

209225
## 迁移到其它模型
210226

227+
如果要持续从 Hailo Model Zoo 搬模型,推荐先看这份流程文档:
228+
[docs/HAILO_MODEL_PORTING_zh.md](docs/HAILO_MODEL_PORTING_zh.md)。里面包含
229+
`.hef` 准备、模板选择、脚手架生成模块、Docker 构建和运行命令。
230+
211231
[src/rpi5_hailo8_yolov8/](src/rpi5_hailo8_yolov8/) 当模板:
212232

213233
1. 复制整个目录,重命名(如 `rpi5_hailo8_yolov8_seg/`)。
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Base image for arm64 (Raspberry Pi 5). Build on the Pi directly, or use
2+
# `docker buildx build --platform linux/arm64` from another host.
3+
FROM python:3.11-slim
4+
5+
WORKDIR /app
6+
7+
# OpenCV + Hailo runtime dependencies.
8+
# libgl1: cv2 image codecs
9+
# libglib2.0-0, libsm6, libxext6, libxrender1: common cv2 dependencies
10+
# libgomp1: OpenMP (used by some opencv-python ops)
11+
# ffmpeg: standalone binary used by VideoAnalyzer for libx264 ultrafast
12+
# encoding (~5x faster than cv2's mp4v at 4K on Pi 5).
13+
RUN apt-get update && apt-get install -y --no-install-recommends \
14+
libgl1 \
15+
libglib2.0-0 \
16+
libgomp1 \
17+
libsm6 \
18+
libxext6 \
19+
libxrender1 \
20+
ffmpeg \
21+
&& rm -rf /var/lib/apt/lists/*
22+
23+
COPY requirements.txt .
24+
RUN pip install --no-cache-dir -r requirements.txt
25+
26+
# Install the local HailoRT wheel. The user must place a wheel matching their
27+
# host driver version into hailort-packages/ before building this image.
28+
# Example filename: hailort-4.23.0-cp311-cp311-linux_aarch64.whl
29+
#
30+
# build-essential + python3-dev are needed to compile `netifaces`, a hailort
31+
# dependency that has no pre-built wheel for cp311/aarch64. They are removed
32+
# after install to keep the final image small.
33+
COPY hailort-packages/*.whl /tmp/
34+
RUN apt-get update && apt-get install -y --no-install-recommends \
35+
build-essential python3-dev \
36+
&& pip install --no-cache-dir /tmp/hailort-*.whl \
37+
&& apt-get purge -y --auto-remove build-essential python3-dev \
38+
&& rm -rf /var/lib/apt/lists/* \
39+
&& rm -f /tmp/*.whl
40+
41+
COPY . .
42+
43+
EXPOSE 8000
44+
45+
CMD ["python", "web_detection.py", "--model_path", "model/deeplab_v3_mobilenet_v2.hef", "--video_path", "video/test.mp4"]
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Base image for arm64 (Raspberry Pi 5). Build on the Pi directly, or use
2+
# `docker buildx build --platform linux/arm64` from another host.
3+
FROM python:3.11-slim
4+
5+
WORKDIR /app
6+
7+
# OpenCV + Hailo runtime dependencies.
8+
# libgl1: cv2 image codecs
9+
# libglib2.0-0, libsm6, libxext6, libxrender1: common cv2 dependencies
10+
# libgomp1: OpenMP (used by some opencv-python ops)
11+
# ffmpeg: standalone binary used by VideoAnalyzer for libx264 ultrafast
12+
# encoding (~5x faster than cv2's mp4v at 4K on Pi 5).
13+
RUN apt-get update && apt-get install -y --no-install-recommends \
14+
libgl1 \
15+
libglib2.0-0 \
16+
libgomp1 \
17+
libsm6 \
18+
libxext6 \
19+
libxrender1 \
20+
ffmpeg \
21+
&& rm -rf /var/lib/apt/lists/*
22+
23+
COPY requirements.txt .
24+
RUN pip install --no-cache-dir -r requirements.txt
25+
26+
# Install the local HailoRT wheel. The user must place a wheel matching their
27+
# host driver version into hailort-packages/ before building this image.
28+
# Example filename: hailort-4.23.0-cp311-cp311-linux_aarch64.whl
29+
#
30+
# build-essential + python3-dev are needed to compile `netifaces`, a hailort
31+
# dependency that has no pre-built wheel for cp311/aarch64. They are removed
32+
# after install to keep the final image small.
33+
COPY hailort-packages/*.whl /tmp/
34+
RUN apt-get update && apt-get install -y --no-install-recommends \
35+
build-essential python3-dev \
36+
&& pip install --no-cache-dir /tmp/hailort-*.whl \
37+
&& apt-get purge -y --auto-remove build-essential python3-dev \
38+
&& rm -rf /var/lib/apt/lists/* \
39+
&& rm -f /tmp/*.whl
40+
41+
COPY . .
42+
43+
EXPOSE 8000
44+
45+
CMD ["python", "web_detection.py", "--model_path", "model/fast_depth.hef", "--video_path", "video/test.mp4"]
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Base image for arm64 (Raspberry Pi 5). Build on the Pi directly, or use
2+
# `docker buildx build --platform linux/arm64` from another host.
3+
FROM python:3.11-slim
4+
5+
WORKDIR /app
6+
7+
# OpenCV + Hailo runtime dependencies.
8+
# libgl1: cv2 image codecs
9+
# libglib2.0-0, libsm6, libxext6, libxrender1: common cv2 dependencies
10+
# libgomp1: OpenMP (used by some opencv-python ops)
11+
# ffmpeg: standalone binary used by VideoAnalyzer for libx264 ultrafast
12+
# encoding (~5x faster than cv2's mp4v at 4K on Pi 5).
13+
RUN apt-get update && apt-get install -y --no-install-recommends \
14+
libgl1 \
15+
libglib2.0-0 \
16+
libgomp1 \
17+
libsm6 \
18+
libxext6 \
19+
libxrender1 \
20+
ffmpeg \
21+
&& rm -rf /var/lib/apt/lists/*
22+
23+
COPY requirements.txt .
24+
RUN pip install --no-cache-dir -r requirements.txt
25+
26+
# Install the local HailoRT wheel. The user must place a wheel matching their
27+
# host driver version into hailort-packages/ before building this image.
28+
# Example filename: hailort-4.23.0-cp311-cp311-linux_aarch64.whl
29+
#
30+
# build-essential + python3-dev are needed to compile `netifaces`, a hailort
31+
# dependency that has no pre-built wheel for cp311/aarch64. They are removed
32+
# after install to keep the final image small.
33+
COPY hailort-packages/*.whl /tmp/
34+
RUN apt-get update && apt-get install -y --no-install-recommends \
35+
build-essential python3-dev \
36+
&& pip install --no-cache-dir /tmp/hailort-*.whl \
37+
&& apt-get purge -y --auto-remove build-essential python3-dev \
38+
&& rm -rf /var/lib/apt/lists/* \
39+
&& rm -f /tmp/*.whl
40+
41+
COPY . .
42+
43+
EXPOSE 8000
44+
45+
CMD ["python", "web_detection.py", "--model_path", "model/person_attr_resnet_v1_18.hef", "--video_path", "video/test.mp4"]

docker/hailo8/scdepthv3.dockerfile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Base image for arm64 (Raspberry Pi 5). Build on the Pi directly, or use
2+
# `docker buildx build --platform linux/arm64` from another host.
3+
FROM python:3.11-slim
4+
5+
WORKDIR /app
6+
7+
# OpenCV + Hailo runtime dependencies.
8+
# libgl1: cv2 image codecs
9+
# libglib2.0-0, libsm6, libxext6, libxrender1: common cv2 dependencies
10+
# libgomp1: OpenMP (used by some opencv-python ops)
11+
# ffmpeg: standalone binary used by VideoAnalyzer for libx264 ultrafast
12+
# encoding (~5x faster than cv2's mp4v at 4K on Pi 5).
13+
RUN apt-get update && apt-get install -y --no-install-recommends \
14+
libgl1 \
15+
libglib2.0-0 \
16+
libgomp1 \
17+
libsm6 \
18+
libxext6 \
19+
libxrender1 \
20+
ffmpeg \
21+
&& rm -rf /var/lib/apt/lists/*
22+
23+
COPY requirements.txt .
24+
RUN pip install --no-cache-dir -r requirements.txt
25+
26+
# Install the local HailoRT wheel. The user must place a wheel matching their
27+
# host driver version into hailort-packages/ before building this image.
28+
# Example filename: hailort-4.23.0-cp311-cp311-linux_aarch64.whl
29+
#
30+
# build-essential + python3-dev are needed to compile `netifaces`, a hailort
31+
# dependency that has no pre-built wheel for cp311/aarch64. They are removed
32+
# after install to keep the final image small.
33+
COPY hailort-packages/*.whl /tmp/
34+
RUN apt-get update && apt-get install -y --no-install-recommends \
35+
build-essential python3-dev \
36+
&& pip install --no-cache-dir /tmp/hailort-*.whl \
37+
&& apt-get purge -y --auto-remove build-essential python3-dev \
38+
&& rm -rf /var/lib/apt/lists/* \
39+
&& rm -f /tmp/*.whl
40+
41+
COPY . .
42+
43+
EXPOSE 8000
44+
45+
CMD ["python", "web_detection.py", "--model_path", "model/scdepthv3.hef", "--video_path", "video/test.mp4"]

docker/hailo8/scrfd.dockerfile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Base image for arm64 (Raspberry Pi 5). Build on the Pi directly, or use
2+
# `docker buildx build --platform linux/arm64` from another host.
3+
FROM python:3.11-slim
4+
5+
WORKDIR /app
6+
7+
# OpenCV + Hailo runtime dependencies.
8+
# libgl1: cv2 image codecs
9+
# libglib2.0-0, libsm6, libxext6, libxrender1: common cv2 dependencies
10+
# libgomp1: OpenMP (used by some opencv-python ops)
11+
# ffmpeg: standalone binary used by VideoAnalyzer for libx264 ultrafast
12+
# encoding (~5x faster than cv2's mp4v at 4K on Pi 5).
13+
RUN apt-get update && apt-get install -y --no-install-recommends \
14+
libgl1 \
15+
libglib2.0-0 \
16+
libgomp1 \
17+
libsm6 \
18+
libxext6 \
19+
libxrender1 \
20+
ffmpeg \
21+
&& rm -rf /var/lib/apt/lists/*
22+
23+
COPY requirements.txt .
24+
RUN pip install --no-cache-dir -r requirements.txt
25+
26+
# Install the local HailoRT wheel. The user must place a wheel matching their
27+
# host driver version into hailort-packages/ before building this image.
28+
# Example filename: hailort-4.23.0-cp311-cp311-linux_aarch64.whl
29+
#
30+
# build-essential + python3-dev are needed to compile `netifaces`, a hailort
31+
# dependency that has no pre-built wheel for cp311/aarch64. They are removed
32+
# after install to keep the final image small.
33+
COPY hailort-packages/*.whl /tmp/
34+
RUN apt-get update && apt-get install -y --no-install-recommends \
35+
build-essential python3-dev \
36+
&& pip install --no-cache-dir /tmp/hailort-*.whl \
37+
&& apt-get purge -y --auto-remove build-essential python3-dev \
38+
&& rm -rf /var/lib/apt/lists/* \
39+
&& rm -f /tmp/*.whl
40+
41+
COPY . .
42+
43+
EXPOSE 8000
44+
45+
CMD ["python", "web_detection.py", "--model_path", "model/scrfd_500m.hef", "--video_path", "video/test.mp4"]
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Base image for arm64 (Raspberry Pi 5). Build on the Pi directly, or use
2+
# `docker buildx build --platform linux/arm64` from another host.
3+
FROM python:3.11-slim
4+
5+
WORKDIR /app
6+
7+
# OpenCV + Hailo runtime dependencies.
8+
# libgl1: cv2 image codecs
9+
# libglib2.0-0, libsm6, libxext6, libxrender1: common cv2 dependencies
10+
# libgomp1: OpenMP (used by some opencv-python ops)
11+
# ffmpeg: standalone binary used by VideoAnalyzer for libx264 ultrafast
12+
# encoding (~5x faster than cv2's mp4v at 4K on Pi 5).
13+
RUN apt-get update && apt-get install -y --no-install-recommends \
14+
libgl1 \
15+
libglib2.0-0 \
16+
libgomp1 \
17+
libsm6 \
18+
libxext6 \
19+
libxrender1 \
20+
ffmpeg \
21+
&& rm -rf /var/lib/apt/lists/*
22+
23+
COPY requirements.txt .
24+
RUN pip install --no-cache-dir -r requirements.txt
25+
26+
# Install the local HailoRT wheel. The user must place a wheel matching their
27+
# host driver version into hailort-packages/ before building this image.
28+
# Example filename: hailort-4.23.0-cp311-cp311-linux_aarch64.whl
29+
#
30+
# build-essential + python3-dev are needed to compile `netifaces`, a hailort
31+
# dependency that has no pre-built wheel for cp311/aarch64. They are removed
32+
# after install to keep the final image small.
33+
COPY hailort-packages/*.whl /tmp/
34+
RUN apt-get update && apt-get install -y --no-install-recommends \
35+
build-essential python3-dev \
36+
&& pip install --no-cache-dir /tmp/hailort-*.whl \
37+
&& apt-get purge -y --auto-remove build-essential python3-dev \
38+
&& rm -rf /var/lib/apt/lists/* \
39+
&& rm -f /tmp/*.whl
40+
41+
COPY . .
42+
43+
EXPOSE 8000
44+
45+
CMD ["python", "web_detection.py", "--model_path", "model/segformer_b0_bn.hef", "--video_path", "video/test.mp4"]
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Base image for arm64 (Raspberry Pi 5). Build on the Pi directly, or use
2+
# `docker buildx build --platform linux/arm64` from another host.
3+
FROM python:3.11-slim
4+
5+
WORKDIR /app
6+
7+
# OpenCV + Hailo runtime dependencies.
8+
# libgl1: cv2 image codecs
9+
# libglib2.0-0, libsm6, libxext6, libxrender1: common cv2 dependencies
10+
# libgomp1: OpenMP (used by some opencv-python ops)
11+
# ffmpeg: standalone binary used by VideoAnalyzer for libx264 ultrafast
12+
# encoding (~5x faster than cv2's mp4v at 4K on Pi 5).
13+
RUN apt-get update && apt-get install -y --no-install-recommends \
14+
libgl1 \
15+
libglib2.0-0 \
16+
libgomp1 \
17+
libsm6 \
18+
libxext6 \
19+
libxrender1 \
20+
ffmpeg \
21+
&& rm -rf /var/lib/apt/lists/*
22+
23+
COPY requirements.txt .
24+
RUN pip install --no-cache-dir -r requirements.txt
25+
26+
# Install the local HailoRT wheel. The user must place a wheel matching their
27+
# host driver version into hailort-packages/ before building this image.
28+
# Example filename: hailort-4.23.0-cp311-cp311-linux_aarch64.whl
29+
#
30+
# build-essential + python3-dev are needed to compile `netifaces`, a hailort
31+
# dependency that has no pre-built wheel for cp311/aarch64. They are removed
32+
# after install to keep the final image small.
33+
COPY hailort-packages/*.whl /tmp/
34+
RUN apt-get update && apt-get install -y --no-install-recommends \
35+
build-essential python3-dev \
36+
&& pip install --no-cache-dir /tmp/hailort-*.whl \
37+
&& apt-get purge -y --auto-remove build-essential python3-dev \
38+
&& rm -rf /var/lib/apt/lists/* \
39+
&& rm -f /tmp/*.whl
40+
41+
COPY . .
42+
43+
EXPOSE 8000
44+
45+
CMD ["python", "web_detection.py", "--model_path", "model/unet_mobilenet_v2.hef", "--video_path", "video/test.mp4"]

0 commit comments

Comments
 (0)