Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -30,12 +30,37 @@ class timer:
|
|
30 |
if not path.exists(cache_path):
|
31 |
os.makedirs(cache_path, exist_ok=True)
|
32 |
from huggingface_hub import hf_hub_download
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
-
hf_hub_download(repo_id="city96/FLUX.1-schnell-gguf", filename="flux1-schnell-Q3_K_S.gguf")
|
35 |
pipe = FluxPipeline.from_pretrained("flux1-schnell-Q3_K_S.gguf")
|
36 |
pipe.load_lora_weights(hf_hub_download("ByteDance/Hyper-SD", "Hyper-FLUX.1-dev-8steps-lora.safetensors"))
|
37 |
pipe.fuse_lora(lora_scale=0.125)
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
41 |
gr.Markdown(
|
|
|
30 |
if not path.exists(cache_path):
|
31 |
os.makedirs(cache_path, exist_ok=True)
|
32 |
from huggingface_hub import hf_hub_download
|
33 |
+
import torch
|
34 |
+
|
35 |
+
from diffusers import FluxPipeline, FluxTransformer2DModel, GGUFQuantizationConfig
|
36 |
+
|
37 |
+
ckpt_path = (
|
38 |
+
"https://huggingface.co/city96/FLUX.1-dev-gguf/blob/main/flux1-schnell-Q3_K_S.gguf"
|
39 |
+
)
|
40 |
+
transformer = FluxTransformer2DModel.from_single_file(
|
41 |
+
ckpt_path,
|
42 |
+
quantization_config=GGUFQuantizationConfig(compute_dtype=torch.bfloat16),
|
43 |
+
torch_dtype=torch.bfloat16,
|
44 |
+
)
|
45 |
+
pipe = FluxPipeline.from_pretrained(
|
46 |
+
"black-forest-labs/FLUX.1-dev",
|
47 |
+
transformer=transformer,
|
48 |
+
torch_dtype=torch.bfloat16,
|
49 |
+
)
|
50 |
|
|
|
51 |
pipe = FluxPipeline.from_pretrained("flux1-schnell-Q3_K_S.gguf")
|
52 |
pipe.load_lora_weights(hf_hub_download("ByteDance/Hyper-SD", "Hyper-FLUX.1-dev-8steps-lora.safetensors"))
|
53 |
pipe.fuse_lora(lora_scale=0.125)
|
54 |
+
|
55 |
+
pipe.enable_model_cpu_offload()
|
56 |
+
prompt = "A cat holding a sign that says hello world"
|
57 |
+
image = pipe(prompt, generator=torch.manual_seed(0)).images[0]
|
58 |
+
image.save("flux-gguf.png")
|
59 |
+
|
60 |
+
|
61 |
+
#hf_hub_download(repo_id="city96/FLUX.1-schnell-gguf", filename="flux1-schnell-Q3_K_S.gguf")
|
62 |
+
|
63 |
+
pipe.to(device="cpu", dtype=torch.bfloat16)
|
64 |
|
65 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
66 |
gr.Markdown(
|