explaingit

leejet/stable-diffusion.cpp

5,997C++Audience · developerComplexity · 4/5Setup · moderate

TLDR

A dependency-free C++ tool for generating images from text prompts on your own hardware, supporting Nvidia, Apple Silicon, AMD, and CPU, no cloud API key needed.

Mindmap

mindmap
  root((stable-diffusion.cpp))
    What it does
      Text to image
      Image upscaling
      Guided composition
    Hardware support
      CUDA for Nvidia
      Metal for Apple
      Vulkan and OpenCL
      CPU fallback
    Supported models
      SD 1.x and 2.x
      Stable Diffusion XL
      FLUX series
      Wan video models
    Features
      ControlNet
      LoRA weights
      Web UI included
    Wrappers
      Python
      Go and Rust
      C# and Flutter
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Generate images from text prompts entirely on your own computer without paying for a cloud API

USE CASE 2

Run Stable Diffusion XL or FLUX models on an Apple Silicon Mac using Metal acceleration

USE CASE 3

Build a Python or Go app that generates images by calling this project's C library

USE CASE 4

Use ControlNet to guide the composition of a generated image by providing a reference sketch or pose

Tech stack

C++CCUDAMetalVulkanOpenCL

Getting it running

Difficulty · moderate Time to first run · 1h+

Requires downloading large model checkpoint files (several GB each) and selecting the right build flag for your GPU or CPU target.

License terms not specified in the explanation, check the repository directly.

In plain English

stable-diffusion.cpp is a tool for running AI image-generation models on your own computer, written in C and C++. The name follows the pattern of llama.cpp, a widely known project that brought large language models to personal hardware. This project does the same thing but for diffusion models: the kind of AI systems that turn a text prompt into an image (or, for some models, a short video clip). The main draw is that it runs with no external software dependencies and works on a wide range of hardware. You can run it on a regular CPU or take advantage of a graphics card via CUDA (for Nvidia), Metal (for Apple Silicon), Vulkan, or OpenCL. The project supports many popular model families: Stable Diffusion 1.x, 2.x, XL, the FLUX series, Wan video models, Qwen Image, Z-Image, and others. Models can be loaded in several file formats including .safetensors and the compressed .gguf format, which can reduce memory usage. Using it is straightforward once you have the binary and a model file. You run a command-line tool, point it at your model, pass a text prompt, and it writes an image to disk. The project also ships an embedded web interface for those who prefer a browser-based view over the command line. Beyond basic text-to-image, the project supports ControlNet (which lets you guide composition using a reference image), LoRA fine-tuned models (small extra weights that adjust a model's style or subject), and image upscaling via ESRGAN. There are also several sampling methods available, which affect the quality and speed trade-off during generation. Third-party wrappers exist for Go, Python, Rust, C#, and Flutter, so developers who want to build applications on top of stable-diffusion.cpp can work in their preferred language rather than calling C code directly.

Copy-paste prompts

Prompt 1
I want to run stable-diffusion.cpp on my Apple Silicon Mac to generate images using Metal. Walk me through downloading a FLUX model in .gguf format and running the CLI command to generate an image from a text prompt.
Prompt 2
How do I apply a LoRA fine-tuned weight file on top of a base Stable Diffusion XL checkpoint using stable-diffusion.cpp? Show me the CLI flags.
Prompt 3
I want to build a Python script that calls stable-diffusion.cpp to generate images. Which Python wrapper should I use and how do I install it and make a basic text-to-image call?
Prompt 4
Show me how to use ControlNet with stable-diffusion.cpp to generate an image guided by a reference pose image, what flags do I pass and what ControlNet model file do I need?
Prompt 5
How do I use the built-in web UI in stable-diffusion.cpp instead of the command line? What command starts the server and what port does it listen on?
Open on GitHub → Explain another repo

← leejet on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.