File size: 1,468 Bytes
519302b 3902441 519302b 00aec70 519302b abf00e7 3902441 00aec70 519302b 00aec70 519302b 00aec70 8ab31f6 00aec70 519302b 00aec70 519302b 00aec70 519302b 00aec70 519302b 00aec70 519302b 00aec70 |
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 |
---
library_name: diffusers
license: other
license_name: flux-1-dev-non-commercial-license
license_link: LICENSE.md
---
## To run
> [!TIP]
> Check out [sayakpaul/flux.1-dev-nf4-pkg](https://huggingface.co./sayakpaul/flux.1-dev-nf4-pkg) that shows how to run this checkpoint along with an NF4 T5 in a free-tier Colab Notebook.
Be mindful of the license of Flux.1-Dev here.
Make sure you have the latest versions of `bitsandbytes` and `accelerate` installed.
And then install `diffusers` from [this PR](https://github.com/huggingface/diffusers/pull/9213/):
```bash
pip install git+https://github.com/huggingface/diffusers@c795c82df39620e2576ccda765b6e67e849c36e7
```
```python
import torch
from diffusers import FluxTransformer2DModel, FluxPipeline
model_id = "black-forest-labs/FLUX.1-dev"
nf4_id = "sayakpaul/flux.1-dev-nf4-with-bnb-integration"
model_nf4 = FluxTransformer2DModel.from_pretrained(nf4_id, torch_dtype=torch.bfloat16)
print(model_nf4.dtype)
print(model_nf4.config.quantization_config)
pipe = FluxPipeline.from_pretrained(model_id, transformer=model_nf4, torch_dtype=torch.bfloat16)
pipe.enable_model_cpu_offload()
prompt = "A mystic cat with a sign that says hello world!"
image = pipe(prompt, guidance_scale=3.5, num_inference_steps=50, generator=torch.manual_seed(0)).images[0]
image.save("flux-nf4-dev-loaded.png")
```

|