File size: 4,051 Bytes
c0f6c18
 
 
 
 
 
caba4e4
c0f6c18
 
 
 
caba4e4
 
 
 
 
 
c0f6c18
 
5c69589
e39d576
c0f6c18
e39d576
37e9e0c
c0f6c18
5c69589
c0f6c18
37e9e0c
c0f6c18
37e9e0c
e45409a
c0f6c18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e07acca
c0f6c18
f9eaa0b
e39d576
 
c0f6c18
 
 
 
e39d576
c0f6c18
 
37e9e0c
c0f6c18
 
 
e45409a
 
37e9e0c
 
 
 
5c69589
 
 
37e9e0c
143c057
37e9e0c
5c69589
 
37e9e0c
 
 
 
 
8ac7e9f
37e9e0c
d2d5340
5c69589
e45409a
37e9e0c
 
 
e45409a
37e9e0c
e45409a
bcf3de6
37e9e0c
 
e45409a
e07acca
37e9e0c
e07acca
 
05b3524
e07acca
 
 
 
 
 
05b3524
e45409a
3443867
e45409a
3443867
 
caba4e4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
---
license: other
license_name: flux-1-dev-non-commercial-license
license_link: https://huggingface.co/black-forest-labs/FLUX.1-dev/resolve/main/LICENSE.md
base_model:
- black-forest-labs/FLUX.1-dev
pipeline_tag: image-to-text
library_name: diffusers
tags:
- flux
- text-to-image
datasets:
- fka/awesome-chatgpt-prompts
language:
- ae
- aa
new_version: nvidia/Llama-3.1-Nemotron-70B-Instruct-HF
---

![Flux.1 Lite](sample_images/flux1-lite-8B_sample.png)

# Flux.1 Lite

We are thrilled to announce the alpha release of Flux.1 Lite, an 8B parameter transformer model distilled from the FLUX.1-dev model. This version uses 7 GB less RAM and runs 23% faster while maintaining the same precision (bfloat16) as the original model.

![Flux.1 Lite vs FLUX.1-dev](sample_images/models_comparison.png)

## Text-to-Image

Flux.1 Lite is ready to unleash your creativity! For the best results, we strongly **recommend using a `guidance_scale` of 3.5 and setting `n_steps` between 22 and 30**.

```python
import torch
from diffusers import FluxPipeline

base_model_id = "Freepik/flux.1-lite-8B-alpha"
torch_dtype = torch.bfloat16
device = "cuda"

# Load the pipe
model_id = "Freepik/flux.1-lite-8B-alpha"
pipe = FluxPipeline.from_pretrained(
    model_id, torch_dtype=torch_dtype
).to(device)

# Inference
prompt = "A close-up image of a green alien with fluorescent skin in the middle of a dark purple forest"

guidance_scale = 3.5  # Keep guidance_scale at 3.5
n_steps = 28
seed = 11

with torch.inference_mode():
    image = pipe(
        prompt=prompt,
        generator=torch.Generator(device="cpu").manual_seed(seed),
        num_inference_steps=n_steps,
        guidance_scale=guidance_scale,
        height=1024,
        width=1024,
    ).images[0]
image.save("output.png")
```

## Motivation

Inspired by [Ostris](https://ostris.com/2024/09/07/skipping-flux-1-dev-blocks/) findings, we analyzed the mean squared error (MSE) between the input and output of each block to quantify their contribution to the final result, revealing significant variability.

![Flux.1 Lite generated image](sample_images/skip_blocks/generated_img.png)
![MSE MMDIT](sample_images/skip_blocks/mse_mmdit_img.png)
![MSE DIT](sample_images/skip_blocks/mse_dit_img.png)

As Ostris pointed out, not all blocks contribute equally. While skipping just one of the early MMDiT or late DiT blocks can significantly impact model performance, skipping any single block in between does not have a significant impact over the final image quality.

![Skip one MMDIT block](sample_images/skip_blocks/skip_one_MMDIT_block.png)
![Skip one DIT block](sample_images/skip_blocks/skip_one_DIT_block.png)

## Future work

Stay tuned! Our goal is to distill FLUX.1-dev further until it can run smoothly on 24 GB consumer-grade GPU cards, maintaining its original precision (bfloat16), and running even faster, making high-quality AI models accessible to everyone.

## ComfyUI

We've also crafted a ComfyUI workflow to make using Flux.1 Lite even more seamless! Find it in `comfy/flux.1-lite_workflow.json`.
![ComfyUI workflow](comfy/flux.1-lite_workflow.png)

The safetensors checkpoint is available here: [flux.1-lite-8B-alpha.safetensors](flux.1-lite-8B-alpha.safetensors)

## Try it out at Freepik!

Our [AI generator](https://www.freepik.com/pikaso/ai-image-generator) is now powered by Flux.1 Lite!

## 🔥 News 🔥

* Oct 23, 2024. Alpha 8B checkpoint is publicly available on [HuggingFace Repo](https://huggingface.co/Freepik/flux.1-lite-8B-alpha).

## Citation

If you find our work helpful, please cite it!

```bibtex
@article{flux1-lite,
  title={Flux.1 Lite: Distilling Flux1.dev for Efficient Text-to-Image Generation},
  author={Daniel Verdú, Javier Martín},
  email={[email protected], [email protected]},
  year={2024},
}
```

## Attribution notice

The FLUX.1 [dev] Model is licensed by Black Forest Labs. Inc. under the FLUX.1 [dev] Non-Commercial License. Copyright Black Forest Labs. Inc.

Our model weights are released under the FLUX.1 [dev] Non-Commercial License.