Views
No views yet
1BitsAndBytesConfig {
2 "_load_in_4bit": true,
3 "_load_in_8bit": false,
4 "bnb_4bit_compute_dtype": "bfloat16",
5 "bnb_4bit_quant_storage": "uint8",
6 "bnb_4bit_quant_type": "nf4",
7 "bnb_4bit_use_double_quant": false,
8 "llm_int8_enable_fp32_cpu_offload": false,
9 "llm_int8_has_fp16_weight": false,
10 "llm_int8_skip_modules": null,
11 "llm_int8_threshold": 6.0,
12 "load_in_4bit": true,
13 "load_in_8bit": false,
14 "quant_method": "bitsandbytes"
15}
16a puppy, yarn art style to trigger the image generation.1from diffusers import AutoPipelineForText2Image, FluxTransformer2DModel, BitsAndBytesConfig
2import torch
3
4ckpt_id = "black-forest-labs/FLUX.1-dev"
5bnb_4bit_compute_dtype = torch.bfloat16
6nf4_config = BitsAndBytesConfig(
7 load_in_4bit=True,
8 bnb_4bit_quant_type="nf4",
9 bnb_4bit_compute_dtype=bnb_4bit_compute_dtype,
10)
11transformer = FluxTransformer2DModel.from_pretrained(
12 ckpt_id,
13 subfolder="transformer",
14 quantization_config=nf4_config,
15 torch_dtype=bnb_4bit_compute_dtype,
16)
17pipeline = AutoPipelineForText2Image.from_pretrained(
18 ckpt_id, transformer=transformer, torch_dtype=torch.bfloat16
19)
20pipeline.load_lora_weights("yarn_art_lora_flux_nf4", weight_name="pytorch_lora_weights.safetensors")
21
22pipeline.fuse_lora()
23pipeline.unload_lora_weights()
24pipeline.enable_model_cpu_offload()
25
26image = pipeline("a puppy in a pond, yarn art style", guidance_scale=3.5, height=768).images[0]
27image.save("yarn.png")# TODO: add an example code snippet for running this diffusion pipeline