File size: 1,025 Bytes
30f0bed
 
 
 
8e8f5bc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30f0bed
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
---
pipeline_tag: text-to-image
library_name: diffusers
---
## Setup

Install the latest version of `diffusers`

```shell
pip install git+https://github.com/huggingface/diffusers.git
```

Login to your Hugging Face account

```shell
hf auth login
```

## How to use

The following code snippet demonstrates how to use the [Flux2](https://huggingface.co/black-forest-labs/FLUX.2-dev) modular pipeline with a remote text encoder and a 4bit quantized version of the DiT. It requires approximately 19GB of VRAM to generate an image.

```python
import torch
from diffusers.modular_pipelines.flux2 import ALL_BLOCKS
from diffusers.modular_pipelines import SequentialPipelineBlocks

blocks = SequentialPipelineBlocks.from_blocks_dict(ALL_BLOCKS['remote'])
pipe = blocks.init_pipeline("diffusers/flux2-bnb-4bit-modular")
pipe.load_components(torch_dtype=torch.bfloat16, device_map="cuda")

prompt = "a photo of a cat"
outputs = pipe(prompt=prompt, num_inference_steps=28, output="images")
outputs[0].save("flux2-bnb-modular.png")
```