Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,28 +1,26 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
pipe = WanPipeline.from_pretrained(
|
| 6 |
-
"Wan-AI/Wan2.2-TI2V-5B-Diffusers",
|
| 7 |
-
torch_dtype=torch.float16
|
| 8 |
-
)
|
| 9 |
-
pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
|
| 10 |
-
pipe = pipe.to("cuda")
|
| 11 |
|
| 12 |
def generate_video(prompt, duration):
|
| 13 |
"""
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
Returns the path to the saved MP4 file.
|
| 17 |
"""
|
| 18 |
duration = max(1, min(duration, 8))
|
| 19 |
-
video
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
|
|
|
| 24 |
with gr.Blocks() as demo:
|
| 25 |
-
gr.Markdown("## Wan 2.2 Video Generator (Local)")
|
| 26 |
|
| 27 |
with gr.Row():
|
| 28 |
prompt_input = gr.Textbox(label="Prompt", placeholder="Describe your scene")
|
|
@@ -32,5 +30,4 @@ with gr.Blocks() as demo:
|
|
| 32 |
|
| 33 |
submit_btn.click(generate_video, inputs=[prompt_input, duration_input], outputs=output_video)
|
| 34 |
|
| 35 |
-
|
| 36 |
-
demo.launch(api_name="generate-video")
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import time
|
| 3 |
+
import shutil
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
def generate_video(prompt, duration):
|
| 6 |
"""
|
| 7 |
+
Simulates video generation for testing UI and API.
|
| 8 |
+
Returns a placeholder MP4 file.
|
|
|
|
| 9 |
"""
|
| 10 |
duration = max(1, min(duration, 8))
|
| 11 |
+
print(f"Generating video for prompt: '{prompt}' with duration {duration}s")
|
| 12 |
+
|
| 13 |
+
time.sleep(1)
|
| 14 |
+
|
| 15 |
+
placeholder_video = "placeholder.mp4"
|
| 16 |
+
output_path = "output.mp4"
|
| 17 |
+
shutil.copyfile(placeholder_video, output_path)
|
| 18 |
+
|
| 19 |
+
return output_path
|
| 20 |
|
| 21 |
+
# Gradio UI + API
|
| 22 |
with gr.Blocks() as demo:
|
| 23 |
+
gr.Markdown("## Wan 2.2 Video Generator (Local Test Placeholder)")
|
| 24 |
|
| 25 |
with gr.Row():
|
| 26 |
prompt_input = gr.Textbox(label="Prompt", placeholder="Describe your scene")
|
|
|
|
| 30 |
|
| 31 |
submit_btn.click(generate_video, inputs=[prompt_input, duration_input], outputs=output_video)
|
| 32 |
|
| 33 |
+
demo.launch(api_name="generate-video")
|
|
|