CV / ResNet
ResNet50V2
ResNet50V2 image classification accelerated by RKNN on reComputer RK3576 and RK3588.
Choose the device you're using, the set up guide and documentation will update accordingly.
Getting Started
sudo docker run --rm --privileged --net=host \
-e PYTHONUNBUFFERED=1 -e RKNN_LOG_LEVEL=0 \
--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-resnet50v2:latest \
python3 web_classification.py --model_path model/rk3576_resnet50-v2-7.rknn --camera_id -1REST API
Use the REST API to run inference. Copy the commands below.
curl http://localhost:8080/v1/chat/completions -d '{
"model": "resnet50-v2-rknn",
"messages": [{"role": "user", "content": "Hello"}]
}'import requests
resp = requests.post(
"http://localhost:8080/v1/chat/completions",
json={"model": "resnet50-v2-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:
# 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 page is adapted from the ResNet50V2 READMEs in
reComputer-RK-CV. The
service runs ImageNet classification on the Rockchip NPU and provides browser,
MJPEG, health-check, and REST interfaces.
Model Information
| Property | Value |
|---|---|
| Task | Image classification |
| Input | 224 x 224 RGB image |
| Output | Configurable Top-K ImageNet labels and confidence scores |
| RK3576 model | model/rk3576_resnet50-v2-7.rknn |
| RK3588 model | model/rk3588_resnet50-v2-7.rknn |
| Labels | model/synset.txt |
Step A: Pull Images
sudo docker pull ghcr.io/seeed-projects/recomputer-rk-cv/rk3588-resnet50v2:latest
sudo docker pull ghcr.io/seeed-projects/recomputer-rk-cv/rk3576-resnet50v2:latestStep B: Run with One Click
For RK3576:
sudo docker run --rm --privileged --net=host \
-e PYTHONUNBUFFERED=1 -e RKNN_LOG_LEVEL=0 \
--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-resnet50v2:latest \
python3 web_classification.py \
--model_path model/rk3576_resnet50-v2-7.rknn --camera_id -1For RK3588:
sudo docker run --rm --privileged --net=host \
-e PYTHONUNBUFFERED=1 -e RKNN_LOG_LEVEL=0 \
--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-resnet50v2:latest \
python3 web_classification.py \
--model_path model/rk3588_resnet50-v2-7.rknn --camera_id -1Open http://<BOARD_IP>:8000 for the Web page or
http://<BOARD_IP>:8000/docs for OpenAPI.
🔌 API Documentation
1. Model Inference Interface (Predict)
Endpoint: POST /api/models/resnet50v2/predict
Request Parameters (Multipart/Form-Data):
file: Optional image file to classify.video: Optional MP4 file; it cannot be supplied together withfile.timestamp: Optional non-negative video timestamp in seconds; defaults to the first frame.conf: Optional request-level confidence threshold from0.0to1.0.topk: Optional number of results from1to20; defaults to5.- With neither
filenorvideo, the current camera or local-video frame is used when available.
Usage Examples:
curl -X POST "http://<BOARD_IP>:8000/api/models/resnet50v2/predict" \
-F "file=@dog_224x224.jpg" -F "topk=5" -F "conf=0.01"curl -X POST "http://<BOARD_IP>:8000/api/models/resnet50v2/predict" \
-F "video=@test.mp4" -F "timestamp=5.5" -F "topk=3"Response Format (JSON):
{
"success": true,
"model": "resnet50v2",
"source": "uploaded image",
"predictions": [
{"class": "n02099601 golden retriever", "confidence": 0.89}
],
"image": {"width": 224, "height": 224}
}2. System Configuration Interface (Config)
GET /api/config returns conf_thresh; update it with JSON through
POST /api/config. Request-level conf takes precedence.
| Endpoint | Purpose |
|---|---|
GET /api/health | Service, platform, model, and readiness. |
GET /api/video_feed | Annotated MJPEG preview. |
POST /api/video/upload | Upload an image or MP4. |
POST /api/video/analyze | Analyze an uploaded filename. |
GET /api/video/status | Processing progress and errors. |
GET /api/video/list | Uploaded and generated files. |
GET /api/video/download/{filename} | Download a result. |
3. Command Line Arguments
The application accepts an uploaded image, a selected frame from an uploaded MP4, a looping local video, or a camera frame.
| Argument | Default | Description |
|---|---|---|
--model_path | Required | RKNN model selected for the target SoC. |
--camera_id | 1 | Camera index; use -1 for upload-only mode. |
--video_path | None | Local MP4 path; it overrides the camera. |
--host | 0.0.0.0 | FastAPI listen address. |
--port | 8000 | Service port. |
Map /dev/videoN into the container when selecting camera N.
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)
Model Replacement
The runtime resizes input to 224 x 224, converts BGR to RGB, applies softmax,
and filters Top-K results. A replacement model must preserve the expected
input layout, normalization, channel order, and output format. Update
synset.txt if the class set changes. Runtime files are stored under
workspace/; set RK_CV_WORKSPACE to override that location.
Build Local Images
docker build -f docker/rk3576/resnet50v2.dockerfile \
-t rk3576-resnet50v2:local src/rk3576_resnet50v2
docker build -f docker/rk3588/resnet50v2.dockerfile \
-t rk3588-resnet50v2:local src/rk3588_resnet50v2Inputs and Outputs
Input: image, video frame, or camera frame. Output: Top-K ImageNet labels and confidence scores.