Spaces:
Running
Running
readme added
Browse files
README.md
CHANGED
@@ -1,723 +1,13 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
[Adversarial Diffusion Distillation](https://nolowiz.com/fast-stable-diffusion-on-cpu-using-fastsd-cpu-and-openvino/).
|
15 |
-
|
16 |
-

|
17 |
-
The following interfaces are available :
|
18 |
-
|
19 |
-
- Desktop GUI, basic text to image generation (Qt,faster)
|
20 |
-
- WebUI (Advanced features,Lora,controlnet etc)
|
21 |
-
- CLI (CommandLine Interface)
|
22 |
-
|
23 |
-
🚀 Using **OpenVINO(SDXS-512-0.9)**, it took **0.82 seconds** (**820 milliseconds**) to create a single 512x512 image on a **Core i7-12700**.
|
24 |
-
|
25 |
-
## Table of Contents 👇
|
26 |
-
|
27 |
-
- [Supported Platforms](#Supported platforms)
|
28 |
-
- [Dependencies](#dependencies)
|
29 |
-
- [Memory requirements](#memory-requirements)
|
30 |
-
- [Features](#features)
|
31 |
-
- [Benchmarks](#fast-inference-benchmarks)
|
32 |
-
- [OpenVINO Support](#openvino)
|
33 |
-
- [Installation](#installation)
|
34 |
-
- [Real-time text to image (EXPERIMENTAL)](#real-time-text-to-image)
|
35 |
-
- [Models](#models)
|
36 |
-
- [How to use Lora models](#useloramodels)
|
37 |
-
- [How to use controlnet](#usecontrolnet)
|
38 |
-
- [Android](#android)
|
39 |
-
- [Raspberry Pi 4](#raspberry)
|
40 |
-
- [API Support](#apisupport)
|
41 |
-
- [GGUF support (Flux)](#gguf-support)
|
42 |
-
- [AI PC Support - OpenVINO](#ai-pc-support)
|
43 |
-
- [MCP Server Support](#mcpsupport)
|
44 |
-
- [Open WebUI Support](#openwebuisupport)
|
45 |
-
- [License](#license)
|
46 |
-
- [Contributors](#contributors)
|
47 |
-
|
48 |
-
## Supported platforms⚡️
|
49 |
-
|
50 |
-
FastSD CPU works on the following platforms:
|
51 |
-
|
52 |
-
- Windows
|
53 |
-
- Linux
|
54 |
-
- Mac
|
55 |
-
- Android + Termux
|
56 |
-
- Raspberry PI 4
|
57 |
-
|
58 |
-
## Dependencies 📦
|
59 |
-
|
60 |
-
- Python 3.10 or Python 3.11 (Please ensure that you have a working Python 3.10 or Python 3.11 installation available on the system)
|
61 |
-
|
62 |
-
## Memory requirements
|
63 |
-
|
64 |
-
Minimum system RAM requirement for FastSD CPU.
|
65 |
-
|
66 |
-
Model (LCM,OpenVINO): SD Turbo, 1 step, 512 x 512
|
67 |
-
|
68 |
-
Model (LCM-LoRA): Dreamshaper v8, 3 step, 512 x 512
|
69 |
-
|
70 |
-
| Mode | Min RAM |
|
71 |
-
| --------------------- | ------------- |
|
72 |
-
| LCM | 2 GB |
|
73 |
-
| LCM-LoRA | 4 GB |
|
74 |
-
| OpenVINO | 11 GB |
|
75 |
-
|
76 |
-
If we enable Tiny decoder(TAESD) we can save some memory(2GB approx) for example in OpenVINO mode memory usage will become 9GB.
|
77 |
-
|
78 |
-
:exclamation: Please note that guidance scale >1 increases RAM usage and slow inference speed.
|
79 |
-
|
80 |
-
## Features ✨
|
81 |
-
|
82 |
-
- Desktop GUI, web UI and CLI
|
83 |
-
- Supports 256,512,768,1024 image sizes
|
84 |
-
- Supports Windows,Linux,Mac
|
85 |
-
- Saves images and diffusion setting used to generate the image
|
86 |
-
- Settings to control,steps,guidance and seed
|
87 |
-
- Added safety checker setting
|
88 |
-
- Maximum inference steps increased to 25
|
89 |
-
- Added [OpenVINO](https://github.com/openvinotoolkit/openvino) support
|
90 |
-
- Fixed OpenVINO image reproducibility issue
|
91 |
-
- Fixed OpenVINO high RAM usage,thanks [deinferno](https://github.com/deinferno)
|
92 |
-
- Added multiple image generation support
|
93 |
-
- Application settings
|
94 |
-
- Added Tiny Auto Encoder for SD (TAESD) support, 1.4x speed boost (Fast,moderate quality)
|
95 |
-
- Safety checker disabled by default
|
96 |
-
- Added SDXL,SSD1B - 1B LCM models
|
97 |
-
- Added LCM-LoRA support, works well for fine-tuned Stable Diffusion model 1.5 or SDXL models
|
98 |
-
- Added negative prompt support in LCM-LoRA mode
|
99 |
-
- LCM-LoRA models can be configured using text configuration file
|
100 |
-
- Added support for custom models for OpenVINO (LCM-LoRA baked)
|
101 |
-
- OpenVINO models now supports negative prompt (Set guidance >1.0)
|
102 |
-
- Real-time inference support,generates images while you type (experimental)
|
103 |
-
- Fast 2,3 steps inference
|
104 |
-
- Lcm-Lora fused models for faster inference
|
105 |
-
- Supports integrated GPU(iGPU) using OpenVINO (export DEVICE=GPU)
|
106 |
-
- 5.7x speed using OpenVINO(steps: 2,tiny autoencoder)
|
107 |
-
- Image to Image support (Use Web UI)
|
108 |
-
- OpenVINO image to image support
|
109 |
-
- Fast 1 step inference (SDXL Turbo)
|
110 |
-
- Added SD Turbo support
|
111 |
-
- Added image to image support for Turbo models (Pytorch and OpenVINO)
|
112 |
-
- Added image variations support
|
113 |
-
- Added 2x upscaler (EDSR and Tiled SD upscale (experimental)),thanks [monstruosoft](https://github.com/monstruosoft) for SD upscale
|
114 |
-
- Works on Android + Termux + PRoot
|
115 |
-
- Added interactive CLI,thanks [monstruosoft](https://github.com/monstruosoft)
|
116 |
-
- Added basic lora support to CLI and WebUI
|
117 |
-
- ONNX EDSR 2x upscale
|
118 |
-
- Add SDXL-Lightning support
|
119 |
-
- Add SDXL-Lightning OpenVINO support (int8)
|
120 |
-
- Add multilora support,thanks [monstruosoft](https://github.com/monstruosoft)
|
121 |
-
- Add basic ControlNet v1.1 support(LCM-LoRA mode),thanks [monstruosoft](https://github.com/monstruosoft)
|
122 |
-
- Add ControlNet annotators(Canny,Depth,LineArt,MLSD,NormalBAE,Pose,SoftEdge,Shuffle)
|
123 |
-
- Add SDXS-512 0.9 support
|
124 |
-
- Add SDXS-512 0.9 OpenVINO,fast 1 step inference (0.8 seconds to generate 512x512 image)
|
125 |
-
- Default model changed to SDXS-512-0.9
|
126 |
-
- Faster realtime image generation
|
127 |
-
- Add NPU device check
|
128 |
-
- Revert default model to SDTurbo
|
129 |
-
- Update realtime UI
|
130 |
-
- Add hypersd support
|
131 |
-
- 1 step fast inference support for SDXL and SD1.5
|
132 |
-
- Experimental support for single file Safetensors SD 1.5 models(Civitai models), simply add local model path to configs/stable-diffusion-models.txt file.
|
133 |
-
- Add REST API support
|
134 |
-
- Add Aura SR (4x)/GigaGAN based upscaler support
|
135 |
-
- Add Aura SR v2 upscaler support
|
136 |
-
- Add FLUX.1 schnell OpenVINO int 4 support
|
137 |
-
- Add CLIP skip support
|
138 |
-
- Add token merging support
|
139 |
-
- Add Intel AI PC support
|
140 |
-
- AI PC NPU(Power efficient inference using OpenVINO) supports, text to image ,image to image and image variations support
|
141 |
-
- Add [TAEF1 (Tiny autoencoder for FLUX.1) openvino](https://huggingface.co/rupeshs/taef1-openvino) support
|
142 |
-
- Add Image to Image and Image Variations Qt GUI support,thanks [monstruosoft](https://github.com/monstruosoft)
|
143 |
-
|
144 |
-
<a id="fast-inference-benchmarks"></a>
|
145 |
-
|
146 |
-
## Fast Inference Benchmarks
|
147 |
-
|
148 |
-
### 🚀 Fast 1 step inference with Hyper-SD
|
149 |
-
|
150 |
-
#### Stable diffuion 1.5
|
151 |
-
|
152 |
-
Works with LCM-LoRA mode.
|
153 |
-
Fast 1 step inference supported on `runwayml/stable-diffusion-v1-5` model,select `rupeshs/hypersd-sd1-5-1-step-lora` lcm_lora model from the settings.
|
154 |
-
|
155 |
-
#### Stable diffuion XL
|
156 |
-
|
157 |
-
Works with LCM and LCM-OpenVINO mode.
|
158 |
-
|
159 |
-
- *Hyper-SD SDXL 1 step* - [rupeshs/hyper-sd-sdxl-1-step](https://huggingface.co/rupeshs/hyper-sd-sdxl-1-step)
|
160 |
-
|
161 |
-
- *Hyper-SD SDXL 1 step OpenVINO* - [rupeshs/hyper-sd-sdxl-1-step-openvino-int8](https://huggingface.co/rupeshs/hyper-sd-sdxl-1-step-openvino-int8)
|
162 |
-
|
163 |
-
#### Inference Speed
|
164 |
-
|
165 |
-
Tested on Core i7-12700 to generate **768x768** image(1 step).
|
166 |
-
|
167 |
-
| Diffusion Pipeline | Latency |
|
168 |
-
| --------------------- | ------------- |
|
169 |
-
| Pytorch | 19s |
|
170 |
-
| OpenVINO | 13s |
|
171 |
-
| OpenVINO + TAESDXL | 6.3s |
|
172 |
-
|
173 |
-
### Fastest 1 step inference (SDXS-512-0.9)
|
174 |
-
|
175 |
-
:exclamation:This is an experimental model, only text to image workflow is supported.
|
176 |
-
|
177 |
-
#### Inference Speed
|
178 |
-
|
179 |
-
Tested on Core i7-12700 to generate **512x512** image(1 step).
|
180 |
-
|
181 |
-
**SDXS-512-0.9**
|
182 |
-
|
183 |
-
| Diffusion Pipeline | Latency |
|
184 |
-
| --------------------- | ------------- |
|
185 |
-
| Pytorch | 4.8s |
|
186 |
-
| OpenVINO | 3.8s |
|
187 |
-
| OpenVINO + TAESD | **0.82s** |
|
188 |
-
|
189 |
-
### 🚀 Fast 1 step inference (SD/SDXL Turbo - Adversarial Diffusion Distillation,ADD)
|
190 |
-
|
191 |
-
Added support for ultra fast 1 step inference using [sdxl-turbo](https://huggingface.co/stabilityai/sdxl-turbo) model
|
192 |
-
|
193 |
-
:exclamation: These SD turbo models are intended for research purpose only.
|
194 |
-
|
195 |
-
#### Inference Speed
|
196 |
-
|
197 |
-
Tested on Core i7-12700 to generate **512x512** image(1 step).
|
198 |
-
|
199 |
-
**SD Turbo**
|
200 |
-
|
201 |
-
| Diffusion Pipeline | Latency |
|
202 |
-
| --------------------- | ------------- |
|
203 |
-
| Pytorch | 7.8s |
|
204 |
-
| OpenVINO | 5s |
|
205 |
-
| OpenVINO + TAESD | 1.7s |
|
206 |
-
|
207 |
-
**SDXL Turbo**
|
208 |
-
|
209 |
-
| Diffusion Pipeline | Latency |
|
210 |
-
| --------------------- | ------------- |
|
211 |
-
| Pytorch | 10s |
|
212 |
-
| OpenVINO | 5.6s |
|
213 |
-
| OpenVINO + TAESDXL | 2.5s |
|
214 |
-
|
215 |
-
### 🚀 Fast 2 step inference (SDXL-Lightning - Adversarial Diffusion Distillation)
|
216 |
-
|
217 |
-
SDXL-Lightning works with LCM and LCM-OpenVINO mode.You can select these models from app settings.
|
218 |
-
|
219 |
-
Tested on Core i7-12700 to generate **768x768** image(2 steps).
|
220 |
-
|
221 |
-
| Diffusion Pipeline | Latency |
|
222 |
-
| --------------------- | ------------- |
|
223 |
-
| Pytorch | 18s |
|
224 |
-
| OpenVINO | 12s |
|
225 |
-
| OpenVINO + TAESDXL | 10s |
|
226 |
-
|
227 |
-
- *SDXL-Lightning* - [rupeshs/SDXL-Lightning-2steps](https://huggingface.co/rupeshs/SDXL-Lightning-2steps)
|
228 |
-
|
229 |
-
- *SDXL-Lightning OpenVINO* - [rupeshs/SDXL-Lightning-2steps-openvino-int8](https://huggingface.co/rupeshs/SDXL-Lightning-2steps-openvino-int8)
|
230 |
-
|
231 |
-
### 2 Steps fast inference (LCM)
|
232 |
-
|
233 |
-
FastSD CPU supports 2 to 3 steps fast inference using LCM-LoRA workflow. It works well with SD 1.5 models.
|
234 |
-
|
235 |
-

|
236 |
-
|
237 |
-
### FLUX.1-schnell OpenVINO support
|
238 |
-
|
239 |
-

|
240 |
-
|
241 |
-
:exclamation: Important - Please note the following points with FLUX workflow
|
242 |
-
|
243 |
-
- As of now only text to image generation mode is supported
|
244 |
-
- Use OpenVINO mode
|
245 |
-
- Use int4 model - *rupeshs/FLUX.1-schnell-openvino-int4*
|
246 |
-
- 512x512 image generation needs around **30GB** system RAM
|
247 |
-
|
248 |
-
Tested on Intel Core i7-12700 to generate **512x512** image(3 steps).
|
249 |
-
|
250 |
-
| Diffusion Pipeline | Latency |
|
251 |
-
| --------------------- | ------------- |
|
252 |
-
| OpenVINO | 4 min 30sec |
|
253 |
-
|
254 |
-
### Benchmark scripts
|
255 |
-
|
256 |
-
To benchmark run the following batch file on Windows:
|
257 |
-
|
258 |
-
- `benchmark.bat` - To benchmark Pytorch
|
259 |
-
- `benchmark-openvino.bat` - To benchmark OpenVINO
|
260 |
-
|
261 |
-
Alternatively you can run benchmarks by passing `-b` command line argument in CLI mode.
|
262 |
-
<a id="openvino"></a>
|
263 |
-
|
264 |
-
## OpenVINO support
|
265 |
-
|
266 |
-
Fast SD CPU utilizes [OpenVINO](https://www.intel.com/content/www/us/en/developer/tools/openvino-toolkit/overview.html) to speed up the inference speed.
|
267 |
-
Thanks [deinferno](https://github.com/deinferno) for the OpenVINO model contribution.
|
268 |
-
We can get 2x speed improvement when using OpenVINO.
|
269 |
-
Thanks [Disty0](https://github.com/Disty0) for the conversion script.
|
270 |
-
|
271 |
-
### OpenVINO SDXL models
|
272 |
-
|
273 |
-
These are models converted to use directly use it with FastSD CPU. These models are compressed to int8 to reduce the file size (10GB to 4.4 GB) using [NNCF](https://github.com/openvinotoolkit/nncf)
|
274 |
-
|
275 |
-
- Hyper-SD SDXL 1 step - [rupeshs/hyper-sd-sdxl-1-step-openvino-int8](https://huggingface.co/rupeshs/hyper-sd-sdxl-1-step-openvino-int8)
|
276 |
-
- SDXL Lightning 2 steps - [rupeshs/SDXL-Lightning-2steps-openvino-int8](https://huggingface.co/rupeshs/SDXL-Lightning-2steps-openvino-int8)
|
277 |
-
|
278 |
-
### OpenVINO SD Turbo models
|
279 |
-
|
280 |
-
We have converted SD/SDXL Turbo models to OpenVINO for fast inference on CPU. These models are intended for research purpose only. Also we converted TAESDXL MODEL to OpenVINO and
|
281 |
-
|
282 |
-
- *SD Turbo OpenVINO* - [rupeshs/sd-turbo-openvino](https://huggingface.co/rupeshs/sd-turbo-openvino)
|
283 |
-
- *SDXL Turbo OpenVINO int8* - [rupeshs/sdxl-turbo-openvino-int8](https://huggingface.co/rupeshs/sdxl-turbo-openvino-int8)
|
284 |
-
- *TAESDXL OpenVINO* - [rupeshs/taesdxl-openvino](https://huggingface.co/rupeshs/taesdxl-openvino)
|
285 |
-
|
286 |
-
You can directly use these models in FastSD CPU.
|
287 |
-
|
288 |
-
### Convert SD 1.5 models to OpenVINO LCM-LoRA fused models
|
289 |
-
|
290 |
-
We first creates LCM-LoRA baked in model,replaces the scheduler with LCM and then converts it into OpenVINO model. For more details check [LCM OpenVINO Converter](https://github.com/rupeshs/lcm-openvino-converter), you can use this tools to convert any StableDiffusion 1.5 fine tuned models to OpenVINO.
|
291 |
-
|
292 |
-
<a id="real-time-text-to-image"></a>
|
293 |
-
|
294 |
-
## Real-time text to image (EXPERIMENTAL)
|
295 |
-
|
296 |
-
We can generate real-time text to images using FastSD CPU.
|
297 |
-
|
298 |
-
**CPU (OpenVINO)**
|
299 |
-
|
300 |
-
Near real-time inference on CPU using OpenVINO, run the `start-realtime.bat` batch file and open the link in browser (Resolution : 512x512,Latency : 0.82s on Intel Core i7)
|
301 |
-
|
302 |
-
Watch YouTube video :
|
303 |
-
|
304 |
-
[](https://www.youtube.com/watch?v=0XMiLc_vsyI)
|
305 |
-
|
306 |
-
## Models
|
307 |
-
|
308 |
-
To use single file [Safetensors](https://huggingface.co/docs/safetensors/en/index) SD 1.5 models(Civit AI) follow this [YouTube tutorial](https://www.youtube.com/watch?v=zZTfUZnXJVk). Use LCM-LoRA Mode for single file safetensors.
|
309 |
-
|
310 |
-
Fast SD supports LCM models and LCM-LoRA models.
|
311 |
-
|
312 |
-
### LCM Models
|
313 |
-
|
314 |
-
These models can be configured in `configs/lcm-models.txt` file.
|
315 |
-
|
316 |
-
### OpenVINO models
|
317 |
-
|
318 |
-
These are LCM-LoRA baked in models. These models can be configured in `configs/openvino-lcm-models.txt` file
|
319 |
-
|
320 |
-
### LCM-LoRA models
|
321 |
-
|
322 |
-
These models can be configured in `configs/lcm-lora-models.txt` file.
|
323 |
-
|
324 |
-
- *lcm-lora-sdv1-5* - distilled consistency adapter for [runwayml/stable-diffusion-v1-5](https://huggingface.co/runwayml/stable-diffusion-v1-5)
|
325 |
-
- *lcm-lora-sdxl* - Distilled consistency adapter for [stable-diffusion-xl-base-1.0](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0)
|
326 |
-
- *lcm-lora-ssd-1b* - Distilled consistency adapter for [segmind/SSD-1B](https://huggingface.co/segmind/SSD-1B)
|
327 |
-
|
328 |
-
These models are used with Stablediffusion base models `configs/stable-diffusion-models.txt`.
|
329 |
-
|
330 |
-
:exclamation: Currently no support for OpenVINO LCM-LoRA models.
|
331 |
-
|
332 |
-
### How to add new LCM-LoRA models
|
333 |
-
|
334 |
-
To add new model follow the steps:
|
335 |
-
For example we will add `wavymulder/collage-diffusion`, you can give Stable diffusion 1.5 Or SDXL,SSD-1B fine tuned models.
|
336 |
-
|
337 |
-
1. Open `configs/stable-diffusion-models.txt` file in text editor.
|
338 |
-
2. Add the model ID `wavymulder/collage-diffusion` or locally cloned path.
|
339 |
-
|
340 |
-
Updated file as shown below :
|
341 |
-
|
342 |
-
```Lykon/dreamshaper-8
|
343 |
-
Fictiverse/Stable_Diffusion_PaperCut_Model
|
344 |
-
stabilityai/stable-diffusion-xl-base-1.0
|
345 |
-
runwayml/stable-diffusion-v1-5
|
346 |
-
segmind/SSD-1B
|
347 |
-
stablediffusionapi/anything-v5
|
348 |
-
wavymulder/collage-diffusion
|
349 |
-
```
|
350 |
-
|
351 |
-
Similarly we can update `configs/lcm-lora-models.txt` file with lcm-lora ID.
|
352 |
-
|
353 |
-
### How to use LCM-LoRA models offline
|
354 |
-
|
355 |
-
Please follow the steps to run LCM-LoRA models offline :
|
356 |
-
|
357 |
-
- In the settings ensure that "Use locally cached model" setting is ticked.
|
358 |
-
- Download the model for example `latent-consistency/lcm-lora-sdv1-5`
|
359 |
-
Run the following commands:
|
360 |
-
|
361 |
-
```
|
362 |
-
git lfs install
|
363 |
-
git clone https://huggingface.co/latent-consistency/lcm-lora-sdv1-5
|
364 |
-
```
|
365 |
-
|
366 |
-
Copy the cloned model folder path for example "D:\demo\lcm-lora-sdv1-5" and update the `configs/lcm-lora-models.txt` file as shown below :
|
367 |
-
|
368 |
-
```
|
369 |
-
D:\demo\lcm-lora-sdv1-5
|
370 |
-
latent-consistency/lcm-lora-sdxl
|
371 |
-
latent-consistency/lcm-lora-ssd-1b
|
372 |
-
```
|
373 |
-
|
374 |
-
- Open the app and select the newly added local folder in the combo box menu.
|
375 |
-
- That's all!
|
376 |
-
<a id="useloramodels"></a>
|
377 |
-
|
378 |
-
## How to use Lora models
|
379 |
-
|
380 |
-
Place your lora models in "lora_models" folder. Use LCM or LCM-Lora mode.
|
381 |
-
You can download lora model (.safetensors/Safetensor) from [Civitai](https://civitai.com/) or [Hugging Face](https://huggingface.co/)
|
382 |
-
E.g: [cutecartoonredmond](https://civitai.com/models/207984/cutecartoonredmond-15v-cute-cartoon-lora-for-liberteredmond-sd-15?modelVersionId=234192)
|
383 |
-
<a id="usecontrolnet"></a>
|
384 |
-
|
385 |
-
## ControlNet support
|
386 |
-
|
387 |
-
We can use ControlNet in LCM-LoRA mode.
|
388 |
-
|
389 |
-
Download ControlNet models from [ControlNet-v1-1](https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/tree/main).Download and place controlnet models in "controlnet_models" folder.
|
390 |
-
|
391 |
-
Use the medium size models (723 MB)(For example : <https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/blob/main/control_v11p_sd15_canny_fp16.safetensors>)
|
392 |
-
|
393 |
-
## Installation
|
394 |
-
|
395 |
-
### FastSD CPU on Windows
|
396 |
-
|
397 |
-

|
398 |
-
|
399 |
-
:exclamation:**You must have a working Python installation.(Recommended : Python 3.10 or 3.11 )**
|
400 |
-
|
401 |
-
To install FastSD CPU on Windows run the following steps :
|
402 |
-
|
403 |
-
- Clone/download this repo or download [release](https://github.com/rupeshs/fastsdcpu/releases).
|
404 |
-
- Double click `install.bat` (It will take some time to install,depending on your internet speed.)
|
405 |
-
- You can run in desktop GUI mode or web UI mode.
|
406 |
-
|
407 |
-
#### Desktop GUI
|
408 |
-
|
409 |
-
- To start desktop GUI double click `start.bat`
|
410 |
-
|
411 |
-
#### Web UI
|
412 |
-
|
413 |
-
- To start web UI double click `start-webui.bat`
|
414 |
-
|
415 |
-
### FastSD CPU on Linux
|
416 |
-
|
417 |
-
:exclamation:**Ensure that you have Python 3.9 or 3.10 or 3.11 version installed.**
|
418 |
-
|
419 |
-
- Clone/download this repo or download [release](https://github.com/rupeshs/fastsdcpu/releases).
|
420 |
-
- In the terminal, enter into fastsdcpu directory
|
421 |
-
- Run the following command
|
422 |
-
|
423 |
-
`chmod +x install.sh`
|
424 |
-
|
425 |
-
`./install.sh`
|
426 |
-
|
427 |
-
#### To start Desktop GUI
|
428 |
-
|
429 |
-
`./start.sh`
|
430 |
-
|
431 |
-
#### To start Web UI
|
432 |
-
|
433 |
-
`./start-webui.sh`
|
434 |
-
|
435 |
-
### FastSD CPU on Mac
|
436 |
-
|
437 |
-

|
438 |
-
|
439 |
-
:exclamation:**Ensure that you have Python 3.9 or 3.10 or 3.11 version installed.**
|
440 |
-
|
441 |
-
Run the following commands to install FastSD CPU on Mac :
|
442 |
-
|
443 |
-
- Clone/download this repo or download [release](https://github.com/rupeshs/fastsdcpu/releases).
|
444 |
-
- In the terminal, enter into fastsdcpu directory
|
445 |
-
- Run the following command
|
446 |
-
|
447 |
-
`chmod +x install-mac.sh`
|
448 |
-
|
449 |
-
`./install-mac.sh`
|
450 |
-
|
451 |
-
#### To start Desktop GUI
|
452 |
-
|
453 |
-
`./start.sh`
|
454 |
-
|
455 |
-
#### To start Web UI
|
456 |
-
|
457 |
-
`./start-webui.sh`
|
458 |
-
|
459 |
-
Thanks [Autantpourmoi](https://github.com/Autantpourmoi) for Mac testing.
|
460 |
-
|
461 |
-
:exclamation:We don't support OpenVINO on Mac (M1/M2/M3 chips, but *does* work on Intel chips).
|
462 |
-
|
463 |
-
If you want to increase image generation speed on Mac(M1/M2 chip) try this:
|
464 |
-
|
465 |
-
`export DEVICE=mps` and start app `start.sh`
|
466 |
-
|
467 |
-
#### Web UI screenshot
|
468 |
-
|
469 |
-

|
470 |
-
|
471 |
-
### Google Colab
|
472 |
-
|
473 |
-
Due to the limitation of using CPU/OpenVINO inside colab, we are using GPU with colab.
|
474 |
-
[](https://colab.research.google.com/drive/1SuAqskB-_gjWLYNRFENAkIXZ1aoyINqL?usp=sharing)
|
475 |
-
|
476 |
-
### CLI mode (Advanced users)
|
477 |
-
|
478 |
-

|
479 |
-
|
480 |
-
Open the terminal and enter into fastsdcpu folder.
|
481 |
-
Activate virtual environment using the command:
|
482 |
-
|
483 |
-
##### Windows users
|
484 |
-
|
485 |
-
(Suppose FastSD CPU available in the directory "D:\fastsdcpu")
|
486 |
-
`D:\fastsdcpu\env\Scripts\activate.bat`
|
487 |
-
|
488 |
-
##### Linux users
|
489 |
-
|
490 |
-
`source env/bin/activate`
|
491 |
-
|
492 |
-
Start CLI `src/app.py -h`
|
493 |
-
|
494 |
-
<a id="android"></a>
|
495 |
-
|
496 |
-
## Android (Termux + PRoot)
|
497 |
-
|
498 |
-
FastSD CPU running on Google Pixel 7 Pro.
|
499 |
-
|
500 |
-

|
501 |
-
|
502 |
-
### Install FastSD CPU on Android
|
503 |
-
|
504 |
-
Follow this guide to install FastSD CPU on Android + Termux [How To Install and Run FastSD CPU on Android + Temux – Step By Step Guide [Updated]](https://nolowiz.com/how-to-install-and-run-fastsd-cpu-on-android-temux-step-by-step-guide/)
|
505 |
-
|
506 |
-
<a id="raspberry"></a>
|
507 |
-
|
508 |
-
## Raspberry PI 4 support
|
509 |
-
|
510 |
-
Thanks [WGNW_MGM] for Raspberry PI 4 testing.FastSD CPU worked without problems.
|
511 |
-
System configuration - Raspberry Pi 4 with 4GB RAM, 8GB of SWAP memory.
|
512 |
-
|
513 |
-
<a id="apisupport"></a>
|
514 |
-
|
515 |
-
## API support
|
516 |
-
|
517 |
-

|
518 |
-
|
519 |
-
FastSD CPU supports basic API endpoints. Following API endpoints are available :
|
520 |
-
|
521 |
-
- /api/info - To get system information
|
522 |
-
- /api/config - Get configuration
|
523 |
-
- /api/models - List all available models
|
524 |
-
- /api/generate - Generate images (Text to image,image to image)
|
525 |
-
|
526 |
-
To start FastAPI in webserver mode run:
|
527 |
-
``python src/app.py --api``
|
528 |
-
|
529 |
-
or use `start-webserver.sh` for Linux and `start-webserver.bat` for Windows.
|
530 |
-
|
531 |
-
Access API documentation locally at <http://localhost:8000/api/docs> .
|
532 |
-
|
533 |
-
Generated image is JPEG image encoded as base64 string.
|
534 |
-
In the image-to-image mode input image should be encoded as base64 string.
|
535 |
-
|
536 |
-
To generate an image a minimal request `POST /api/generate` with body :
|
537 |
-
|
538 |
-
```
|
539 |
-
{
|
540 |
-
"prompt": "a cute cat",
|
541 |
-
"use_openvino": true
|
542 |
-
}
|
543 |
-
```
|
544 |
-
|
545 |
-
<a id="gguf-support"></a>
|
546 |
-
|
547 |
-
## GGUF support - Flux
|
548 |
-
|
549 |
-
[GGUF](https://github.com/ggerganov/ggml/blob/master/docs/gguf.md) Flux model supported via [stablediffusion.cpp](https://github.com/leejet/stable-diffusion.cpp) shared library. Currently Flux Schenell model supported.
|
550 |
-
|
551 |
-
To use GGUF model use web UI and select GGUF mode.
|
552 |
-
|
553 |
-
Tested on Windows and Linux.
|
554 |
-
|
555 |
-
:exclamation: Main advantage here we reduced minimum system RAM required for Flux workflow to around **12 GB**.
|
556 |
-
|
557 |
-
Supported mode - Text to image
|
558 |
-
|
559 |
-
### How to run Flux GGUF model
|
560 |
-
|
561 |
-
- Download stablediffusion.cpp prebuilt shared library and place it inside fastsdcpu folder
|
562 |
-
For Windows users, download [stable-diffusion.dll](https://huggingface.co/rupeshs/FastSD-Flux-GGUF/blob/main/stable-diffusion.dll)
|
563 |
-
|
564 |
-
For Linux users download [libstable-diffusion.so](https://huggingface.co/rupeshs/FastSD-Flux-GGUF/blob/main/libstable-diffusion.so)
|
565 |
-
|
566 |
-
You can also build the library manully by following the guide *"Build stablediffusion.cpp shared library for GGUF flux model support"*
|
567 |
-
|
568 |
-
- Download **diffusion model** from [flux1-schnell-q4_0.gguf](https://huggingface.co/rupeshs/FastSD-Flux-GGUF/blob/main/flux1-schnell-q4_0.gguf) and place it inside `models/gguf/diffusion` directory
|
569 |
-
- Download **clip model** from [clip_l_q4_0.gguf](https://huggingface.co/rupeshs/FastSD-Flux-GGUF/blob/main/clip_l_q4_0.gguf) and place it inside `models/gguf/clip` directory
|
570 |
-
- Download **T5-XXL model** from [t5xxl_q4_0.gguf](https://huggingface.co/rupeshs/FastSD-Flux-GGUF/blob/main/t5xxl_q4_0.gguf) and place it inside `models/gguf/t5xxl` directory
|
571 |
-
- Download **VAE model** from [ae.safetensors](https://huggingface.co/black-forest-labs/FLUX.1-schnell/blob/main/ae.safetensors) and place it inside `models/gguf/vae` directory
|
572 |
-
- Start web UI and select GGUF mode
|
573 |
-
- Select the models settings tab and select GGUF diffusion,clip_l,t5xxl and VAE models.
|
574 |
-
- Enter your prompt and generate image
|
575 |
-
|
576 |
-
### Build stablediffusion.cpp shared library for GGUF flux model support(Optional)
|
577 |
-
|
578 |
-
To build the stablediffusion.cpp library follow these steps
|
579 |
-
|
580 |
-
- `git clone https://github.com/leejet/stable-diffusion.cpp`
|
581 |
-
- `cd stable-diffusion.cpp`
|
582 |
-
- `git pull origin master`
|
583 |
-
- `git submodule init`
|
584 |
-
- `git submodule update`
|
585 |
-
- `git checkout 14206fd48832ab600d9db75f15acb5062ae2c296`
|
586 |
-
- `cmake . -DSD_BUILD_SHARED_LIBS=ON`
|
587 |
-
- `cmake --build . --config Release`
|
588 |
-
- Copy the stablediffusion dll/so file to fastsdcpu folder
|
589 |
-
|
590 |
-
<a id="ai-pc-support"></a>
|
591 |
-
|
592 |
-
## Intel AI PC support - OpenVINO (CPU, GPU, NPU)
|
593 |
-
|
594 |
-
Fast SD now supports AI PC with Intel® Core™ Ultra Processors. [To learn more about AI PC and OpenVINO](https://nolowiz.com/ai-pc-and-openvino-quick-and-simple-guide/).
|
595 |
-
|
596 |
-
### GPU
|
597 |
-
|
598 |
-
For GPU mode `set device=GPU` and run webui. FastSD GPU benchmark on AI PC as shown below.
|
599 |
-
|
600 |
-

|
601 |
-
|
602 |
-
### NPU
|
603 |
-
|
604 |
-
FastSD CPU now supports power efficient NPU (Neural Processing Unit) that comes with Intel Core Ultra processors.
|
605 |
-
|
606 |
-
FastSD tested with following Intel processor's NPUs:
|
607 |
-
|
608 |
-
- Intel Core Ultra Series 1 (Meteor Lake)
|
609 |
-
- Intel Core Ultra Series 2 (Lunar Lake)
|
610 |
-
|
611 |
-
Currently FastSD support this model for NPU [rupeshs/sd15-lcm-square-openvino-int8](https://huggingface.co/rupeshs/sd15-lcm-square-openvino-int8).
|
612 |
-
|
613 |
-
Supports following modes on NPU :
|
614 |
-
|
615 |
-
- Text to image
|
616 |
-
- Image to image
|
617 |
-
- Image variations
|
618 |
-
|
619 |
-
To run model in NPU follow these steps (Please make sure that your AI PC's NPU driver is the latest):
|
620 |
-
|
621 |
-
- Start webui
|
622 |
-
- Select LCM-OpenVINO mode
|
623 |
-
- Select the models settings tab and select OpenVINO model `rupeshs/sd15-lcm-square-openvino-int8`
|
624 |
-
- Set device envionment variable `set DEVICE=NPU`
|
625 |
-
- Now it will run on the NPU
|
626 |
-
|
627 |
-
This is heterogeneous computing since text encoder and Unet will use NPU and VAE will use GPU for processing. Thanks to OpenVINO.
|
628 |
-
|
629 |
-
Please note that tiny auto encoder will not work in NPU mode.
|
630 |
-
|
631 |
-
*Thanks to Intel for providing AI PC dev kit and Tiber cloud access to test FastSD, special thanks to [Pooja Baraskar](https://github.com/Pooja-B),[Dmitriy Pastushenkov](https://github.com/DimaPastushenkov).*
|
632 |
-
|
633 |
-
<a id="mcpsupport"></a>
|
634 |
-
|
635 |
-
## MCP Server Support
|
636 |
-
|
637 |
-
FastSDCPU now supports [MCP(Model Context Protocol)](https://modelcontextprotocol.io/introduction) server.
|
638 |
-
|
639 |
-
To start FastAPI in MCP server mode run:
|
640 |
-
``python src/app.py --mcp``
|
641 |
-
|
642 |
-
or use `start-mcpserver.sh` for Linux and `start-mcpserver.bat` for Windows.
|
643 |
-
|
644 |
-
FastSDCPU MCP server will be running at <http://127.0.0.1:8000/mcp>
|
645 |
-
|
646 |
-
It can be used with AI apps that support MCP protocol for example [Claude desktop](https://claude.ai/download)
|
647 |
-
|
648 |
-
Note: OpenWebUI not directly using MCP protocol it is based on OpenAPI protocol.
|
649 |
-
|
650 |
-
### Claude desktop
|
651 |
-
|
652 |
-
To connect with FastSD MCP server first configure Claude desktop :
|
653 |
-
|
654 |
-
- First configure Claude desktop,open File - >Settings -> Developer - Edit config
|
655 |
-
- Add below config(Also ensure that node.js installed on your machine)
|
656 |
-
|
657 |
-
```json
|
658 |
-
{
|
659 |
-
"mcpServers": {
|
660 |
-
"fastsdcpu": {
|
661 |
-
"command": "npx",
|
662 |
-
"args": [
|
663 |
-
"mcp-remote",
|
664 |
-
"http://127.0.0.1:8000/mcp"
|
665 |
-
]
|
666 |
-
}
|
667 |
-
}
|
668 |
-
}
|
669 |
-
```
|
670 |
-
|
671 |
-
- Restart Claude desktop
|
672 |
-
- Give a sample prompt to generate image "create image of a cat"
|
673 |
-
|
674 |
-
Screenshot of Claude desktop accessing **Intel AI PC NPU** to generate an image using the FastSD MCP server
|
675 |
-
|
676 |
-

|
677 |
-
|
678 |
-
<a id="openwebuisupport"></a>
|
679 |
-
|
680 |
-
## Open WebUI Support
|
681 |
-
|
682 |
-
The FastSDCPU can be used with [OpenWebUI](https://github.com/open-webui/open-webui) for local image generation using LLM and tool calling.
|
683 |
-
|
684 |
-
Follow the below steps to FastSD to use with Open WebUI.
|
685 |
-
|
686 |
-
- First start FastAPI in MCP server:
|
687 |
-
``python src/app.py --mcp``
|
688 |
-
|
689 |
-
or use `start-mcpserver.sh` for Linux and `start-mcpserver.bat` for Windows.
|
690 |
-
|
691 |
-
- Update server URL in the settings page as shown below
|
692 |
-
|
693 |
-

|
694 |
-
|
695 |
-
- Change chat controls setting "Function Calling" to "Native"
|
696 |
-
|
697 |
-
- Generate image using text prompt (Qwen 2.5 7B model used for the demo)
|
698 |
-
|
699 |
-

|
700 |
-
|
701 |
-
## Known issues
|
702 |
-
|
703 |
-
- TAESD will not work with OpenVINO image to image workflow
|
704 |
-
|
705 |
-
## License
|
706 |
-
|
707 |
-
The fastsdcpu project is available as open source under the terms of the [MIT license](https://github.com/rupeshs/fastsdcpu/blob/main/LICENSE)
|
708 |
-
|
709 |
-
## Disclaimer
|
710 |
-
|
711 |
-
Users are granted the freedom to create images using this tool, but they are obligated to comply with local laws and utilize it responsibly. The developers will not assume any responsibility for potential misuse by users.
|
712 |
-
|
713 |
-
<a id="contributors"></a>
|
714 |
-
|
715 |
-
## Thanks to all our contributors
|
716 |
-
|
717 |
-
Original Author & Maintainer - [Rupesh Sreeraman](https://github.com/rupeshs)
|
718 |
-
|
719 |
-
We thank all contributors for their time and hard work!
|
720 |
-
|
721 |
-
<a href="https://github.com/rupeshs/fastsdcpu/graphs/contributors">
|
722 |
-
<img src="https://contrib.rocks/image?repo=rupeshs/fastsdcpu" />
|
723 |
-
</a>
|
|
|
1 |
+
---
|
2 |
+
title: Fastsdcpu
|
3 |
+
emoji: 📉
|
4 |
+
colorFrom: blue
|
5 |
+
colorTo: blue
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 3.50.2
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
license: mit
|
11 |
+
---
|
12 |
+
|
13 |
+
Check out the configuration reference at <https://huggingface.co/docs/hub/spaces-config-reference>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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