CV / DeepLab v3

DeepLabV3 RKNN

Produces a 21-class PASCAL VOC segmentation overlay for images and video frames.

8 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 -p 8000:8000 \
  -v /dev/dri/renderD129:/dev/dri/renderD129 \
  -v /proc/device-tree/compatible:/proc/device-tree/compatible:ro \
  ghcr.io/seeed-projects/recomputer-rk-cv/rk3576-deeplabv3:latest \
  python3 web_service.py --platform rk3576 --model_path /app/model/deeplabv3.rknn \
  --sample_path /app/model/test.jpg --overlay_alpha 0.5 --camera_id -1 --host 0.0.0.0 --port 8000

REST API

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

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

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

Model Details

DeepLabV3 on reComputer RK3576 and RK3588

This page documents the DeepLabV3 semantic-segmentation service in reComputer-RK-CV. It supports still images, cameras, looping local video, uploaded MP4 analysis, and an MJPEG overlay preview.

Model information

PropertyValue
Model/app/model/deeplabv3.rknn
Input513 x 513 RGB
Output21-class PASCAL VOC logits
RenderingArgmax mask with configurable color-overlay opacity

The service validates both NCHW and NHWC output layouts and restores the mask to the source resolution.

Run the service

RK3576

bash
sudo docker run --rm --privileged -p 8000:8000 \
  -v /dev/dri/renderD129:/dev/dri/renderD129 \
  -v /proc/device-tree/compatible:/proc/device-tree/compatible:ro \
  ghcr.io/seeed-projects/recomputer-rk-cv/rk3576-deeplabv3:latest \
  python3 web_service.py --platform rk3576 \
  --model_path /app/model/deeplabv3.rknn \
  --sample_path /app/model/test.jpg --overlay_alpha 0.5 \
  --camera_id -1 --host 0.0.0.0 --port 8000

RK3588

bash
sudo docker run --rm --privileged -p 8000:8000 \
  -v /dev/dri/renderD129:/dev/dri/renderD129 \
  -v /proc/device-tree/compatible:/proc/device-tree/compatible:ro \
  ghcr.io/seeed-projects/recomputer-rk-cv/rk3588-deeplabv3:latest \
  python3 web_service.py --platform rk3588 \
  --model_path /app/model/deeplabv3.rknn \
  --sample_path /app/model/test.jpg --overlay_alpha 0.5 \
  --camera_id -1 --host 0.0.0.0 --port 8000

Open http://<BOARD_IP>:8000 or /docs. For a USB camera, map its /dev/videoN node and set --camera_id N. For a mounted local video, use --video /data/input.mp4; local video takes precedence over the camera.

Startup arguments

ArgumentDefaultDescription
--platformRequiredrk3576 or rk3588.
--model_pathmodel/deeplabv3.rknnDeepLabV3 RKNN file.
--sample_pathmodel/test.jpgWarm-up and initial-preview image.
--overlay_alpha0.5Initial mask opacity from 0 to 1.
--camera_id-1Camera N, or -1 for uploads only.
--video, --video_pathNoneLooping local video; overrides the camera.
--host / --port0.0.0.0 / 8000Service address and container port.

When using -p, change only the host side if port 8000 is occupied. The container service must remain on port 8000 for its health check.

REST API

Endpoint: POST /api/models/deeplabv3/predict

bash
curl -X POST "http://<BOARD_IP>:8000/api/models/deeplabv3/predict" \
  -F "file=@test.jpg" -F "overlay_alpha=0.65"

The response reports image size, inference time, opacity, and all PASCAL VOC classes present with their pixel counts. The latest rendered overlay is available from GET /api/video_feed.

Example result fields:

json
{
  "success": true,
  "model": "deeplabv3",
  "inference_time": 0.052,
  "result": {
    "classes": [{"id": 15, "class": "person", "pixels": 18234}],
    "width": 1280,
    "height": 720,
    "overlay_alpha": 0.65
  }
}

GET/POST /api/config manages the global overlay opacity. Health, MP4 upload, analysis status, list, and download endpoints are also provided. Models with a different class count require corresponding label and output-processing code changes.

Processing details

Input is resized to 513 x 513 and converted from BGR to RGB. The runtime accepts NCHW or NHWC logits, verifies that the output has 21 channels, restores the logits to the source resolution, applies argmax, and overlays the PASCAL VOC color map. POST /api/video/analyze accepts an uploaded filename; status and result files are exposed through the /api/video/* endpoints.

Build locally

bash
docker build -f docker/rk3576/deeplabv3.dockerfile \
  -t rk3576-deeplabv3:local src/rk3576_deeplabv3

docker build -f docker/rk3588/deeplabv3.dockerfile \
  -t rk3588-deeplabv3:local src/rk3588_deeplabv3

Inputs and Outputs

Input: image, video frame, or camera frame. Output: PASCAL VOC semantic mask, class pixel counts, and overlay.