CV / YOLOv8
YOLOv8m_object
YOLOv8 Object Detection Series Medium Version, lightweight and efficient, suitable for edge deployment.
Choose the device you're using, the set up guide and documentation will update accordingly.
Getting Started
sudo docker run -it --rm --pull always --runtime=nvidia \
--network host ghcr.io/seeed-studio/vllm:latest-rk3588 \
vllm serve yolov8m_objectREST API
Use the REST API to run inference. Copy the commands below.
curl -X POST "http://127.0.0.1:8000/api/models/yolov8n/predict" -F "realtime=true"
# Or without file parameters
curl -X POST "http://127.0.0.1:8000/api/models/yolov8n/predict"
import requests
import json
resp = requests.post(
"http://127.0.0.1:8000/api/models/yolov8n/predict",
json={},
timeout=30
)
result = resp.json()
print(json.dumps(result, indent=2, ensure_ascii=False))
Model Details
Quick Start
1. Install Docker
Run the following commands on the development board to install Docker:
# 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 docker2. Run the Project (One command, dual-mode preview)
This project supports simultaneous preview via Local GUI and Web Browser. The program automatically detects the display environment and downgrades to Web mode if no display is connected.
Step A: Configure Display Permissions (Optional)
If you have a monitor connected and want to see the window locally:
xhost +local:dockerStep B: One-click Run
For RK3588:
sudo docker run --rm --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-yolov8:latest \
python3 web_detection.py --model_path model/yolov8n.rknn --video video/test.mp4For RK3576:
sudo docker run --rm --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/rk3576-yolov8:latest \
python3 web_detection.py --model_path model/yolov8n.rknn --video video/test.mp4Access via: http://<Board_IP>:8000
Note: If you need custom classes, you can add
-v $(pwd)/class_config.txt:/app/class_config.txt \mount and--class_pathparameter. The program defaults to COCO 80 classes.
Example:
sudo docker run --rm --privileged --net=host \
-e PYTHONUNBUFFERED=1 \
-e RKNN_LOG_LEVEL=0 \
-v $(pwd)/class_config.txt:/app/class_config.txt \
--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-yolov8:latest \
python3 web_detection.py --model_path model/yolov8n.rknn --video video/test.mp4 --class_path class_config.txt๐ API Documentation
This project provides RESTful interfaces compatible with the Ultralytics Cloud API standard, supporting object detection via image, video uploads or direct camera calls.
1. Model Inference Interface (Predict)
Endpoint: POST /api/models/yolov8/predict
Request Parameters (Multipart/Form-Data):
file: (Optional) Image file to be detected.video: (Optional) MP4 video file to be detected.timestamp: (Optional) Timestamp in the video file (seconds), returns detection results for the frame at that point. Default is 0.realtime: (Optional) Boolean. Iftrueor if nofile/videoparameters are provided, returns detection results for the current camera frame.conf: (Optional) Confidence threshold for a single request, range 0.0-1.0.iou: (Optional) NMS IOU threshold for a single request, range 0.0-1.0.
Usage Examples:
1. Image Detection:
curl -X POST "http://127.0.0.1:8000/api/models/yolov8/predict" -F "file=@/home/cat/001.jpg"2. Video Specific Frame Detection:
curl -X POST "http://127.0.0.1:8000/api/models/yolov8/predict" -F "video=@/home/cat/test.mp4" -F "timestamp=5.5"3. Get Current Camera Frame Detection:
curl -X POST "http://127.0.0.1:8000/api/models/yolov8/predict" -F "realtime=true"
# Or without file parameters
curl -X POST "http://127.0.0.1:8000/api/models/yolov8/predict"Response Format (JSON):
{
"success": true,
"source": "video frame at 5.5s",
"predictions": [
{
"class": "person",
"confidence": 0.92,
"box": { "x1": 100, "y1": 200, "x2": 300, "y2": 500 }
}
],
"image": { "width": 1280, "height": 720 }
}2. System Configuration Interface (Config)
Used to dynamically adjust thresholds for real-time video streams and default inference.
Get Current Configuration
- Endpoint:
GET /api/config - Response:
{"obj_thresh": 0.25, "nms_thresh": 0.45}
Update System Configuration
- Endpoint:
POST /api/config - Request Body (JSON):
{"obj_thresh": 0.3, "nms_thresh": 0.5} - Response:
{"status": "success"}
3. Real-time Video Stream Interface (Video Feed)
Get real-time MJPEG video stream with detection boxes drawn, can be directly embedded in HTML <img> tags.
- Endpoint:
GET /api/video_feed - Example Usage:
<img src="http://<Board_IP>:8000/api/video_feed">
๐ ๏ธ Developer Guide (Production Recommendations)
Code Description
web_detection.py:- Dual-mode Support: Integrates FastAPI, supporting both local rendering and MJPEG streaming output.
- Environment Adaptive: Automatically detects the
DISPLAYenvironment variable, silently skipping GUI initialization if not present. - RKNN Inference: Encapsulates RKNN initialization, model loading, and multi-core inference logic.
- Dynamic Loading: Supports dynamic class configuration loading via
--class_path. - Post-processing: YOLOv8 specific Box decoding and NMS logic.
Modifying Models
- Place the trained and converted .rknn model into the
model/directory. - Add the
--model_pathargument to the running command to point to the new model.