Go to file
2025-10-17 21:46:39 +08:00
.github chore: add github issue template 2025-10-16 21:04:41 +08:00
assets feat: add Qwen Image Edit support (#877) 2025-10-13 23:17:18 +08:00
docs docs: split README sections (build, performance, etc.) into separate docs 2025-10-16 23:22:06 +08:00
examples docs: split README sections (build, performance, etc.) into separate docs 2025-10-16 23:22:06 +08:00
ggml@c538174d26 sync: update ggml 2025-10-17 21:46:39 +08:00
thirdparty feat: add wan2.1/2.2 support (#778) 2025-09-06 18:08:03 +08:00
.clang-format style: format code 2024-01-29 23:05:18 +08:00
.dockerignore chore: add sd Dockerfile 2023-08-22 22:14:20 +08:00
.gitignore chore: add install() support in CMakeLists.txt (#540) 2025-09-11 22:24:16 +08:00
.gitmodules feat: add wan2.1/2.2 support (#778) 2025-09-06 18:08:03 +08:00
clip.hpp feat: add Qwen Image support (#851) 2025-10-12 23:23:19 +08:00
CMakeLists.txt chore: allow building ggml as a separate shared lib (#468) 2025-10-15 22:10:26 +08:00
common.hpp feat: add Qwen Image support (#851) 2025-10-12 23:23:19 +08:00
conditioner.hpp fix: resolve precision issues in SDXL VAE under fp16 (#888) 2025-10-15 23:01:00 +08:00
control.hpp fix: tensor loading thread count (#854) 2025-09-25 00:26:38 +08:00
denoiser.hpp refactor: simplify DPM++ (2S) Ancestral (#667) 2025-09-16 23:05:25 +08:00
diffusion_model.hpp feat: add Qwen Image Edit support (#877) 2025-10-13 23:17:18 +08:00
Dockerfile chore: fix dockerfile libgomp1 dependency + improvements (#852) 2025-10-11 00:17:45 +08:00
Dockerfile.musa feat: upgrade musa sdk to rc4.2.0 (#732) 2025-07-28 21:51:11 +08:00
Dockerfile.sycl feat: Add SYCL Dockerfile (#651) 2025-09-14 13:02:59 +08:00
esrgan.hpp feat: add support for more esrgan models & x2 & x1 models (#855) 2025-10-12 22:53:31 +08:00
face_detect.py feat: add PhotoMaker Version 2 support (#358) 2024-11-23 11:50:14 +08:00
flux.hpp feat: add Qwen Image Edit support (#877) 2025-10-13 23:17:18 +08:00
format-code.sh feat: add wan2.1/2.2 support (#778) 2025-09-06 18:08:03 +08:00
ggml_extend.hpp fix: resolve precision issues in SDXL VAE under fp16 (#888) 2025-10-15 23:01:00 +08:00
gguf_reader.hpp feat: add wan2.1/2.2 support (#778) 2025-09-06 18:08:03 +08:00
gits_noise.inl fix: clang complains about needless braces (#618) 2025-03-09 12:26:41 +08:00
LICENSE Initial commit 2023-08-13 16:00:22 +08:00
lora.hpp fix: tensor loading thread count (#854) 2025-09-25 00:26:38 +08:00
ltxv.hpp feat: add wan2.1/2.2 support (#778) 2025-09-06 18:08:03 +08:00
mmdit.hpp feat: add sd3 flash attn support (#815) 2025-09-11 23:24:29 +08:00
model.cpp feat: add Qwen Image Edit support (#877) 2025-10-13 23:17:18 +08:00
model.h feat: add Qwen Image support (#851) 2025-10-12 23:23:19 +08:00
pmid.hpp fix: tensor loading thread count (#854) 2025-09-25 00:26:38 +08:00
preprocessing.hpp fix: correct canny preprocessor (#861) 2025-10-13 22:02:35 +08:00
qwen_image.hpp fix: resolve precision issues in SDXL VAE under fp16 (#888) 2025-10-15 23:01:00 +08:00
qwenvl.hpp feat: add Qwen Image Edit support (#877) 2025-10-13 23:17:18 +08:00
README.md docs: split README sections (build, performance, etc.) into separate docs 2025-10-16 23:22:06 +08:00
rng_philox.hpp refactor: reorganize code and use c api (#133) 2024-01-01 16:22:18 +08:00
rng.hpp refactor: reorganize code and use c api (#133) 2024-01-01 16:22:18 +08:00
rope.hpp feat: add Qwen Image Edit support (#877) 2025-10-13 23:17:18 +08:00
stable-diffusion.cpp fix: resolve precision issues in SDXL VAE under fp16 (#888) 2025-10-15 23:01:00 +08:00
stable-diffusion.h fix: resolve precision issues in SDXL VAE under fp16 (#888) 2025-10-15 23:01:00 +08:00
t5.hpp fix: avoid generating black images when running T5 on the GPU (#882) 2025-10-13 00:01:06 +08:00
tae.hpp fix: tensor loading thread count (#854) 2025-09-25 00:26:38 +08:00
tokenize_util.cpp feat: add Qwen Image support (#851) 2025-10-12 23:23:19 +08:00
tokenize_util.h feat: add Qwen Image support (#851) 2025-10-12 23:23:19 +08:00
unet.hpp fix: add flash attn support check (#803) 2025-09-07 21:29:06 +08:00
upscaler.cpp feat: add support for more esrgan models & x2 & x1 models (#855) 2025-10-12 22:53:31 +08:00
util.cpp feat: add Qwen Image Edit support (#877) 2025-10-13 23:17:18 +08:00
util.h feat: add Qwen Image Edit support (#877) 2025-10-13 23:17:18 +08:00
vae.hpp fix: resolve precision issues in SDXL VAE under fp16 (#888) 2025-10-15 23:01:00 +08:00
vocab_qwen.hpp feat: add Qwen Image support (#851) 2025-10-12 23:23:19 +08:00
vocab_umt5.hpp feat: add wan2.1/2.2 support (#778) 2025-09-06 18:08:03 +08:00
vocab.hpp feat: add sd3 support (#298) 2024-07-28 15:44:08 +08:00
wan.hpp feat: add Qwen Image Edit support (#877) 2025-10-13 23:17:18 +08:00

stable-diffusion.cpp

leejet%2Fstable-diffusion.cpp | Trendshift

Diffusion model(SD,Flux,Wan,...) inference in pure C/C++

Note that this project is under active development.
API and command-line option may change frequently.

🔥Important News

  • 2025/10/13 🚀 stable-diffusion.cpp now supports Qwen-Image-Edit / Qwen-Image-Edit 2509
    👉 Details: PR #877

  • 2025/10/12 🚀 stable-diffusion.cpp now supports Qwen-Image
    👉 Details: PR #851

  • 2025/09/14 🚀 stable-diffusion.cpp now supports Wan2.1 Vace
    👉 Details: PR #819

  • 2025/09/06 🚀 stable-diffusion.cpp now supports Wan2.1 / Wan2.2
    👉 Details: PR #778

Features

  • Plain C/C++ implementation based on ggml, working in the same way as llama.cpp
  • Super lightweight and without external dependencies
  • Supported models
  • Supported backends
    • CPU (AVX, AVX2 and AVX512 support for x86 architectures)
    • CUDA
    • Vulkan
    • Metal
    • OpenCL
    • SYCL
  • Supported weight formats
    • Pytorch checkpoint (.ckpt or .pth)
    • Safetensors (./safetensors)
    • GGUF (.gguf)
  • Supported platforms
  • Flash Attention for memory usage optimization
  • Negative prompt
  • stable-diffusion-webui style tokenizer (not all the features, only token weighting for now)
  • VAE tiling processing for reduce memory usage
  • Sampling method
  • Cross-platform reproducibility (--rng cuda, consistent with the stable-diffusion-webui GPU RNG)
  • Embedds generation parameters into png output as webui-compatible text string

Quick Start

Get the sd executable

Download model weights

Generate an image with just one command

./bin/sd -m ../models/v1-5-pruned-emaonly.safetensors -p "a lovely cat"

For detailed command-line arguments, check out cli doc.

Performance

If you want to improve performance or reduce VRAM/RAM usage, please refer to performance guide.

Bindings

These projects wrap stable-diffusion.cpp for easier use in other languages/frameworks.

UIs

These projects use stable-diffusion.cpp as a backend for their image generation.

Contributors

Thank you to all the people who have already contributed to stable-diffusion.cpp!

Contributors

Star History

Star History Chart

References