Meismaxandmaxisme commited on
Commit
0d78592
·
verified ·
1 Parent(s): f8e2815

Upload 2 files

Browse files
Files changed (2) hide show
  1. Readme.md +731 -0
  2. requirements.txt +22 -0
Readme.md ADDED
@@ -0,0 +1,731 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # FastSD CPU :sparkles:[![Mentioned in Awesome OpenVINO](https://awesome.re/mentioned-badge-flat.svg)](https://github.com/openvinotoolkit/awesome-openvino)
2
+
3
+ <div align="center">
4
+ <a href="https://trendshift.io/repositories/3957" target="_blank"><img src="https://trendshift.io/api/badge/repositories/3957" alt="rupeshs%2Ffastsdcpu | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
5
+ </div>
6
+
7
+ FastSD CPU is a faster version of Stable Diffusion on CPU. Based on [Latent Consistency Models](https://github.com/luosiallen/latent-consistency-model) and
8
+ [Adversarial Diffusion Distillation](https://nolowiz.com/fast-stable-diffusion-on-cpu-using-fastsd-cpu-and-openvino/).
9
+
10
+ ![FastSD CPU screenshot](https://raw.githubusercontent.com/rupeshs/fastsdcpu/main/docs/images/fastsdcpu-webui.png)
11
+ The following interfaces are available :
12
+
13
+ - Desktop GUI, basic text to image generation (Qt,faster)
14
+ - WebUI (Advanced features,Lora,controlnet etc)
15
+ - CLI (CommandLine Interface)
16
+
17
+ 🚀 Using **OpenVINO(SDXS-512-0.9)**, it took **0.82 seconds** (**820 milliseconds**) to create a single 512x512 image on a **Core i7-12700**.
18
+
19
+ ## 📰 News
20
+
21
+ - **2025-05-17** - Added SANA Sprint(OpenVINO) support,Tiny AutoEncoder 1.3(Mocha Croissant) support
22
+ - **2025-04-20** - Added MCP server support,faster uv based installation,Cluade desktop, Open WebUI support
23
+ - **2024-11-03** - Added Intel Core Ultra Series 2 (Lunar Lake) NPU support
24
+ - **2024-10-02** - Added GGUF diffusion model(Flux) support
25
+ - **2024-09-03** – Added Intel AI PC GPU, NPU support 🚀
26
+
27
+ ## Table of Contents 👇
28
+
29
+ - [Supported&nbsp;Platforms](#Supported&nbsp;platforms)
30
+ - [Dependencies](#dependencies)
31
+ - [Memory requirements](#memory-requirements)
32
+ - [Features](#features)
33
+ - [Benchmarks](#fast-inference-benchmarks)
34
+ - [OpenVINO Support](#openvino)
35
+ - [Installation](#installation)
36
+ - [Real-time text to image (EXPERIMENTAL)](#real-time-text-to-image)
37
+ - [Models](#models)
38
+ - [How to use Lora models](#useloramodels)
39
+ - [How to use controlnet](#usecontrolnet)
40
+ - [Android + Termux](#android)
41
+ - [Raspberry Pi 4](#raspberry)
42
+ - [API&nbsp;Support](#apisupport)
43
+ - [GGUF support (Flux)](#gguf-support)
44
+ - [AI PC Support - OpenVINO](#ai-pc-support)
45
+ - [MCP Server Support](#mcpsupport)
46
+ - [Open WebUI Support](#openwebuisupport)
47
+ - [ComfyUI support](#comfyuisupport)
48
+ - [License](#license)
49
+ - [Contributors](#contributors)
50
+
51
+ ## Supported platforms⚡️
52
+
53
+ FastSD CPU works on the following platforms:
54
+
55
+ - Windows
56
+ - Linux
57
+ - Mac
58
+ - Android + Termux
59
+ - Raspberry PI 4
60
+
61
+ ## Dependencies 📦
62
+
63
+ - Python 3.10 or higher
64
+ - [uv - fast Python package and project manager](https://docs.astral.sh/uv/)
65
+
66
+ ## Memory requirements
67
+
68
+ Minimum system RAM requirement for FastSD CPU.
69
+
70
+ Model (LCM,OpenVINO): SD Turbo, 1 step, 512 x 512
71
+
72
+ Model (LCM-LoRA): Dreamshaper v8, 3 step, 512 x 512
73
+
74
+ | Mode | Min RAM |
75
+ | --------------------- | ------------- |
76
+ | LCM | 2 GB |
77
+ | LCM-LoRA | 4 GB |
78
+ | OpenVINO | 11 GB |
79
+
80
+ If we enable Tiny decoder(TAESD) we can save some memory(2GB approx) for example in OpenVINO mode memory usage will become 9GB.
81
+
82
+ :exclamation: Please note that guidance scale >1 increases RAM usage and slow inference speed.
83
+
84
+ ## Features ✨
85
+
86
+ - Desktop GUI, web UI and CLI
87
+ - Supports 256,512,768,1024 image sizes
88
+ - Supports Windows,Linux,Mac
89
+ - Saves images and diffusion setting used to generate the image
90
+ - Settings to control,steps,guidance and seed
91
+ - Added safety checker setting
92
+ - Maximum inference steps increased to 25
93
+ - Added [OpenVINO](https://github.com/openvinotoolkit/openvino) support
94
+ - Fixed OpenVINO image reproducibility issue
95
+ - Fixed OpenVINO high RAM usage,thanks [deinferno](https://github.com/deinferno)
96
+ - Added multiple image generation support
97
+ - Application settings
98
+ - Added Tiny Auto Encoder for SD (TAESD) support, 1.4x speed boost (Fast,moderate quality)
99
+ - Safety checker disabled by default
100
+ - Added SDXL,SSD1B - 1B LCM models
101
+ - Added LCM-LoRA support, works well for fine-tuned Stable Diffusion model 1.5 or SDXL models
102
+ - Added negative prompt support in LCM-LoRA mode
103
+ - LCM-LoRA models can be configured using text configuration file
104
+ - Added support for custom models for OpenVINO (LCM-LoRA baked)
105
+ - OpenVINO models now supports negative prompt (Set guidance >1.0)
106
+ - Real-time inference support,generates images while you type (experimental)
107
+ - Fast 2,3 steps inference
108
+ - Lcm-Lora fused models for faster inference
109
+ - Supports integrated GPU(iGPU) using OpenVINO (export DEVICE=GPU)
110
+ - 5.7x speed using OpenVINO(steps: 2,tiny autoencoder)
111
+ - Image to Image support (Use Web UI)
112
+ - OpenVINO image to image support
113
+ - Fast 1 step inference (SDXL Turbo)
114
+ - Added SD Turbo support
115
+ - Added image to image support for Turbo models (Pytorch and OpenVINO)
116
+ - Added image variations support
117
+ - Added 2x upscaler (EDSR and Tiled SD upscale (experimental)),thanks [monstruosoft](https://github.com/monstruosoft) for SD upscale
118
+ - Works on Android + Termux + PRoot
119
+ - Added interactive CLI,thanks [monstruosoft](https://github.com/monstruosoft)
120
+ - Added basic lora support to CLI and WebUI
121
+ - ONNX EDSR 2x upscale
122
+ - Add SDXL-Lightning support
123
+ - Add SDXL-Lightning OpenVINO support (int8)
124
+ - Add multilora support,thanks [monstruosoft](https://github.com/monstruosoft)
125
+ - Add basic ControlNet v1.1 support(LCM-LoRA mode),thanks [monstruosoft](https://github.com/monstruosoft)
126
+ - Add ControlNet annotators(Canny,Depth,LineArt,MLSD,NormalBAE,Pose,SoftEdge,Shuffle)
127
+ - Add SDXS-512 0.9 support
128
+ - Add SDXS-512 0.9 OpenVINO,fast 1 step inference (0.8 seconds to generate 512x512 image)
129
+ - Default model changed to SDXS-512-0.9
130
+ - Faster realtime image generation
131
+ - Add NPU device check
132
+ - Revert default model to SDTurbo
133
+ - Update realtime UI
134
+ - Add hypersd support
135
+ - 1 step fast inference support for SDXL and SD1.5
136
+ - Experimental support for single file Safetensors SD 1.5 models(Civitai models), simply add local model path to configs/stable-diffusion-models.txt file.
137
+ - Add REST API support
138
+ - Add Aura SR (4x)/GigaGAN based upscaler support
139
+ - Add Aura SR v2 upscaler support
140
+ - Add FLUX.1 schnell OpenVINO int 4 support
141
+ - Add CLIP skip support
142
+ - Add token merging support
143
+ - Add Intel AI PC support
144
+ - AI PC NPU(Power efficient inference using OpenVINO) supports, text to image ,image to image and image variations support
145
+ - Add [TAEF1 (Tiny autoencoder for FLUX.1) openvino](https://huggingface.co/rupeshs/taef1-openvino) support
146
+ - Add Image to Image and Image Variations Qt GUI support,thanks [monstruosoft](https://github.com/monstruosoft)
147
+
148
+ <a id="fast-inference-benchmarks"></a>
149
+
150
+ ## Fast Inference Benchmarks
151
+
152
+ ### 🚀 Fast 1 step inference with Hyper-SD
153
+
154
+ #### Stable diffuion 1.5
155
+
156
+ Works with LCM-LoRA mode.
157
+ 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.
158
+
159
+ #### Stable diffuion XL
160
+
161
+ Works with LCM and LCM-OpenVINO mode.
162
+
163
+ - *Hyper-SD SDXL 1 step* - [rupeshs/hyper-sd-sdxl-1-step](https://huggingface.co/rupeshs/hyper-sd-sdxl-1-step)
164
+
165
+ - *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)
166
+
167
+ #### Inference Speed
168
+
169
+ Tested on Core i7-12700 to generate **768x768** image(1 step).
170
+
171
+ | Diffusion Pipeline | Latency |
172
+ | --------------------- | ------------- |
173
+ | Pytorch | 19s |
174
+ | OpenVINO | 13s |
175
+ | OpenVINO + TAESDXL | 6.3s |
176
+
177
+ ### Fastest 1 step inference (SDXS-512-0.9)
178
+
179
+ :exclamation:This is an experimental model, only text to image workflow is supported.
180
+
181
+ #### Inference Speed
182
+
183
+ Tested on Core i7-12700 to generate **512x512** image(1 step).
184
+
185
+ **SDXS-512-0.9**
186
+
187
+ | Diffusion Pipeline | Latency |
188
+ | --------------------- | ------------- |
189
+ | Pytorch | 4.8s |
190
+ | OpenVINO | 3.8s |
191
+ | OpenVINO + TAESD | **0.82s** |
192
+
193
+ ### 🚀 Fast 1 step inference (SD/SDXL Turbo - Adversarial Diffusion Distillation,ADD)
194
+
195
+ Added support for ultra fast 1 step inference using [sdxl-turbo](https://huggingface.co/stabilityai/sdxl-turbo) model
196
+
197
+ :exclamation: These SD turbo models are intended for research purpose only.
198
+
199
+ #### Inference Speed
200
+
201
+ Tested on Core i7-12700 to generate **512x512** image(1 step).
202
+
203
+ **SD Turbo**
204
+
205
+ | Diffusion Pipeline | Latency |
206
+ | --------------------- | ------------- |
207
+ | Pytorch | 7.8s |
208
+ | OpenVINO | 5s |
209
+ | OpenVINO + TAESD | 1.7s |
210
+
211
+ **SDXL Turbo**
212
+
213
+ | Diffusion Pipeline | Latency |
214
+ | --------------------- | ------------- |
215
+ | Pytorch | 10s |
216
+ | OpenVINO | 5.6s |
217
+ | OpenVINO + TAESDXL | 2.5s |
218
+
219
+ ### 🚀 Fast 2 step inference (SDXL-Lightning - Adversarial Diffusion Distillation)
220
+
221
+ SDXL-Lightning works with LCM and LCM-OpenVINO mode.You can select these models from app settings.
222
+
223
+ Tested on Core i7-12700 to generate **768x768** image(2 steps).
224
+
225
+ | Diffusion Pipeline | Latency |
226
+ | --------------------- | ------------- |
227
+ | Pytorch | 18s |
228
+ | OpenVINO | 12s |
229
+ | OpenVINO + TAESDXL | 10s |
230
+
231
+ - *SDXL-Lightning* - [rupeshs/SDXL-Lightning-2steps](https://huggingface.co/rupeshs/SDXL-Lightning-2steps)
232
+
233
+ - *SDXL-Lightning OpenVINO* - [rupeshs/SDXL-Lightning-2steps-openvino-int8](https://huggingface.co/rupeshs/SDXL-Lightning-2steps-openvino-int8)
234
+
235
+ ### 2 Steps fast inference (LCM)
236
+
237
+ FastSD CPU supports 2 to 3 steps fast inference using LCM-LoRA workflow. It works well with SD 1.5 models.
238
+
239
+ ![2 Steps inference](https://raw.githubusercontent.com/rupeshs/fastsdcpu/main/docs/images/2steps-inference.jpg)
240
+
241
+ ### FLUX.1-schnell OpenVINO support
242
+
243
+ ![FLUX Schenell OpenVINO](https://raw.githubusercontent.com/rupeshs/fastsdcpu/main/docs/images/fastsdcpu_flux_on_cpu.png)
244
+
245
+ :exclamation: Important - Please note the following points with FLUX workflow
246
+
247
+ - As of now only text to image generation mode is supported
248
+ - Use OpenVINO mode
249
+ - Use int4 model - *rupeshs/FLUX.1-schnell-openvino-int4*
250
+ - 512x512 image generation needs around **30GB** system RAM
251
+
252
+ Tested on Intel Core i7-12700 to generate **512x512** image(3 steps).
253
+
254
+ | Diffusion Pipeline | Latency |
255
+ | --------------------- | ------------- |
256
+ | OpenVINO | 4 min 30sec |
257
+
258
+ ### Benchmark scripts
259
+
260
+ To benchmark run the following batch file on Windows:
261
+
262
+ - `benchmark.bat` - To benchmark Pytorch
263
+ - `benchmark-openvino.bat` - To benchmark OpenVINO
264
+
265
+ Alternatively you can run benchmarks by passing `-b` command line argument in CLI mode.
266
+ <a id="openvino"></a>
267
+
268
+ ## OpenVINO support
269
+
270
+ 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.
271
+ Thanks [deinferno](https://github.com/deinferno) for the OpenVINO model contribution.
272
+ We can get 2x speed improvement when using OpenVINO.
273
+ Thanks [Disty0](https://github.com/Disty0) for the conversion script.
274
+
275
+ ### OpenVINO SDXL models
276
+
277
+ 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)
278
+
279
+ - Hyper-SD SDXL 1 step - [rupeshs/hyper-sd-sdxl-1-step-openvino-int8](https://huggingface.co/rupeshs/hyper-sd-sdxl-1-step-openvino-int8)
280
+ - SDXL Lightning 2 steps - [rupeshs/SDXL-Lightning-2steps-openvino-int8](https://huggingface.co/rupeshs/SDXL-Lightning-2steps-openvino-int8)
281
+
282
+ ### OpenVINO SD Turbo models
283
+
284
+ 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
285
+
286
+ - *SD Turbo OpenVINO* - [rupeshs/sd-turbo-openvino](https://huggingface.co/rupeshs/sd-turbo-openvino)
287
+ - *SDXL Turbo OpenVINO int8* - [rupeshs/sdxl-turbo-openvino-int8](https://huggingface.co/rupeshs/sdxl-turbo-openvino-int8)
288
+ - *TAESDXL OpenVINO* - [rupeshs/taesdxl-openvino](https://huggingface.co/rupeshs/taesdxl-openvino)
289
+
290
+ You can directly use these models in FastSD CPU.
291
+
292
+ ### Convert SD 1.5 models to OpenVINO LCM-LoRA fused models
293
+
294
+ 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.
295
+
296
+ <a id="real-time-text-to-image"></a>
297
+
298
+ ## Real-time text to image (EXPERIMENTAL)
299
+
300
+ We can generate real-time text to images using FastSD CPU.
301
+
302
+ **CPU (OpenVINO)**
303
+
304
+ 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)
305
+
306
+ Watch YouTube video :
307
+
308
+ [![IMAGE_ALT](https://img.youtube.com/vi/0XMiLc_vsyI/0.jpg)](https://www.youtube.com/watch?v=0XMiLc_vsyI)
309
+
310
+ ## Models
311
+
312
+ 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.
313
+
314
+ Fast SD supports LCM models and LCM-LoRA models.
315
+
316
+ ### LCM Models
317
+
318
+ These models can be configured in `configs/lcm-models.txt` file.
319
+
320
+ ### OpenVINO models
321
+
322
+ These are LCM-LoRA baked in models. These models can be configured in `configs/openvino-lcm-models.txt` file
323
+
324
+ ### LCM-LoRA models
325
+
326
+ These models can be configured in `configs/lcm-lora-models.txt` file.
327
+
328
+ - *lcm-lora-sdv1-5* - distilled consistency adapter for [runwayml/stable-diffusion-v1-5](https://huggingface.co/runwayml/stable-diffusion-v1-5)
329
+ - *lcm-lora-sdxl* - Distilled consistency adapter for [stable-diffusion-xl-base-1.0](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0)
330
+ - *lcm-lora-ssd-1b* - Distilled consistency adapter for [segmind/SSD-1B](https://huggingface.co/segmind/SSD-1B)
331
+
332
+ These models are used with Stablediffusion base models `configs/stable-diffusion-models.txt`.
333
+
334
+ :exclamation: Currently no support for OpenVINO LCM-LoRA models.
335
+
336
+ ### How to add new LCM-LoRA models
337
+
338
+ To add new model follow the steps:
339
+ For example we will add `wavymulder/collage-diffusion`, you can give Stable diffusion 1.5 Or SDXL,SSD-1B fine tuned models.
340
+
341
+ 1. Open `configs/stable-diffusion-models.txt` file in text editor.
342
+ 2. Add the model ID `wavymulder/collage-diffusion` or locally cloned path.
343
+
344
+ Updated file as shown below :
345
+
346
+ ```Lykon/dreamshaper-8
347
+ Fictiverse/Stable_Diffusion_PaperCut_Model
348
+ stabilityai/stable-diffusion-xl-base-1.0
349
+ runwayml/stable-diffusion-v1-5
350
+ segmind/SSD-1B
351
+ stablediffusionapi/anything-v5
352
+ wavymulder/collage-diffusion
353
+ ```
354
+
355
+ Similarly we can update `configs/lcm-lora-models.txt` file with lcm-lora ID.
356
+
357
+ ### How to use LCM-LoRA models offline
358
+
359
+ Please follow the steps to run LCM-LoRA models offline :
360
+
361
+ - In the settings ensure that "Use locally cached model" setting is ticked.
362
+ - Download the model for example `latent-consistency/lcm-lora-sdv1-5`
363
+ Run the following commands:
364
+
365
+ ```
366
+ git lfs install
367
+ git clone https://huggingface.co/latent-consistency/lcm-lora-sdv1-5
368
+ ```
369
+
370
+ 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 :
371
+
372
+ ```
373
+ D:\demo\lcm-lora-sdv1-5
374
+ latent-consistency/lcm-lora-sdxl
375
+ latent-consistency/lcm-lora-ssd-1b
376
+ ```
377
+
378
+ - Open the app and select the newly added local folder in the combo box menu.
379
+ - That's all!
380
+ <a id="useloramodels"></a>
381
+
382
+ ## How to use Lora models
383
+
384
+ Place your lora models in "lora_models" folder. Use LCM or LCM-Lora mode.
385
+ You can download lora model (.safetensors/Safetensor) from [Civitai](https://civitai.com/) or [Hugging Face](https://huggingface.co/)
386
+ E.g: [cutecartoonredmond](https://civitai.com/models/207984/cutecartoonredmond-15v-cute-cartoon-lora-for-liberteredmond-sd-15?modelVersionId=234192)
387
+ <a id="usecontrolnet"></a>
388
+
389
+ ## ControlNet support
390
+
391
+ We can use ControlNet in LCM-LoRA mode.
392
+
393
+ 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.
394
+
395
+ 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>)
396
+
397
+ ## Installation
398
+
399
+ ### FastSD CPU on Windows
400
+
401
+ ![FastSD CPU Desktop GUI Screenshot](https://raw.githubusercontent.com/rupeshs/fastsdcpu/main/docs/images/fastsdcpu-gui.jpg)
402
+
403
+ :exclamation:**You must have a working Python and uv installation.(Recommended : Python 3.10 or higher )**
404
+
405
+ To install FastSD CPU on Windows run the following steps :
406
+
407
+ - Clone/download this repo or download [release](https://github.com/rupeshs/fastsdcpu/releases).
408
+ - Double click `install.bat` (It will take some time to install,depending on your internet speed.)
409
+ - You can run in desktop GUI mode or web UI mode.
410
+
411
+ #### Desktop GUI
412
+
413
+ - To start desktop GUI double click `start.bat`
414
+
415
+ #### Web UI
416
+
417
+ - To start web UI double click `start-webui.bat`
418
+
419
+ ### FastSD CPU on Linux
420
+
421
+ :exclamation:**Ensure that you have Python 3.10 and uv installed.**
422
+
423
+ - Clone/download this repo or download [release](https://github.com/rupeshs/fastsdcpu/releases).
424
+ - In the terminal, enter into fastsdcpu directory
425
+ - Run the following command
426
+
427
+ `chmod +x install.sh`
428
+
429
+ `./install.sh`
430
+
431
+ #### To start Desktop GUI
432
+
433
+ `./start.sh`
434
+
435
+ #### To start Web UI
436
+
437
+ `./start-webui.sh`
438
+
439
+ ### FastSD CPU on Mac
440
+
441
+ ![FastSD CPU running on Mac](https://raw.githubusercontent.com/rupeshs/fastsdcpu/main/docs/images/fastsdcpu-mac-gui.jpg)
442
+
443
+ :exclamation:**Ensure that you have Python 3.9 or 3.10 or 3.11 version installed.**
444
+
445
+ Run the following commands to install FastSD CPU on Mac :
446
+
447
+ - Clone/download this repo or download [release](https://github.com/rupeshs/fastsdcpu/releases).
448
+ - In the terminal, enter into fastsdcpu directory
449
+ - Run the following command
450
+
451
+ `chmod +x install-mac.sh`
452
+
453
+ `./install-mac.sh`
454
+
455
+ #### To start Desktop GUI
456
+
457
+ `./start.sh`
458
+
459
+ #### To start Web UI
460
+
461
+ `./start-webui.sh`
462
+
463
+ Thanks [Autantpourmoi](https://github.com/Autantpourmoi) for Mac testing.
464
+
465
+ :exclamation:We don't support OpenVINO on Mac (M1/M2/M3 chips, but *does* work on Intel chips).
466
+
467
+ If you want to increase image generation speed on Mac(M1/M2 chip) try this:
468
+
469
+ `export DEVICE=mps` and start app `start.sh`
470
+
471
+ #### Web UI screenshot
472
+
473
+ ![FastSD CPU WebUI Screenshot](https://raw.githubusercontent.com/rupeshs/fastsdcpu/main/docs/images/fastcpu-webui.png)
474
+
475
+ ### Google Colab
476
+
477
+ Due to the limitation of using CPU/OpenVINO inside colab, we are using GPU with colab.
478
+ [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1SuAqskB-_gjWLYNRFENAkIXZ1aoyINqL?usp=sharing)
479
+
480
+ ### CLI mode (Advanced users)
481
+
482
+ ![FastSD CPU CLI Screenshot](https://raw.githubusercontent.com/rupeshs/fastsdcpu/main/docs/images/fastcpu-cli.png)
483
+
484
+ Open the terminal and enter into fastsdcpu folder.
485
+ Activate virtual environment using the command:
486
+
487
+ ##### Windows users
488
+
489
+ (Suppose FastSD CPU available in the directory "D:\fastsdcpu")
490
+ `D:\fastsdcpu\env\Scripts\activate.bat`
491
+
492
+ ##### Linux users
493
+
494
+ `source env/bin/activate`
495
+
496
+ Start CLI `src/app.py -h`
497
+
498
+ <a id="android"></a>
499
+
500
+ ## Android (Termux + PRoot)
501
+
502
+ FastSD CPU running on Google Pixel 7 Pro.
503
+
504
+ ![FastSD CPU Android Termux Screenshot](https://raw.githubusercontent.com/rupeshs/fastsdcpu/main/docs/images/fastsdcpu-android-termux-pixel7.png)
505
+
506
+ ### Install FastSD CPU on Android
507
+
508
+ 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/)
509
+
510
+ <a id="raspberry"></a>
511
+
512
+ ## Raspberry PI 4 support
513
+
514
+ Thanks [WGNW_MGM] for Raspberry PI 4 testing.FastSD CPU worked without problems.
515
+ System configuration - Raspberry Pi 4 with 4GB RAM, 8GB of SWAP memory.
516
+
517
+ <a id="apisupport"></a>
518
+
519
+ ## API support
520
+
521
+ ![FastSD CPU API documentation](https://raw.githubusercontent.com/rupeshs/fastsdcpu/add-basic-api-support/docs/images/fastsdcpu-api.png)
522
+
523
+ FastSD CPU supports basic API endpoints. Following API endpoints are available :
524
+
525
+ - /api/info - To get system information
526
+ - /api/config - Get configuration
527
+ - /api/models - List all available models
528
+ - /api/generate - Generate images (Text to image,image to image)
529
+
530
+ To start FastAPI in webserver mode run:
531
+ ``python src/app.py --api``
532
+
533
+ or use `start-webserver.sh` for Linux and `start-webserver.bat` for Windows.
534
+
535
+ Access API documentation locally at <http://localhost:8000/api/docs> .
536
+
537
+ Generated image is JPEG image encoded as base64 string.
538
+ In the image-to-image mode input image should be encoded as base64 string.
539
+
540
+ To generate an image a minimal request `POST /api/generate` with body :
541
+
542
+ ```
543
+ {
544
+ "prompt": "a cute cat",
545
+ "use_openvino": true
546
+ }
547
+ ```
548
+
549
+ <a id="gguf-support"></a>
550
+
551
+ ## GGUF support - Flux
552
+
553
+ [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.
554
+
555
+ To use GGUF model use web UI and select GGUF mode.
556
+
557
+ Tested on Windows and Linux.
558
+
559
+ :exclamation: Main advantage here we reduced minimum system RAM required for Flux workflow to around **12 GB**.
560
+
561
+ Supported mode - Text to image
562
+
563
+ ### How to run Flux GGUF model
564
+
565
+ - Download stablediffusion.cpp prebuilt shared library and place it inside fastsdcpu folder
566
+ For Windows users, download [stable-diffusion.dll](https://huggingface.co/rupeshs/FastSD-Flux-GGUF/blob/main/stable-diffusion.dll)
567
+
568
+ For Linux users download [libstable-diffusion.so](https://huggingface.co/rupeshs/FastSD-Flux-GGUF/blob/main/libstable-diffusion.so)
569
+
570
+ You can also build the library manully by following the guide *"Build stablediffusion.cpp shared library for GGUF flux model support"*
571
+
572
+ - 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
573
+ - 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
574
+ - 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
575
+ - 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
576
+ - Start web UI and select GGUF mode
577
+ - Select the models settings tab and select GGUF diffusion,clip_l,t5xxl and VAE models.
578
+ - Enter your prompt and generate image
579
+
580
+ ### Build stablediffusion.cpp shared library for GGUF flux model support(Optional)
581
+
582
+ To build the stablediffusion.cpp library follow these steps
583
+
584
+ - `git clone https://github.com/leejet/stable-diffusion.cpp`
585
+ - `cd stable-diffusion.cpp`
586
+ - `git pull origin master`
587
+ - `git submodule init`
588
+ - `git submodule update`
589
+ - `git checkout 14206fd48832ab600d9db75f15acb5062ae2c296`
590
+ - `cmake . -DSD_BUILD_SHARED_LIBS=ON`
591
+ - `cmake --build . --config Release`
592
+ - Copy the stablediffusion dll/so file to fastsdcpu folder
593
+
594
+ <a id="ai-pc-support"></a>
595
+
596
+ ## Intel AI PC support - OpenVINO (CPU, GPU, NPU)
597
+
598
+ 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/).
599
+
600
+ ### GPU
601
+
602
+ For GPU mode `set device=GPU` and run webui. FastSD GPU benchmark on AI PC as shown below.
603
+
604
+ ![FastSD AI PC Arc GPU benchmark](https://raw.githubusercontent.com/rupeshs/fastsdcpu/main/docs/images/ARCGPU.png)
605
+
606
+ ### NPU
607
+
608
+ FastSD CPU now supports power efficient NPU (Neural Processing Unit) that comes with Intel Core Ultra processors.
609
+
610
+ FastSD tested with following Intel processor's NPUs:
611
+
612
+ - Intel Core Ultra Series 1 (Meteor Lake)
613
+ - Intel Core Ultra Series 2 (Lunar Lake)
614
+
615
+ Currently FastSD support this model for NPU [rupeshs/sd15-lcm-square-openvino-int8](https://huggingface.co/rupeshs/sd15-lcm-square-openvino-int8).
616
+
617
+ Supports following modes on NPU :
618
+
619
+ - Text to image
620
+ - Image to image
621
+ - Image variations
622
+
623
+ To run model in NPU follow these steps (Please make sure that your AI PC's NPU driver is the latest):
624
+
625
+ - Start webui
626
+ - Select LCM-OpenVINO mode
627
+ - Select the models settings tab and select OpenVINO model `rupeshs/sd15-lcm-square-openvino-int8`
628
+ - Set device envionment variable `set DEVICE=NPU`
629
+ - Now it will run on the NPU
630
+
631
+ This is heterogeneous computing since text encoder and Unet will use NPU and VAE will use GPU for processing. Thanks to OpenVINO.
632
+
633
+ Please note that tiny auto encoder will not work in NPU mode.
634
+
635
+ *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).*
636
+
637
+ <a id="mcpsupport"></a>
638
+
639
+ ## MCP Server Support
640
+
641
+ FastSDCPU now supports [MCP(Model Context Protocol)](https://modelcontextprotocol.io/introduction) server.
642
+
643
+ - Start FastSDCPU MCP server:
644
+ ``python src/app.py --mcp``
645
+ or
646
+ Run `start-mcpserver.sh` for Linux and `start-mcpserver.bat` for Windows.
647
+
648
+ FastSDCPU MCP server will be running at <http://127.0.0.1:8000/mcp>
649
+
650
+ It can be used with AI apps that support MCP protocol for example [Claude desktop](https://claude.ai/download)
651
+
652
+ Note: OpenWebUI not directly using MCP protocol it is based on OpenAPI protocol.
653
+
654
+ ### Claude desktop
655
+
656
+ To connect with FastSD MCP server first configure Claude desktop :
657
+
658
+ - First configure Claude desktop,open File - >Settings -> Developer - Edit config
659
+ - Add below config(Also ensure that node.js installed on your machine)
660
+
661
+ ```json
662
+ {
663
+ "mcpServers": {
664
+ "fastsdcpu": {
665
+ "command": "npx",
666
+ "args": [
667
+ "mcp-remote",
668
+ "http://127.0.0.1:8000/mcp"
669
+ ]
670
+ }
671
+ }
672
+ }
673
+ ```
674
+
675
+ - Restart Claude desktop
676
+ - Give a sample prompt to generate image "create image of a cat"
677
+
678
+ Screenshot of Claude desktop accessing **Intel AI PC NPU** to generate an image using the FastSD MCP server
679
+
680
+ ![Claude desktop FastSD CPU AIPC NPU](https://raw.githubusercontent.com/rupeshs/fastsdcpu/refs/heads/add-mcp-server-support/docs/images/fastsdcpu_claude.jpg)
681
+
682
+ <a id="openwebuisupport"></a>
683
+
684
+ ## Open WebUI Support
685
+
686
+ The FastSDCPU can be used with [OpenWebUI](https://github.com/open-webui/open-webui) for local image generation using LLM and tool calling.
687
+
688
+ Follow the below steps to FastSD to use with Open WebUI.
689
+
690
+ - Start FastSDCPU MCP server:
691
+ ``python src/app.py --mcp``
692
+ or
693
+ Run `start-mcpserver.sh` for Linux and `start-mcpserver.bat` for Windows.
694
+
695
+ - Update server URL in the settings page as shown below
696
+
697
+ ![OpenWebUI Settings](https://raw.githubusercontent.com/rupeshs/fastsdcpu/refs/heads/add-mcp-server-support/docs/images/openwebui-settings.png)
698
+
699
+ - Change chat controls setting "Function Calling" to "Native"
700
+
701
+ - Generate image using text prompt (Qwen 2.5 7B model used for the demo)
702
+
703
+ ![OpenWebUI FastSD MCP Server](https://raw.githubusercontent.com/rupeshs/fastsdcpu/refs/heads/add-mcp-server-support/docs/images/openwebui-fastsd.jpg)
704
+
705
+ <a id="comfyuisupport"></a>
706
+
707
+ ## ComfyUI support
708
+
709
+ FastSD can be used with ComfyUI with [ComfyUI-FastSDCPU node](https://github.com/BetaDoggo/ComfyUI-FastSDCPU). To use it follow this [step by step guide](https://nolowiz.com/how-to-use-comfyui-with-fastsdcpu-and-openvino/). To use NPU set environment variable "DEVICE=NPU" and choose "rupeshs/sd15-lcm-square-openvino-int8" as your OpenVINO Model.
710
+
711
+ ![Comfyui OpenVINO text to image workflow](https://raw.githubusercontent.com/rupeshs/fastsdcpu/refs/heads/add-sana-sprint-support/docs/images/comfyui-workflow.png)
712
+
713
+ ## License
714
+
715
+ The fastsdcpu project is available as open source under the terms of the [MIT license](https://github.com/rupeshs/fastsdcpu/blob/main/LICENSE)
716
+
717
+ ## Disclaimer
718
+
719
+ 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.
720
+
721
+ <a id="contributors"></a>
722
+
723
+ ## Thanks to all our contributors
724
+
725
+ Original Author & Maintainer - [Rupesh Sreeraman](https://github.com/rupeshs)
726
+
727
+ We thank all contributors for their time and hard work!
728
+
729
+ <a href="https://github.com/rupeshs/fastsdcpu/graphs/contributors">
730
+ <img src="https://contrib.rocks/image?repo=rupeshs/fastsdcpu" />
731
+ </a>
requirements.txt ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ accelerate==1.6.0
2
+ diffusers==0.33.0
3
+ transformers==4.48.0
4
+ PyQt5
5
+ Pillow==9.4.0
6
+ openvino==2025.1.0
7
+ optimum-intel==1.23.0
8
+ onnx==1.16.0
9
+ numpy==1.26.4
10
+ onnxruntime==1.17.3
11
+ pydantic
12
+ typing-extensions==4.8.0
13
+ pyyaml==6.0.1
14
+ gradio==5.6.0
15
+ peft==0.6.1
16
+ opencv-python==4.8.1.78
17
+ omegaconf==2.3.0
18
+ controlnet-aux==0.0.7
19
+ mediapipe>=0.10.9
20
+ tomesd==0.1.3
21
+ mcp==1.6.0
22
+ fastapi-mcp==0.3.0