Downloads · 30 days
0
darkbit1001/Stable-Diffusion-1.5-LCM-ONNX-RKNN2
Stable-Diffusion-1.5-LCM-ONNX-RKNN2 is a machine learning model from darkbit1001. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Run the Stable Diffusion 1.5 Latent Consistency Model (LCM-SD) on Rockchip RKNPU2 (RK3588) using RKNN2.
Downloads · 30 days
0
Access
Public
Updated Jan 13, 2026
Repo size
6.6 GB
Likes
0
Public
Click a slice to open those files.
.onnx_data3.4 GB · 52%
From the Hugging Face model README
Run the Stable Diffusion 1.5 Latent Consistency Model (LCM-SD) on Rockchip RKNPU2 (RK3588) using RKNN2.
This repository supports command-line inference and a production-ready HTTP server optimized specifically for LCM-SD.
| Resolution | Text Encoder | U-Net (per step) | VAE Decoder |
|---|---|---|---|
| 384×384 | ~0.05s | ~2.36s | ~5.48s |
| 512×512 | ~0.05s | ~5.65s | ~11–14s |
NOTE: VAE decode latency is a known RKNN limitation and is not caused by layout, server, or postprocessing overhead.
numpy.RandomState(seed)python ./run_rknn-lcm.py -i ./model -o ./images --num-inference-steps 4 -s 512x512 --prompt "Majestic mountain landscape with snow-capped peaks, autumn foliage in vibrant reds and oranges, a turquoise river winding through a valley, crisp and serene atmosphere, ultra-realistic style."

export MODEL_ROOT=./model
export NUM_WORKERS=3
export PORT=4200
python lcm_server.py
The server listens on:
http://0.0.0.0:4200
Generate a PNG image using LCM-SD.
Request body (JSON):
{
"prompt": "a cinematic forest at sunrise",
"size": "512x512",
"num_inference_steps": 4,
"guidance_scale": 1.0,
"seed": 1234
}
Response: • HTTP 200 • Content-Type: image/png • Binary PNG payload
curl -X POST http://node1.lan:4200/generate \
-H "Content-Type: application/json" \
-o output.png \
-d '{
"prompt": "a cinematic forest at sunrise",
"size": "512x512",
"num_inference_steps": 4,
"guidance_scale": 1.0,
"seed": 1234
}'
docker build \
-t rknn-lcm-sd .
docker run --rm -it \
--device /dev/dri \
--device /dev/rknpu \
-v ./model:/models \
-e MODEL_ROOT=/models \
-e NUM_WORKERS=3 \
-p 4200:4200 \
rknn-lcm-sd
Additionally, a docker-compose.yml is provided.
pip install diffusers pillow numpy<2 rknn-toolkit2
Download a Stable Diffusion 1.5 LCM model in ONNX format and place it in the ./model directory.
huggingface-cli download TheyCallMeHex/LCM-Dreamshaper-V7-ONNX
cp -r -L ~/.cache/huggingface/hub/models--TheyCallMeHex--LCM-Dreamshaper-V7-ONNX/snapshots/4029a217f9cdc0437f395738d3ab686bb910ceea ./model
In theory, you could also achieve LCM inference by merging the LCM Lora into a regular Stable Diffusion 1.5 model and then converting it to ONNX format. However, I'm not sure how to do this. If anyone knows, please feel free to submit a PR.
# Convert the model, 384x384 resolution
python ./convert-onnx-to-rknn.py -m ./model -r 384x384
Note that the higher the resolution, the larger the model and the longer the conversion time. It's not recommended to use very high resolutions.
As of now, models converted using the latest version of rknn-toolkit2 (version 2.2.0) still suffer from severe precision loss, even when using fp16 data type. As shown in the image, the top is the result of inference using the ONNX model, and the bottom is the result using the RKNN model. All parameters are the same. Moreover, the higher the resolution, the more severe the precision loss. This is a bug in rknn-toolkit2. (Fixed in v2.3.0)
Actually, the model conversion script can select multiple resolutions (e.g., "384x384,256x256"), but this causes the model conversion to fail. This is a bug in rknn-toolkit2.