CV / YOLOv5
YOLOv5-seg
YOLOv5-seg instance segmentation models on reComputer RK3588/RK3576 (RKNN) and on reComputer R Series with Hailo-8 or Hailo-10H.
Choose the device you're using, the set up guide and documentation will update accordingly.
Getting Started
sudo docker run --rm \
--name rk3588-yolov5n-seg \
--privileged \
--net=host \
-e PYTHONUNBUFFERED=1 \
-e RKNN_LOG_LEVEL=0 \
--device /dev/video0:/dev/video0 \
--device /dev/dri/renderD128:/dev/dri/renderD128 \
-v /proc/device-tree/compatible:/proc/device-tree/compatible \
ghcr.io/seeed-projects/recomputer-rk-cv/rk3588-yolov5_seg:latest \
python3 web_detection.py --model_path model/yolov5n_seg.rknn --video video/test.mp4Model Details
reComputer R Series (CM5 + Hailo-8)YOLOv5-seg on reComputer R Series (CM5 + Hailo-8)
YOLOv5-seg (anchor-based instance segmentation) detects 80 COCO object classes and produces a pixel mask per instance. The HEF exposes three raw detection heads plus a mask-prototype tensor; the app decodes anchors on the CPU, runs per-class NMS, and assembles masks from the prototype tensor.
This page targets reComputer R Series (CM5 + Hailo-8) with a PCIe Hailo-8 accelerator.
Model Info
| Variant | Parameters | Hardware mAP | HEF size |
|---|---|---|---|
| YOLOv5n-seg | 1.99M | 22.9 | 4.7 MB |
| YOLOv5s-seg | 7.61M | 30.7 | 8.7 MB |
| YOLOv5m-seg | 32.60M | 36.6 | 28.1 MB |
Common properties:
| Property | Value |
|---|---|
| Architecture | YOLOv5-seg (3 anchors, strides 8/16/32) |
| Input | 640x640x3 RGB (normalize_in_net mean 0 / std 255) |
| Output | proto (160x160x32) + 3 detection heads (351 channels each) |
| Letterbox padding | 114 (gray, YOLO convention) |
| HEF | Hailo Model Zoo v2.19.0, Hailo-8 |
The accuracy values are Hailo Model Zoo reference benchmarks, not measurements taken on CM5.
Hardware and Host Setup
sudo apt update
sudo apt install hailort hailort-pcie-driver python3-hailort
sudo reboot
hailortcli --version
hailortcli fw-control identify
ls -l /dev/hailo0Pull the Image
The image is published on GHCR. Pull it before starting the container:
sudo docker pull ghcr.io/seeed-projects/recomputer-hailo8-cv/yolov5n_seg:latest
sudo docker pull ghcr.io/seeed-projects/recomputer-hailo8-cv/yolov5s_seg:latest
sudo docker pull ghcr.io/seeed-projects/recomputer-hailo8-cv/yolov5m_seg:latestRun With Demo Video
YOLOv5n-seg:
sudo docker run --rm \
--name cm5-hailo8-yolov5n-seg \
--privileged \
--net=host \
-e PYTHONUNBUFFERED=1 \
--device /dev/hailo0:/dev/hailo0 \
-v /usr/lib/libhailort.so.4.23.0:/usr/lib/libhailort.so.4.23.0:ro \
-v /usr/lib/libhailort.so:/usr/lib/libhailort.so:ro \
ghcr.io/seeed-projects/recomputer-hailo8-cv/yolov5n_seg:latest \
python web_detection.py --model_path model/yolov5n_seg.hef --video_path video/test.mp4YOLOv5s-seg / YOLOv5m-seg use the same command; replace yolov5n_seg with
yolov5s_seg or yolov5m_seg.
Open http://<Board_IP>:8000 to view the web preview with instance masks.
USB Camera Mode
Add --device /dev/video0:/dev/video0 and replace --video_path video/test.mp4
with --camera_id 0.
REST API
curl -X POST "http://<Board_IP>:8000/api/models/yolov5n_seg/predict" \
-F "file=@test.jpg"| Endpoint | Method | Purpose |
|---|---|---|
/api/models/yolov5n_seg/predict | POST | Boxes + instance masks (JSON) |
/api/video_feed | GET | MJPEG preview stream |
Implementation Details
- Decode follows the Hailo Model Zoo
yolov5_segpost-processing: anchor decode (xy = (sigmoid(xy) * 2 + grid - 0.5) * stride,wh = (sigmoid(wh) * 2) ** 2 * anchor_grid), objectness x class score, per-class NMS, thensigmoid(coeffs @ proto)upsampled to the input and cropped to each box. - The three detection heads are identified by their 351 channels and sorted by spatial size (stride 32 -> 16 -> 8); the proto head is the 160x160x32 tensor. First inference prints every vstream name/shape so the mapping can be verified on hardware.
- The executor uses the HailoRT 4.23 VStreams API and a Hailo-8-specific HEF.
- Source module:
src/rpi5_hailo8_yolov5n_seg/(also..._s_seg/,..._m_seg/) - Dockerfile:
docker/hailo8/yolov5n_seg.dockerfile