# AI use cases for Stable Diffusion CPP (leejet/stable-diffusion.cpp)

Repo: [leejet/stable-diffusion.cpp](https://github.com/leejet/stable-diffusion.cpp) | Use cases: 3 | Page: https://dedupedai.com/use-cases/leejet-stable-diffusion-cpp/

stable-diffusion.cpp runs diffusion models for images and video in pure C/C++ on top of ggml, the same way llama.cpp runs language models. It supports SD 1.x, SDXL, SD3, FLUX, Qwen Image, Z-Image, Wan and LTX video and many more, with CPU, CUDA, Vulkan, Metal, OpenCL and SYCL backends, GGUF weights, LoRA, ControlNet and ESRGAN upscaling.

This file holds every use case of this repo. Each one starts with a "## " heading and ends with its URL.

- Generate images locally with a single command: https://dedupedai.com/use-cases/leejet-stable-diffusion-cpp/generate-images-locally-with-one-command/
- Run FLUX or Qwen Image on modest hardware with GGUF: https://dedupedai.com/use-cases/leejet-stable-diffusion-cpp/run-newer-image-models-on-modest-hardware/
- Add local image generation to your own app: https://dedupedai.com/use-cases/leejet-stable-diffusion-cpp/add-local-image-generation-to-your-app/

## How to generate images locally with a single command with Stable Diffusion CPP

Repo: [leejet/stable-diffusion.cpp](https://github.com/leejet/stable-diffusion.cpp) | Difficulty: Beginner | Time: 20 minutes | Basis: From the README

Download the sd binary and a model, then make images from a text prompt with no Python setup.

**Who it is for:** A developer or artist who wants local image generation without installing a Python environment or a web UI.

**The problem:** Most local image generators need a big Python install and a GPU setup that breaks easily.

**The outcome:** A PNG generated on your own machine, with the generation settings embedded in the file.

### Steps

1. Download a pre-built sd binary from the releases page, or build it from source with the build guide
2. Download weights, for example `curl -L -O https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors`
3. Generate an image: `./bin/sd-cli -m ../models/v1-5-pruned-emaonly.safetensors -p "a lovely cat"`
4. Check the cli doc for options such as negative prompt, sampling method and seed
5. Open the output PNG; the generation parameters are embedded as webui-compatible text

### Prompt to paste into your agent

```text
Download the latest leejet/stable-diffusion.cpp release for my OS, fetch Stable Diffusion v1.5 weights and generate 4 images of <prompt> with sd-cli, each with a different seed. Save them to <folder> and list the exact commands you ran.
```

### Caveat

The README warns that the API and command-line options change frequently, so check the cli doc for your release.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/leejet-stable-diffusion-cpp/generate-images-locally-with-one-command/

## How to run FLUX or Qwen Image on modest hardware with GGUF with Stable Diffusion CPP

Repo: [leejet/stable-diffusion.cpp](https://github.com/leejet/stable-diffusion.cpp) | Difficulty: Intermediate | Time: 1 hour | Basis: From the README

Use GGUF quantized weights and the right backend so newer image models fit in limited memory.

**Who it is for:** Someone with a mid-range GPU, an Apple Silicon Mac or no GPU who wants to try newer models like FLUX.

**The problem:** Newer image models are huge in full precision and simply do not fit on ordinary machines.

**The outcome:** A newer model generating images locally on the backend your hardware supports.

### Steps

1. Get the sd binary for your backend: CPU, CUDA, Vulkan, Metal, OpenCL or SYCL
2. Follow the docs page for your model, such as FLUX.1-dev/FLUX.1-schnell or Qwen Image, to download the weights it needs
3. Prefer GGUF weights and read the Quantization and GGUF guide to pick a size that fits your memory
4. Use VAE tiling and Flash Attention, both listed features, to cut memory use further
5. Read the performance guide and backend selection guide if generation is slow or runs out of memory

### Prompt to paste into your agent

```text
Help me run <FLUX or Qwen Image> with leejet/stable-diffusion.cpp on my <hardware>. Follow the model's docs page and the Quantization and GGUF guide to choose weights that fit in <memory>, then generate one test image of <prompt> and tell me the time and memory used.
```

### Caveat

Each model needs its own set of files, explained in its docs page rather than the README, so expect some reading.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/leejet-stable-diffusion-cpp/run-newer-image-models-on-modest-hardware/

## How to add local image generation to your own app with Stable Diffusion CPP

Repo: [leejet/stable-diffusion.cpp](https://github.com/leejet/stable-diffusion.cpp) | Difficulty: Advanced | Time: 2 hours | Basis: From the README

Use a Stable Diffusion CPP binding for Python, Go, Rust, C# or Flutter to generate images inside your program.

**Who it is for:** An app developer who wants an image feature that runs on the user's device instead of a paid API.

**The problem:** Calling a hosted image API adds per-image cost and sends user prompts to a third party.

**The outcome:** Your app generating images through a native library with no cloud dependency.

### Steps

1. Pick the binding for your language from the Bindings list, for example stable-diffusion-cpp-python for Python or diffusion-rs for Rust
2. Confirm your model works first with the command line: `./bin/sd-cli -m ../models/v1-5-pruned-emaonly.safetensors -p "a lovely cat"`
3. Follow the binding's own README to load the same weights from your code
4. Add LoRA or ESRGAN upscaling later if you need them; both are listed features
5. Pin the Stable Diffusion CPP version, since the project warns that the API changes frequently

### Prompt to paste into your agent

```text
Add local image generation to my <language> app using the stable-diffusion.cpp binding listed for it in the leejet/stable-diffusion.cpp README. Load <model weights>, expose a generate(prompt) function, and pin the library version.
```

### Caveat

Bindings are third-party projects with their own release pace, so check that the one you pick supports your model.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/leejet-stable-diffusion-cpp/add-local-image-generation-to-your-app/
