Downloads · 30 days
11
18% of all-time downloads
HighCWu/FLUX.1-dev-bnb-hqq-4bit
FLUX.1-dev-bnb-hqq-4bit is a text-to-image model from HighCWu. Use it when you need an image from a text prompt. It is set up for diffusers.
<td style="text-align: center;" BF16<br <medium-zoom background="rgba(0,0,0,.7)"<img src="./flux-devbf16.png" alt="Flux-dev output with BF16: Baroque, Futurist, Noir styles"</medium-zoom </td <td style="text-align: ce…
Downloads · 30 days
11
18% of all-time downloads
All-time downloads
60
Public
Parameters
6.1B
10 GB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors10 GB · 100%
How the weights are stored.
U85.9B · 97%
From the Hugging Face model README
To use this quantized FLUX.1 [dev] checkpoint, you need to install the 🧨 diffusers, transformers, bitsandbytes and hqq library:
pip install git+https://github.com/huggingface/diffusers.git@599c887 # add support for `PipelineQuantizationConfig`
pip install git+https://github.com/huggingface/transformers.git@3dbbf01 # add support for hqq quantized model in diffusers pipeline
pip install -U bitsandbytes
pip install -U hqq
After installing the required library, you can run the following script:
import torch
from diffusers import FluxPipeline
pipe = FluxPipeline.from_pretrained(
"HighCWu/FLUX.1-dev-bnb-hqq-4bit",
torch_dtype=torch.bfloat16
)
# Use model cpu offload or all on cuda
pipe.enable_model_cpu_offload()
# pipe.to("cuda")
prompt = "Baroque style, a lavish palace interior with ornate gilded ceilings, intricate tapestries, and dramatic lighting over a grand staircase."
pipe_kwargs = {
"prompt": prompt,
"height": 1024,
"width": 1024,
"guidance_scale": 3.5,
"num_inference_steps": 50,
"max_sequence_length": 512,
}
image = pipe(
**pipe_kwargs, generator=torch.manual_seed(0),
).images[0]
image.save("flux.png")
This checkpoint was created with the following script using "black-forest-labs/FLUX.1-dev" checkpoint:
import torch
assert torch.cuda.is_available() # force initialization of cuda
from diffusers import FluxPipeline
from diffusers import BitsAndBytesConfig as DiffusersBitsAndBytesConfig
from diffusers.quantizers import PipelineQuantizationConfig
from transformers import HqqConfig as TransformersHqqConfig
pipeline_quant_config = PipelineQuantizationConfig(
quant_mapping={
"transformer": DiffusersBitsAndBytesConfig(load_in_4bit=True, bnb_4bit_quant_type="nf4", bnb_4bit_compute_dtype=torch.bfloat16),
"text_encoder_2": TransformersHqqConfig(nbits=4, group_size=64),
}
)
pipe = FluxPipeline.from_pretrained(
"black-forest-labs/FLUX.1-dev",
quantization_config=pipeline_quant_config,
torch_dtype=torch.bfloat16
)
pipe.save_pretrained("FLUX.1-dev-bnb-hqq-4bit")