CV / ResNet

ResNet50V2

ImageNet classification with configurable Top-K results, browser preview, and REST API access.

2 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 \
  -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 -1

REST API

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

Curl
curl http://localhost:8080/v1/chat/completions -d '{
  "model": "resnet50-v2-rknn",
  "messages": [{"role": "user", "content": "Hello"}]
}'
Python
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

ResNet50V2 on reComputer RK3576 and RK3588

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

PropertyValue
TaskImage classification
Input224 x 224 RGB image
OutputConfigurable Top-K ImageNet labels and confidence scores
RK3576 modelmodel/rk3576_resnet50-v2-7.rknn
RK3588 modelmodel/rk3588_resnet50-v2-7.rknn
Labelsmodel/synset.txt

Run the service

RK3576

bash
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 -1

RK3588

bash
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 -1

Open http://<BOARD_IP>:8000 for the Web page or http://<BOARD_IP>:8000/docs for OpenAPI.

Input modes and startup arguments

The application accepts an uploaded image, a selected frame from an uploaded MP4, a looping local video, or a camera frame.

ArgumentDefaultDescription
--model_pathRequiredRKNN model selected for the target SoC.
--camera_id1Camera index; use -1 for upload-only mode.
--video_pathNoneLocal MP4 path; it overrides the camera.
--host0.0.0.0FastAPI listen address.
--port8000Service port.

Map /dev/videoN into the container when selecting camera N.

REST API

Endpoint: POST /api/models/resnet50v2/predict

Multipart fields include file, video, timestamp, conf, and topk.

bash
curl -X POST "http://<BOARD_IP>:8000/api/models/resnet50v2/predict" \
  -F "file=@dog_224x224.jpg" -F "topk=5" -F "conf=0.01"
bash
curl -X POST "http://<BOARD_IP>:8000/api/models/resnet50v2/predict" \
  -F "video=@test.mp4" -F "timestamp=5.5" -F "topk=3"

Example response:

json
{
  "success": true,
  "model": "resnet50v2",
  "source": "uploaded image",
  "predictions": [
    {"class": "n02099601 golden retriever", "confidence": 0.89}
  ],
  "image": {"width": 224, "height": 224}
}

GET /api/config returns conf_thresh; update it with JSON through POST /api/config. Request-level conf takes precedence.

EndpointPurpose
GET /api/healthService, platform, model, and readiness.
GET /api/video_feedAnnotated MJPEG preview.
POST /api/video/uploadUpload an image or MP4.
POST /api/video/analyzeAnalyze an uploaded filename.
GET /api/video/statusProcessing progress and errors.
GET /api/video/listUploaded and generated files.
GET /api/video/download/{filename}Download a result.

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 locally

bash
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_resnet50v2

Inputs and Outputs

Input: image, video frame, or camera frame. Output: Top-K ImageNet labels and confidence scores.