CV / YOLOv7

YOLOv7

reComputer R Series (CM5 + Hailo-10H)

YOLOv7 COCO object detection accelerated by RKNN on reComputer RK3576 and RK3588, and through HailoRT on reComputer R Series with Hailo-10H.

49 downloads
Size
9.2 MB
Precision
RKNN / 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 cm5-hailo10h-yolov7_tiny \
  --privileged \
  --net=host \
  -e PYTHONUNBUFFERED=1 \
  --device /dev/hailo0:/dev/hailo0 \
  -v /usr/lib/libhailort.so.5.1.1:/usr/lib/libhailort.so.5.1.1:ro \
  -v /usr/lib/libhailort.so:/usr/lib/libhailort.so:ro \
  ghcr.io/seeed-projects/recomputer-hailo10h-cv/yolov7_tiny:latest \
  python web_detection.py --model_path model/yolov7_tiny.hef --video_path video/test.mp4

REST API

Use the REST API to run inference. Copy the commands below.

Curl
curl http://localhost:8080/v1/chat/completions -d '{
  "model": "yolov7-rknn",
  "messages": [{"role": "user", "content": "Hello"}]
}'
Python
import requests

resp = requests.post(
    "http://localhost:8080/v1/chat/completions",
    json={"model": "yolov7-rknn", "messages": [{"role": "user", "content": "Hello"}]},
)
print(resp.json())

Model Details

reComputer R Series (CM5 + Hailo-10H)

YOLOv7 on reComputer R Series (CM5 + Hailo-10H)

YOLOv7 / YOLOv7-tiny / YOLOv7e6 / YOLOv7x perform COCO 80-class object detection on Hailo-10H through HailoRT. The compiled HEF runs NMS on-chip (HPP, meta_arch=yolov5, at most 80 boxes per class), so the application only parses the compact NMS-by-class buffer HailoRT 5.1.1 returns.

This page targets reComputer R Series (CM5 + Hailo-10H) with a PCIe Hailo-10H accelerator.

Hardware and Host Setup

ItemValue
BoardreComputer R Series with Raspberry Pi CM5
AcceleratorHailo-10H over PCIe, exposed as /dev/hailo0
RuntimeHailoRT 5.1.1
Python in container3.13, aarch64

Install the Hailo-10H packages on the host and confirm that the driver and device are ready before starting the container:

bash
sudo apt update
sudo apt install hailo-h10-all -y
sudo reboot

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

The expected HailoRT version for these images is 5.1.1.

Run With Demo Video

YOLOv7:

bash
sudo docker run --rm \
  --name cm5-hailo10h-yolov7 \
  --privileged \
  --net=host \
  -e PYTHONUNBUFFERED=1 \
  --device /dev/hailo0:/dev/hailo0 \
  -v /usr/lib/libhailort.so.5.1.1:/usr/lib/libhailort.so.5.1.1:ro \
  -v /usr/lib/libhailort.so:/usr/lib/libhailort.so:ro \
  ghcr.io/seeed-projects/recomputer-hailo10h-cv/yolov7:latest \
  python web_detection.py --model_path model/yolov7.hef --video_path video/test.mp4

YOLOv7-tiny:

bash
sudo docker run --rm \
  --name cm5-hailo10h-yolov7_tiny \
  --privileged \
  --net=host \
  -e PYTHONUNBUFFERED=1 \
  --device /dev/hailo0:/dev/hailo0 \
  -v /usr/lib/libhailort.so.5.1.1:/usr/lib/libhailort.so.5.1.1:ro \
  -v /usr/lib/libhailort.so:/usr/lib/libhailort.so:ro \
  ghcr.io/seeed-projects/recomputer-hailo10h-cv/yolov7_tiny:latest \
  python web_detection.py --model_path model/yolov7_tiny.hef --video_path video/test.mp4

YOLOv7e6:

bash
sudo docker run --rm \
  --name cm5-hailo10h-yolov7e6 \
  --privileged \
  --net=host \
  -e PYTHONUNBUFFERED=1 \
  --device /dev/hailo0:/dev/hailo0 \
  -v /usr/lib/libhailort.so.5.1.1:/usr/lib/libhailort.so.5.1.1:ro \
  -v /usr/lib/libhailort.so:/usr/lib/libhailort.so:ro \
  ghcr.io/seeed-projects/recomputer-hailo10h-cv/yolov7e6:latest \
  python web_detection.py --model_path model/yolov7e6.hef --video_path video/test.mp4

YOLOv7x:

bash
sudo docker run --rm \
  --name cm5-hailo10h-yolov7x \
  --privileged \
  --net=host \
  -e PYTHONUNBUFFERED=1 \
  --device /dev/hailo0:/dev/hailo0 \
  -v /usr/lib/libhailort.so.5.1.1:/usr/lib/libhailort.so.5.1.1:ro \
  -v /usr/lib/libhailort.so:/usr/lib/libhailort.so:ro \
  ghcr.io/seeed-projects/recomputer-hailo10h-cv/yolov7x:latest \
  python web_detection.py --model_path model/yolov7x.hef --video_path video/test.mp4

Open http://<Board_IP>:8000 to view the web preview.

USB Camera Mode

bash
sudo docker run --rm \
  --name cm5-hailo10h-yolov7 \
  --privileged \
  --net=host \
  -e PYTHONUNBUFFERED=1 \
  --device /dev/hailo0:/dev/hailo0 \
  --device /dev/video0:/dev/video0 \
  -v /usr/lib/libhailort.so.5.1.1:/usr/lib/libhailort.so.5.1.1:ro \
  -v /usr/lib/libhailort.so:/usr/lib/libhailort.so:ro \
  ghcr.io/seeed-projects/recomputer-hailo10h-cv/yolov7:latest \
  python web_detection.py --model_path model/yolov7.hef --camera_id 0

Swap yolov7 for yolov7_tiny, yolov7e6 or yolov7x to use another variant.

HEF Files

ModelInputSizeNotes
yolov7.hef640x640x328,106,752 (28.1 MB)36.91M params, 104.51G ops, hardware mAP 48.8, 63.6 FPS
yolov7_tiny.hef640x640x39,199,616 (9.2 MB)6.22M params, 13.74G ops, hardware mAP 36.3, 288 FPS
yolov7e6.hef1280x1280x373,072,640 (73.1 MB)97.20M params, 515.12G ops, hardware mAP 53.1, 16.4 FPS
yolov7x.hef640x640x356,406,016 (56.4 MB)71.46M params, 189.68G ops, hardware mAP 51.0, 34.7 FPS

All four variants are Hailo Model Zoo v5.4.0 Hailo-10H builds. mAP and FPS are the Model Zoo's published Hailo-10H numbers.

Source: https://hailo-model-zoo.s3.eu-west-2.amazonaws.com/ModelZoo/Compiled/v5.4.0/hailo10h/yolov7.hef (yolov7_tiny.hef, yolov7e6.hef, yolov7x.hef in the same directory).

REST API

Each variant has its own endpoint:

VariantEndpoint
YOLOv7POST /api/models/yolov7/predict
YOLOv7-tinyPOST /api/models/yolov7_tiny/predict
YOLOv7e6POST /api/models/yolov7e6/predict
YOLOv7xPOST /api/models/yolov7x/predict
bash
curl -X POST "http://<Board_IP>:8000/api/models/yolov7/predict" \
  -F "file=@bus.jpg" -F "conf=0.25"

The response contains predictions entries with class, confidence and box fields.

Implementation Notes

  • The ALLS recipe is change_output_activation(sigmoid) plus nms_postprocess(<model>_nms_config.json, meta_arch=yolov5, engine=cpu); the NMS config uses nms_scores_th 0.2, nms_iou_th 0.6 and max_proposals_per_class 80, so the host runs no box decode and no NMS.
  • HPP output on HailoRT 5.1.1 is the flat compact NMS-by-class buffer (per class: detection count followed by that many [ymin, xmin, ymax, xmax, score] rows, all normalized to [0, 1]). Fixed-stride readers misalign every class after the first; the parser stops at the first implausible header and also keeps handlers for the ragged NMS-by-score and dense (1,C,5,D) / (1,C,D,5) layouts.
  • yolov7e6 uses a 1280x1280x3 input; the other three use 640x640x3. The application reads the size from the HEF at startup.
  • Pre-processing letterboxes to the HEF input size with gray (114) padding, converts BGR to RGB and feeds raw uint8; the /255 normalization is compiled into the HEF.
  • Class IDs 0..79 index the standard COCO class list directly.
  • First-inference diagnostics are disabled in production (_OUTPUT_LOGGED = True); set it to False in web_detection.py to dump the raw output type, shape, value range and per-class rows when validating a new HEF.

Development Notes

  • Source modules: src/hailo10h_yolov7/, src/hailo10h_yolov7_tiny/, src/hailo10h_yolov7e6/, src/hailo10h_yolov7x/ in the reComputer-Hailo10H-CV repository
  • Containers: ghcr.io/seeed-projects/recomputer-hailo10h-cv/yolov7{,_tiny,e6,x}:latest
  • The Hailo Model Zoo also publishes Hailo-8 builds of all four variants (v2.19.0 / v2.20.0); only the Hailo-10H modules are published here so far.
  • Model licence: GPL-3.0 (upstream WongKinYiu/yolov7).

Inputs and Outputs

Input: image, video frame, or camera frame. Output: COCO classes, confidence scores, and boxes.