File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 1+ import torch
2+
3+ from diffusers import FluxPipeline , FluxTransformer2DModel , GGUFQuantizationConfig
4+
5+ ckpt_path = (
6+ "/home/mozf/LLM/flux1-dev-Q4_0.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+ "/home/mozf/LLM/FLUX.1-dev" ,
15+ transformer = transformer ,
16+ torch_dtype = torch .bfloat16 ,
17+ ).to ("cuda" )
18+
19+
20+ # pipe.enable_model_cpu_offload()
21+ pipe .transformer .to (memory_format = torch .channels_last )
22+ pipe .transformer .compile (mode = "reduce-overhead" , fullgraph = True )
23+
24+ prompt = "A cat holding a sign that says hello world"
25+ image = pipe (prompt , generator = torch .manual_seed (0 )).images [0 ]
26+ # image.save("flux-gguf.png")
27+
28+ prompt = "A cat holding a sign that says hello world"
29+ image = pipe (prompt , generator = torch .manual_seed (0 )).images [0 ]
30+ image .save ("flux-gguf.png" )
You can’t perform that action at this time.
0 commit comments