Views
No views yet
[!IMPORTANT] This model was built following this tutorial which explains in detail how to fine-tune FLUX.1-dev. I copied and adapted the repository page from the tutorial. Original can be found here
black-forest-labs/FLUX.1-dev to generate images in the artistic style of George Barbier.
This work follows the blog post, "Fine-Tuning FLUX.1-dev on consumer hardware and in FP8".1from diffusers import FluxPipeline
2import torch
3
4ckpt_id = "black-forest-labs/FLUX.1-dev"
5pipeline = FluxPipeline.from_pretrained(
6 ckpt_id, torch_dtype=torch.float16
7)
8pipeline.load_lora_weights("paulprt/george-barbier-qlora-flux", weight_name="pytorch_lora_weights.safetensors")
9pipeline.enable_model_cpu_offload()
10
11image = pipeline(
12 "Two women dancing in nature, george barbier style",
13 num_inference_steps=28,
14 guidance_scale=3.5,
15 height=768,
16 width=512,
17 generator=torch.manual_seed(0)
18).images[0]
19image.save("george_barbier_loaded.png")1from diffusers import FluxPipeline, AutoPipelineForText2Image, FluxTransformer2DModel
2import torch
3
4ckpt_id = "black-forest-labs/FLUX.1-dev"
5pipeline = FluxPipeline.from_pretrained(
6 ckpt_id, text_encoder=None, text_encoder_2=None, torch_dtype=torch.float16
7)
8pipeline.load_lora_weights("paulprt/george-barbier-qlora-flux", weight_name="pytorch_lora_weights.safetensors")
9pipeline.fuse_lora()
10pipeline.unload_lora_weights()
11
12# You can save the fused transformer for later use
13# pipeline.transformer.save_pretrained("fused_transformer")
14
15pipeline.enable_model_cpu_offload()
16image = pipeline(
17 "Two women dancing in nature, george barbier style",
18 num_inference_steps=28,
19 guidance_scale=3.5,
20 height=768,
21 width=512,
22 generator=torch.manual_seed(0)
23).images[0]
24image.save("george_barbier_merged.png")1from diffusers import FluxPipeline, AutoPipelineForText2Image, FluxTransformer2DModel, BitsAndBytesConfig
2import torch
3
4ckpt_id = "black-forest-labs/FLUX.1-dev"
5pipeline = FluxPipeline.from_pretrained(
6 ckpt_id, text_encoder=None, text_encoder_2=None, torch_dtype=torch.float16
7)
8pipeline.load_lora_weights("paulprt/george-barbier-qlora-flux", weight_name="pytorch_lora_weights.safetensors")
9pipeline.fuse_lora()
10pipeline.unload_lora_weights()
11
12pipeline.transformer.save_pretrained("fused_transformer")
13
14ckpt_id = "black-forest-labs/FLUX.1-dev"
15bnb_4bit_compute_dtype = torch.bfloat16
16
17nf4_config = BitsAndBytesConfig(
18 load_in_4bit=True,
19 bnb_4bit_quant_type="nf4",
20 bnb_4bit_compute_dtype=bnb_4bit_compute_dtype,
21)
22transformer = FluxTransformer2DModel.from_pretrained(
23 "fused_transformer",
24 quantization_config=nf4_config,
25 torch_dtype=bnb_4bit_compute_dtype,
26)
27
28pipeline = AutoPipelineForText2Image.from_pretrained(
29 ckpt_id, transformer=transformer, torch_dtype=bnb_4bit_compute_dtype
30)
31pipeline.enable_model_cpu_offload()
32
33image = pipeline(
34 "Two women dancing in nature, george barbier style",
35 num_inference_steps=28,
36 guidance_scale=3.5,
37 height=768,
38 width=512,
39 generator=torch.manual_seed(0)
40).images[0]
41image.save("george_barbier_merged.png")