CV / YOLOv7

YOLOv7

YOLOv7 COCO object detection accelerated by RKNN on reComputer RK3576 and RK3588.

6 downloads
Precision
RKNN

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

Getting Started

Deploy
sudo docker run --rm --privileged --net=host --device /dev/dri/renderD128:/dev/dri/renderD128 \
  -v /proc/device-tree/compatible:/proc/device-tree/compatible:ro \
  ghcr.io/seeed-projects/recomputer-rk-cv/rk3576-yolov7:latest \
  python3 web_detection.py --platform rk3576 --model_path model/yolov7-tiny.rknn \
  --anchors model/anchors_yolov7.txt --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

Quick Start

1. Install Docker

Run the following commands on the development board to install Docker:

bash
# Download installation script
curl -fsSL https://get.docker.com -o get-docker.sh
# Install using Aliyun mirror source
sudo sh get-docker.sh --mirror Aliyun
# Start Docker and enable auto-start on boot
sudo systemctl enable docker
sudo systemctl start docker

2. Run the Project (One command, dual-mode preview)

This page documents the YOLOv7 RKNN service from reComputer-RK-CV. It supports COCO detection, browser preview, REST inference, camera input, and offline MP4 processing.

Model Information

PropertyValue
TaskCOCO 80-class object detection
Input640 x 640, letterboxed and converted from BGR to RGB
Variantsyolov7-tiny.rknn, yolov7.rknn
Defaultmodel/yolov7-tiny.rknn
Anchorsmodel/anchors_yolov7.txt

Step A: Pull Images

bash
sudo docker pull ghcr.io/seeed-projects/recomputer-rk-cv/rk3588-yolov7:latest
sudo docker pull ghcr.io/seeed-projects/recomputer-rk-cv/rk3576-yolov7:latest

Step B: Run with One Click

For RK3576:

bash
sudo docker run --rm --privileged --net=host \
  --device /dev/dri/renderD128:/dev/dri/renderD128 \
  -v /proc/device-tree/compatible:/proc/device-tree/compatible:ro \
  ghcr.io/seeed-projects/recomputer-rk-cv/rk3576-yolov7:latest \
  python3 web_detection.py --platform rk3576 \
  --model_path model/yolov7-tiny.rknn \
  --anchors model/anchors_yolov7.txt --video_path video/test.mp4

For RK3588:

bash
sudo docker run --rm --privileged --net=host \
  --device /dev/dri/renderD128:/dev/dri/renderD128 \
  -v /proc/device-tree/compatible:/proc/device-tree/compatible:ro \
  ghcr.io/seeed-projects/recomputer-rk-cv/rk3588-yolov7:latest \
  python3 web_detection.py --platform rk3588 \
  --model_path model/yolov7-tiny.rknn \
  --anchors model/anchors_yolov7.txt --video_path video/test.mp4

To use full YOLOv7, change only the model path to model/yolov7.rknn. Keep the anchors argument. Use --camera_id -1 for upload-only mode.


🔌 API Documentation

1. Model Inference Interface (Predict)

Endpoint: POST /api/models/yolov7/predict

Request Parameters (Multipart/Form-Data):

  • file: Optional image file to detect.
  • video: Optional MP4 file.
  • timestamp: Optional video timestamp in seconds; defaults to the first frame.
  • realtime: Optional boolean; with no upload, use the active camera or local-video frame.
  • conf: Optional request-level confidence threshold; defaults to 0.25.
  • iou: Optional request-level NMS IoU threshold; defaults to 0.45.

Usage Examples:

bash
curl -X POST "http://<BOARD_IP>:8000/api/models/yolov7/predict" \
  -F "file=@bus.jpg" -F "conf=0.25" -F "iou=0.45"

Response Format (JSON):

json
{
  "success": true,
  "source": "uploaded image",
  "predictions": [
    {
      "class": "bus",
      "confidence": 0.92,
      "box": {"x1": 100, "y1": 120, "x2": 520, "y2": 430}
    }
  ],
  "image": {"width": 640, "height": 480}
}

The multipart interface accepts image, MP4-frame, and live-source requests.

2. System Configuration Interface (Config)

GET/POST /api/config controls the default confidence and NMS thresholds. Health, MJPEG, video upload, analysis, progress, list, and download endpoints follow the standard service structure. Runtime files use workspace/ by default. Replacement models need a matching anchor file, input size, class configuration, and output layout.

3. Command Line Arguments

ArgumentDefaultDescription
--platformRequiredrk3576 or rk3588.
--model_pathRequiredTiny or full YOLOv7 RKNN file.
--anchorsRequiredAnchor file matching the converted model.
--camera_id1Camera index; use -1 for uploads only.
--video_pathNoneLooping local MP4; overrides the camera.
--class_pathCOCO labelsOptional replacement class list.
--host / --port0.0.0.0 / 8000Service address and port.

Real-time Video Stream Interface (Video Feed)

Get the latest annotated MJPEG stream for browser preview:

  • Endpoint: GET /api/video_feed
  • Example Usage: <img src="http://<BOARD_IP>:8000/api/video_feed">

🛠️ Developer Guide (Production Recommendations)

Build Local Images

bash
docker build -f docker/rk3576/yolov7.dockerfile \
  -t rk3576-yolov7:local src/rk3576_yolov7

docker build -f docker/rk3588/yolov7.dockerfile \
  -t rk3588-yolov7:local src/rk3588_yolov7

Inputs and Outputs

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