Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -14,7 +14,7 @@ device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
| 14 |
model_id = "Wan-AI/Wan2.2-T2V-A14B-Diffusers"
|
| 15 |
vae = AutoencoderKLWan.from_pretrained(model_id, subfolder="vae", torch_dtype=torch.float32)
|
| 16 |
pipe = WanPipeline.from_pretrained(model_id, vae=vae, torch_dtype=torch.bfloat16)
|
| 17 |
-
flow_shift =
|
| 18 |
pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config, flow_shift=flow_shift)
|
| 19 |
pipe.to(device)
|
| 20 |
|
|
@@ -108,7 +108,7 @@ else:
|
|
| 108 |
print("Initialization complete. Gradio is starting...")
|
| 109 |
|
| 110 |
@spaces.GPU()
|
| 111 |
-
def generate(prompt, negative_prompt, width, height, num_inference_steps, optional_lora_id, progress=gr.Progress(track_tqdm=True)):
|
| 112 |
|
| 113 |
# --- Step 1: ALWAYS build the full weight vector from scratch for THIS run ---
|
| 114 |
|
|
@@ -116,7 +116,7 @@ def generate(prompt, negative_prompt, width, height, num_inference_steps, option
|
|
| 116 |
adapter_weights = [0.0] * len(ALL_ADAPTER_NAMES)
|
| 117 |
try:
|
| 118 |
base_lora_index = ALL_ADAPTER_NAMES.index(CAUSVID_NAME)
|
| 119 |
-
adapter_weights[base_lora_index] =
|
| 120 |
except ValueError:
|
| 121 |
pass # Base lora was not loaded, so its weight remains 0.
|
| 122 |
|
|
@@ -145,7 +145,8 @@ def generate(prompt, negative_prompt, width, height, num_inference_steps, option
|
|
| 145 |
width=width,
|
| 146 |
num_frames=1,
|
| 147 |
num_inference_steps=num_inference_steps,
|
| 148 |
-
guidance_scale=
|
|
|
|
| 149 |
)
|
| 150 |
image = output.frames[0][0]
|
| 151 |
image = (image * 255).astype(np.uint8)
|
|
@@ -165,7 +166,9 @@ iface = gr.Interface(
|
|
| 165 |
gr.Slider(minimum=1, maximum=80, step=1, label="Inference Steps", value=10),
|
| 166 |
gr.Textbox(
|
| 167 |
label="Optional LoRA",
|
| 168 |
-
)
|
|
|
|
|
|
|
| 169 |
],
|
| 170 |
outputs=gr.Image(label="output"),
|
| 171 |
)
|
|
|
|
| 14 |
model_id = "Wan-AI/Wan2.2-T2V-A14B-Diffusers"
|
| 15 |
vae = AutoencoderKLWan.from_pretrained(model_id, subfolder="vae", torch_dtype=torch.float32)
|
| 16 |
pipe = WanPipeline.from_pretrained(model_id, vae=vae, torch_dtype=torch.bfloat16)
|
| 17 |
+
flow_shift = 2.0
|
| 18 |
pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config, flow_shift=flow_shift)
|
| 19 |
pipe.to(device)
|
| 20 |
|
|
|
|
| 108 |
print("Initialization complete. Gradio is starting...")
|
| 109 |
|
| 110 |
@spaces.GPU()
|
| 111 |
+
def generate(prompt, negative_prompt, width, height, num_inference_steps, optional_lora_id, guidance_scale= 3.5, guidance_scale_2= 4,progress=gr.Progress(track_tqdm=True)):
|
| 112 |
|
| 113 |
# --- Step 1: ALWAYS build the full weight vector from scratch for THIS run ---
|
| 114 |
|
|
|
|
| 116 |
adapter_weights = [0.0] * len(ALL_ADAPTER_NAMES)
|
| 117 |
try:
|
| 118 |
base_lora_index = ALL_ADAPTER_NAMES.index(CAUSVID_NAME)
|
| 119 |
+
adapter_weights[base_lora_index] = 0.0
|
| 120 |
except ValueError:
|
| 121 |
pass # Base lora was not loaded, so its weight remains 0.
|
| 122 |
|
|
|
|
| 145 |
width=width,
|
| 146 |
num_frames=1,
|
| 147 |
num_inference_steps=num_inference_steps,
|
| 148 |
+
guidance_scale=float(guidance_scale),
|
| 149 |
+
guidance_scale_2=float(guidance_scale_2),
|
| 150 |
)
|
| 151 |
image = output.frames[0][0]
|
| 152 |
image = (image * 255).astype(np.uint8)
|
|
|
|
| 166 |
gr.Slider(minimum=1, maximum=80, step=1, label="Inference Steps", value=10),
|
| 167 |
gr.Textbox(
|
| 168 |
label="Optional LoRA",
|
| 169 |
+
),
|
| 170 |
+
gr.Slider(minimum=1, maximum=20, step=0.5, label="Guidance Scale", value=3.5),
|
| 171 |
+
gr.Slider(minimum=1, maximum=20, step=0.5, label="Guidance Scale_2", value=4),
|
| 172 |
],
|
| 173 |
outputs=gr.Image(label="output"),
|
| 174 |
)
|