ONNX Model Zoo

thanhtantran/Stable-Diffusion-1.5-LCM-ONNX-RKNN2

By thanhtantran · ↓ 0 · ♥ 0 · Updated 2025-05-22

What's in this repo

This page lists the files in thanhtantran/Stable-Diffusion-1.5-LCM-ONNX-RKNN2, including model.onnx and more.

  • 5 ONNX models (.onnx files)
  • 40 files, including 12 .png, 11 .json, 5 .onnx, 3 .py, 3 .rknn, 2 .md
  • Last updated 2025-05-22

ONNX files

File Size Download
model/text_encoder/model.onnx — Download
model/tokenizer/model.onnx — Download
model/unet/model.onnx — Download
model/vae_decoder/model.onnx — Download
model/vae_encoder/model.onnx — Download

How to use

These ONNX files can be loaded with ONNX Runtime. To inspect a model graph, upload the file to the Netron viewer. Download links point to the original files on Hugging Face.

README

Stable Diffusion 1.5 Latent Consistency Model for RKNN2

Run the Stable Diffusion 1.5 LCM image generation model using RKNPU2!

  • Inference speed (RK3588, single NPU core):
    • 384x384: Text encoder 0.05s + U-Net 2.36s/it + VAE Decoder 5.48s
    • 512x512: Text encoder 0.05s + U-Net 5.65s/it + VAE Decoder 11.13s
  • Memory usage:
    • 384x384: About 5.2GB
    • 512x512: About 5.6GB

Usage

1. Clone or download this repository to your local machine

2. Install dependencies

pip install diffusers pillow numpy<2 rknn-toolkit-lite2

3. Run

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."

image/png

Model Conversion

Install dependencies

pip install diffusers pillow numpy<2 rknn-toolkit2

1. Download the model

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.

2. Convert the model

# 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.

Known Issues

  1. 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)

  2. 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.

References

Model info

onnx rknn LCM stable-diffusion base_model:TheyCallMeHex/LCM-Dreamshaper-V7-ONNX base_model:quantized:TheyCallMeHex/LCM-Dreamshaper-V7-ONNX region:us
↓ 0 ♥ 0

Created: 2025-05-22

Updated: 2025-05-22

View on Hugging Face

Files (40)

.gitattributes
README.md
convert-onnx-to-rknn.py
model/.gitattributes
model/Assets/Icon.png
model/Assets/LCM-Dreamshaper-V7-ONNX.json
model/Assets/OnnxStack - 640x320.png
model/Assets/Preview1.png
model/Assets/Preview2.png
model/Assets/Preview3.png
model/Assets/Preview4.png
model/Assets/Preview5.png
model/Assets/Preview6.png
model/Assets/lcm_angel_30_7.5_2092464983.png
model/Assets/lcm_car_30_7.5_2092464983.png
model/Assets/lcm_demon_30_7.5_2092464983.png
model/Assets/lcm_ninja_30_7.5_2092464983.png
model/README.md
model/feature_extractor/preprocessor_config.json
model/model_index.json
model/scheduler/scheduler_config.json
model/text_encoder/config.json
model/text_encoder/model.onnx ONNX
model/text_encoder/model.rknn
model/tokenizer/merges.txt
model/tokenizer/model.onnx ONNX
model/tokenizer/special_tokens_map.json
model/tokenizer/tokenizer_config.json
model/tokenizer/vocab.json
model/unet/config.json
model/unet/model.onnx ONNX
model/unet/model.onnx_data
model/unet/model.rknn
model/vae_decoder/config.json
model/vae_decoder/model.onnx ONNX
model/vae_decoder/model.rknn
model/vae_encoder/config.json
model/vae_encoder/model.onnx ONNX
run_onnx-lcm.py
run_rknn-lcm.py

Related models