File size: 1,956 Bytes
ca2cc13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e81e48d
ca2cc13
9bd760e
ca2cc13
 
 
 
 
224f003
ca2cc13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89357d0
ca2cc13
 
 
 
 
 
 
 
 
 
 
 
89357d0
ca2cc13
ed9b5a8
ca2cc13
 
 
 
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
---
tags:
- text-to-image
- flux
- diffusers
- quantization
- bitsandbytes
- int8
license: other
language:
- en
base_model:
- black-forest-labs/FLUX.1-dev
pipeline_tag: text-to-image
---

## Model Overview

`Silan10/flux_quantized_bitsandbytes` is an **8-bit quantized version** of the
[`black-forest-labs/FLUX.1-dev`](https://huggingface.co/black-forest-labs/FLUX.1-dev)
text-to-image model. In this version, the **`transformer`**, **`text_encoder`** and
**`text_encoder_2`** components have been quantized to 8-bit precision using bitsandbytes.

Bitsandbytes quantization uses **8-bit integer 
representation** with dynamic scaling factors. This provides substantial memory savings while maintaining high image quality through
mixed-precision computation.

## Usage

```python
import torch
import os
from diffusers import FluxPipeline

model_path = "Silan10/flux_quantized_bitsandbytes"

print("Loading pipeline...")

pipe = FluxPipeline.from_pretrained(
            model_path,
            torch_dtype=torch.bfloat16
        )
pipe.to("cuda")
print("✓ Pipeline loaded successfully.")

prompt = "Ultra-detailed nighttime cyberpunk city street, several pedestrians in modern clothes, one person in the foreground looking toward the camera, sharp facial features and detailed hair, wet pavement reflecting colorful neon signs, shop windows with small readable text on signs, a gradient sky fading from deep blue to purple, a mix of strong highlights and deep shadows, highly detailed, 4K, cinematic lighting."
print("Generating image...")

image = pipe(
    prompt,
    num_inference_steps=20,
    guidance_scale=3.5,
    max_sequence_length=512,
    width=1024,
    height=1024,
    generator=torch.Generator("cpu").manual_seed(42)
).images[0]

image.save("output_bitsandbytes.png")
print("✓ Image generated successfully.")
print("DONE!")
```

## Credits

- **Quantization**: [bitsandbytes](https://github.com/TimDettmers/bitsandbytes) by Tim Dettmers