Text-to-Image
Diffusers
Safetensors
lora
clementchadebec commited on
Commit
56f1540
·
verified ·
1 Parent(s): 2ae93a7

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +91 -3
README.md CHANGED
@@ -1,3 +1,91 @@
1
- ---
2
- license: cc-by-nc-4.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-nc-4.0
3
+ library_name: diffusers
4
+ base_model: stabilityai/stable-diffusion-3-medium
5
+ tags:
6
+ - lora
7
+ - text-to-image
8
+ inference: False
9
+ ---
10
+ # ⚡ Flash Diffusion: FlashPixart ⚡
11
+
12
+
13
+ Flash Diffusion is a diffusion distillation method proposed in [Flash Diffusion: Accelerating Any Conditional
14
+ Diffusion Model for Few Steps Image Generation](http://arxiv.org/abs/2406.02347) *by Clément Chadebec, Onur Tasar, Eyal Benaroche, and Benjamin Aubin.*
15
+ This model is a **90.4M** LoRA distilled version of [SD3](https://huggingface.co/stabilityai/stable-diffusion-3-medium) model that is able to generate 1024x1024 images in **4 steps**.
16
+ See our [live demo](https://huggingface.co/spaces/jasperai/flash-sd3) and official [Github repo](https://github.com/gojasper/flash-diffusion).
17
+
18
+
19
+ <p align="center">
20
+ <img style="width:700px;" src="assets/flash_sd3.jpg">
21
+ </p>
22
+
23
+ # How to use?
24
+
25
+ The model can be used using the `StableDiffusion3Pipeline` from `diffusers` library directly. It can allow reducing the number of required sampling steps to **4 steps**.
26
+
27
+ First, you need to install a specific version of `diffiusers` by runniung`
28
+
29
+ ```bash
30
+ pip install git+https://github.com/initml/diffusers.git@clement/feature/flash_sd3
31
+ ```
32
+ Then, you can ru the following to generate an image
33
+
34
+ ```python
35
+ import torch
36
+ from diffusers import StableDiffusion3Pipeline, SD3Transformer2DModel, FlashFlowMatchEulerDiscreteScheduler
37
+ from peft import PeftModel
38
+
39
+ # Load LoRA
40
+ transformer = SD3Transformer2DModel.from_pretrained(
41
+ "stabilityai/stable-diffusion-3-medium",
42
+ subfolder="transformer",
43
+ torch_dtype=torch.float16,
44
+ revision="refs/pr/26"
45
+ )
46
+ transformer = PeftModel.from_pretrained(transformer, "jasperai/flash-sd3")
47
+
48
+
49
+ # Pipeline
50
+ pipe = StableDiffusion3Pipeline.from_pretrained(
51
+ "stabilityai/stable-diffusion-3-medium",
52
+ revision="refs/pr/26",
53
+ transformer=transformer,
54
+ torch_dtype=torch.float16,
55
+ text_encoder_3=None,
56
+ tokenizer_3=None
57
+ )
58
+
59
+ # Scheduler
60
+ pipe.scheduler = FlashFlowMatchEulerDiscreteScheduler.from_pretrained(
61
+ "stabilityai/stable-diffusion-3-medium",
62
+ subfolder="scheduler",
63
+ revision="refs/pr/26",
64
+ )
65
+
66
+ pipe.to("cuda")
67
+
68
+ prompt = "A raccoon trapped inside a glass jar full of colorful candies, the background is steamy with vivid colors."
69
+
70
+ image = pipe(prompt, num_inference_steps=4, guidance_scale=0).images[0]
71
+ ```
72
+ <p align="center">
73
+ <img style="width:400px;" src="assets/raccoon.png">
74
+ </p>
75
+
76
+ ## Citation
77
+ If you find this work useful or use it in your research, please consider citing us
78
+
79
+ ```bibtex
80
+ @misc{chadebec2024flash,
81
+ title={Flash Diffusion: Accelerating Any Conditional Diffusion Model for Few Steps Image Generation},
82
+ author={Clement Chadebec and Onur Tasar and Eyal Benaroche and Benjamin Aubin},
83
+ year={2024},
84
+ eprint={2406.02347},
85
+ archivePrefix={arXiv},
86
+ primaryClass={cs.CV}
87
+ }
88
+ ```
89
+
90
+ ## License
91
+ This model is released under the the Creative Commons BY-NC license.