CV / PPSeg

PP-LiteSeg

Produces 19-class Cityscapes masks with image, camera, and video service modes.

4 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/renderD129:/dev/dri/renderD129 \
  -v /proc/device-tree/compatible:/proc/device-tree/compatible:ro \
  ghcr.io/seeed-projects/recomputer-rk-cv/rk3576-ppseg:latest \
  python web_service.py --platform rk3576 --model_dir /app/model --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": "pp-liteseg-rknn",
  "messages": [{"role": "user", "content": "Hello"}]
}'
Python
import requests

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

Model Details

PP-LiteSeg on reComputer RK3576 and RK3588

This service packages the PP-LiteSeg Cityscapes example from reComputer-RK-CV with RKNN inference, Web preview, REST APIs, and asynchronous MP4 processing.

Model information

PropertyValue
Modelmodel/ppseg.rknn
Input512 x 512 RGB
Output19-class Cityscapes segmentation mask
Warm-up imagemodel/test.png

Run the service

RK3576

bash
sudo docker run --rm --privileged --net=host \
  -e PYTHONUNBUFFERED=1 -e RKNN_LOG_LEVEL=0 \
  --device /dev/dri/renderD129:/dev/dri/renderD129 \
  -v /proc/device-tree/compatible:/proc/device-tree/compatible:ro \
  ghcr.io/seeed-projects/recomputer-rk-cv/rk3576-ppseg:latest \
  python web_service.py --platform rk3576 --model_dir /app/model \
  --camera_id -1 --host 0.0.0.0 --port 8000

RK3588

bash
sudo docker run --rm --privileged --net=host \
  -e PYTHONUNBUFFERED=1 -e RKNN_LOG_LEVEL=0 \
  --device /dev/dri/renderD129:/dev/dri/renderD129 \
  -v /proc/device-tree/compatible:/proc/device-tree/compatible:ro \
  ghcr.io/seeed-projects/recomputer-rk-cv/rk3588-ppseg:latest \
  python web_service.py --platform rk3588 --model_dir /app/model \
  --camera_id -1 --host 0.0.0.0 --port 8000

Open http://<BOARD_IP>:8000 or /docs. Use --camera_id N with a mapped /dev/videoN node for a camera. Use --video video/test.mp4 for the bundled video; --video and --video_path are aliases and override the camera.

Startup arguments

ArgumentDefaultDescription
--platformRequiredrk3576 or rk3588.
--model_dirmodelDirectory containing ppseg.rknn and test.png.
--camera_id-1Camera index; -1 disables capture.
--video, --video_pathNoneLooping local video; overrides the camera.
--host / --port0.0.0.0 / 8000FastAPI listen address and port.

PYTHONUNBUFFERED=1 flushes logs immediately. RKNN_LOG_LEVEL=0 suppresses known harmless static-model initialization messages; remove it while debugging RKNN startup.

REST API

Endpoint: POST /api/models/ppseg/predict

bash
curl -X POST "http://<BOARD_IP>:8000/api/models/ppseg/predict" \
  -F "file=@test.png"

The response contains inference time, source dimensions, and per-class pixel counts. The latest mask overlay is served by GET /api/video_feed.

EndpointPurpose
GET /api/healthPlatform, model names, and readiness.
GET /api/video_feedLatest color-mask overlay as MJPEG.
POST /api/video/uploadUpload one MP4 in field file.
POST /api/video/analyzeAnalyze an uploaded filename.
GET /api/video/statusBackground progress and errors.
GET /api/video/listUploaded and generated videos.
GET /api/video/download/{filename}Download a result.

The generic threshold and topk configuration fields are retained for service compatibility but do not change the fixed argmax segmentation. A replacement model must retain the expected 19-class output or update the palette and post-processing code.

The runtime resizes input to 512 x 512, converts BGR to RGB, accepts NCHW or NHWC 19-class output, restores the mask with nearest-neighbor interpolation, and overlays the Cityscapes palette. Conversion sources are under rknn_model_zoo/examples/ppseg in the upstream project.

Build locally

bash
docker build -f docker/rk3576/ppseg.dockerfile \
  -t rk3576-ppseg:local src/rk3576_ppseg

docker build -f docker/rk3588/ppseg.dockerfile \
  -t rk3588-ppseg:local src/rk3588_ppseg

Inputs and Outputs

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