K00B404 commited on
Commit
8c70742
·
verified ·
1 Parent(s): 8f2c90a

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+
3
+ from diffusers import FluxPipeline, FluxTransformer2DModel, GGUFQuantizationConfig
4
+
5
+ ckpt_path = (
6
+ "https://huggingface.co/city96/FLUX.1-dev-gguf/blob/main/flux1-dev-Q2_K.gguf"
7
+ )
8
+ transformer = FluxTransformer2DModel.from_single_file(
9
+ ckpt_path,
10
+ quantization_config=GGUFQuantizationConfig(compute_dtype=torch.bfloat16),
11
+ torch_dtype=torch.bfloat16,
12
+ )
13
+ pipe = FluxPipeline.from_pretrained(
14
+ "black-forest-labs/FLUX.1-dev",
15
+ transformer=transformer,
16
+ torch_dtype=torch.bfloat16,
17
+ )
18
+ pipe.enable_model_cpu_offload()
19
+ prompt = "A cat holding a sign that says hello world"
20
+ image = pipe(prompt, generator=torch.manual_seed(0)).images[0]
21
+ image.save("flux-gguf.png")