CV / YOLOv8

YOLOv8-seg

YOLOv8n/s/m instance segmentation on reComputer RK3588/RK3576 (RKNN) and on reComputer R Series with Hailo-8 or Hailo-10H through HailoRT.

223 downloads
Size
~7.2MB
Memory
1GB+
Precision
INT8

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

Getting Started

Deploy
sudo docker run --rm \
  --name rk3588-yolov8n-seg \
  --privileged \
  --net=host \
  -e PYTHONUNBUFFERED=1 \
  -e RKNN_LOG_LEVEL=0 \
  --device /dev/video1:/dev/video1 \
  --device /dev/dri/renderD129:/dev/dri/renderD129 \
  -v /proc/device-tree/compatible:/proc/device-tree/compatible \
  ghcr.io/seeed-projects/recomputer-rk-cv/rk3588-yolov8_seg:latest \
  python web_detection.py --model_path model/yolov8n_seg.rknn --video video/test.mp4

Model Details

reComputer R Series (CM5 + Hailo-8)

YOLOv8-seg on reComputer R Series (CM5 + Hailo-8)

YOLOv8n/s/m-seg run on Hailo-8 through HailoRT 4.23. The HEF exposes raw heads (no on-chip NMS): the host decodes the DFL boxes, applies sigmoid and per-class NMS, and assembles the prototype masks (32 coefficients × 160×160×32 prototype, cropped to each box) for 80 COCO classes.

Model Info

VariantInputPackaged HEFContainer image
YOLOv8n-seg640×640×3 RGB5.3 MByolov8n_seg
YOLOv8s-seg640×640×3 RGB17.3 MByolov8s_seg
YOLOv8m-seg640×640×3 RGB32.9 MByolov8m_seg

Hardware and Host Setup

ItemValue
BoardreComputer R Series with Raspberry Pi CM5
AcceleratorHailo-8 over PCIe, exposed as /dev/hailo0
RuntimeHailoRT 4.23.x (host / container must share major.minor)
Python in container3.11, aarch64
bash
sudo apt update
sudo apt install hailort hailort-pcie-driver python3-hailort
sudo reboot

# After reboot
hailortcli fw-control identify
ls /dev/hailo0

# Docker
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh --mirror Aliyun
sudo systemctl enable docker
sudo systemctl start docker

Run With Demo Video

Select the command matching the model variant.

YOLOv8n-seg

bash
sudo docker run --rm \
  --name cm5-hailo8-yolov8n-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/yolov8n_seg:latest \
  python web_detection.py --model_path model/yolov8n_seg.hef --video_path video/test.mp4

YOLOv8s-seg

bash
sudo docker run --rm \
  --name cm5-hailo8-yolov8s-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/yolov8s_seg:latest \
  python web_detection.py --model_path model/yolov8s_seg.hef --video_path video/test.mp4

YOLOv8m-seg

bash
sudo docker run --rm \
  --name cm5-hailo8-yolov8m-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/yolov8m_seg:latest \
  python web_detection.py --model_path model/yolov8m_seg.hef --video_path video/test.mp4

Open http://<Board_IP>:8000 to view the web preview (instance masks overlaid per class + detection boxes).

USB Camera Mode

bash
sudo docker run --rm \
  --name cm5-hailo8-yolov8n-seg \
  --privileged \
  --net=host \
  -e PYTHONUNBUFFERED=1 \
  --device /dev/hailo0:/dev/hailo0 \
  --device /dev/video0:/dev/video0 \
  -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/yolov8n_seg:latest \
  python web_detection.py --model_path model/yolov8n_seg.hef --camera_id 0

REST API

Each variant has its own endpoint:

VariantEndpoint
YOLOv8n-segPOST /api/models/yolov8n_seg/predict
YOLOv8s-segPOST /api/models/yolov8s_seg/predict
YOLOv8m-segPOST /api/models/yolov8m_seg/predict

Example:

bash
curl -X POST "http://<Board_IP>:8000/api/models/yolov8n_seg/predict" \
  -F "file=@test.jpg"

The response contains predictions entries with class, confidence and box fields (box is x1/y1/x2/y2 in original-frame pixels). Instance masks are rendered in the MJPEG preview; /api/video_feed serves the annotated stream.

Implementation Notes

  • The HEF exposes 10 raw tensors: per stride (32/16/8) a 64-channel DFL box head, an 80-channel class head and a 32-channel mask-coefficient head, plus a 160×160×32 prototype.
  • Box decode uses the DFL softmax expectation (16 bins) over the cell centre; a compile that folds the DFL away (4-channel head) is decoded directly.
  • The class heads may already be sigmoid-activated on device (Model Zoo alls script); the module only applies sigmoid when the values are raw logits.
  • The one2many predictions go through per-class NMS driven by the confidence and IoU sliders; masks are sigmoid(coeffs @ proto), upsampled to the input and cropped to each box (threshold 0.5).
  • Letterbox padding is 114 (Model Zoo base/yolo.yaml); the mean 0 / std 255 normalization is compiled into the HEF.

Development Notes

VariantSourceDockerfileContainer
YOLOv8n-segsrc/rpi5_hailo8_yolov8n_seg/docker/hailo8/yolov8n_seg.dockerfileghcr.io/seeed-projects/recomputer-hailo8-cv/yolov8n_seg:latest
YOLOv8s-segsrc/rpi5_hailo8_yolov8s_seg/docker/hailo8/yolov8s_seg.dockerfileghcr.io/seeed-projects/recomputer-hailo8-cv/yolov8s_seg:latest
YOLOv8m-segsrc/rpi5_hailo8_yolov8m_seg/docker/hailo8/yolov8m_seg.dockerfileghcr.io/seeed-projects/recomputer-hailo8-cv/yolov8m_seg:latest
  • The executor is the HailoRT 4.23 InferVStreams wrapper (Python 3.11 + the bundled cp311 wheel); the native libhailort.so comes from the host.
  • HEFs: Hailo Model Zoo v2.19.0 Hailo-8 builds.
  • Referenced mAP values (COCO instance segmentation) are the Model Zoo full-precision figures, not measurements on this board.