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.

489 downloads
Size
~5.4MB
Memory
1GB+
Precision
INT8 / Hailo HEF

Choose the device you're using, the set up guide and documentation will update accordingly.

Getting Started

Deploy
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.mp4

Model 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

VariantParametersHardware mAPHEF size
YOLOv5n-seg1.99M22.94.7 MB
YOLOv5s-seg7.61M30.78.7 MB
YOLOv5m-seg32.60M36.628.1 MB

Common properties:

PropertyValue
ArchitectureYOLOv5-seg (3 anchors, strides 8/16/32)
Input640x640x3 RGB (normalize_in_net mean 0 / std 255)
Outputproto (160x160x32) + 3 detection heads (351 channels each)
Letterbox padding114 (gray, YOLO convention)
HEFHailo 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

bash
sudo apt update
sudo apt install hailort hailort-pcie-driver python3-hailort
sudo reboot

hailortcli --version
hailortcli fw-control identify
ls -l /dev/hailo0

Pull the Image

The image is published on GHCR. Pull it before starting the container:

bash
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:latest

Run With Demo Video

YOLOv5n-seg:

bash
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.mp4

YOLOv5s-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

bash
curl -X POST "http://<Board_IP>:8000/api/models/yolov5n_seg/predict" \
  -F "file=@test.jpg"
EndpointMethodPurpose
/api/models/yolov5n_seg/predictPOSTBoxes + instance masks (JSON)
/api/video_feedGETMJPEG preview stream

Implementation Details

  • Decode follows the Hailo Model Zoo yolov5_seg post-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, then sigmoid(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