Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -13,12 +13,16 @@ import numpy as np
|
|
13 |
import gradio as gr
|
14 |
import spaces
|
15 |
|
|
|
|
|
16 |
model_id = "Wan-AI/Wan2.1-T2V-1.3B-Diffusers"
|
17 |
vae = AutoencoderKLWan.from_pretrained(model_id, subfolder="vae", torch_dtype=torch.float32)
|
18 |
pipe = WanPipeline.from_pretrained(model_id, vae=vae, torch_dtype=torch.bfloat16)
|
19 |
flow_shift = 1.0 #5.0 1.0 for image, 5.0 for 720P, 3.0 for 480P
|
20 |
pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config, flow_shift=flow_shift)
|
21 |
|
|
|
|
|
22 |
# Configure DDIMScheduler with a beta schedule
|
23 |
# pipe.scheduler = DDIMScheduler.from_config(
|
24 |
# pipe.scheduler.config,
|
@@ -82,7 +86,7 @@ def generate(prompt, negative_prompt, width=1024, height=1024, num_inference_ste
|
|
82 |
pipe.set_adapters([DEFAULT_LORA_NAME], adapter_weights=[1.0])
|
83 |
|
84 |
|
85 |
-
pipe.to("cuda")
|
86 |
# apply_first_block_cache(pipe.transformer, FirstBlockCacheConfig(threshold=0.2))
|
87 |
apply_cache_on_pipe(
|
88 |
pipe,
|
|
|
13 |
import gradio as gr
|
14 |
import spaces
|
15 |
|
16 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
17 |
+
|
18 |
model_id = "Wan-AI/Wan2.1-T2V-1.3B-Diffusers"
|
19 |
vae = AutoencoderKLWan.from_pretrained(model_id, subfolder="vae", torch_dtype=torch.float32)
|
20 |
pipe = WanPipeline.from_pretrained(model_id, vae=vae, torch_dtype=torch.bfloat16)
|
21 |
flow_shift = 1.0 #5.0 1.0 for image, 5.0 for 720P, 3.0 for 480P
|
22 |
pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config, flow_shift=flow_shift)
|
23 |
|
24 |
+
pipe.to(device)
|
25 |
+
|
26 |
# Configure DDIMScheduler with a beta schedule
|
27 |
# pipe.scheduler = DDIMScheduler.from_config(
|
28 |
# pipe.scheduler.config,
|
|
|
86 |
pipe.set_adapters([DEFAULT_LORA_NAME], adapter_weights=[1.0])
|
87 |
|
88 |
|
89 |
+
#pipe.to("cuda")
|
90 |
# apply_first_block_cache(pipe.transformer, FirstBlockCacheConfig(threshold=0.2))
|
91 |
apply_cache_on_pipe(
|
92 |
pipe,
|