Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,37 +2,24 @@ import gradio as gr
|
|
| 2 |
import time
|
| 3 |
import shutil
|
| 4 |
|
| 5 |
-
def
|
| 6 |
-
|
| 7 |
-
Simulates video generation for testing UI and API.
|
| 8 |
-
Clamps duration between 1 and 8 seconds.
|
| 9 |
-
Returns a placeholder MP4 file.
|
| 10 |
-
"""
|
| 11 |
-
if duration < 1:
|
| 12 |
-
duration = 1
|
| 13 |
-
elif duration > 8:
|
| 14 |
-
duration = 8
|
| 15 |
-
|
| 16 |
-
print(f"Generating video for prompt: '{prompt}' with duration {duration}s")
|
| 17 |
-
|
| 18 |
time.sleep(1)
|
| 19 |
-
|
| 20 |
placeholder_video = "placeholder.mp4"
|
| 21 |
output_path = "output.mp4"
|
| 22 |
shutil.copyfile(placeholder_video, output_path)
|
| 23 |
-
|
| 24 |
return output_path
|
| 25 |
|
| 26 |
with gr.Blocks() as demo:
|
| 27 |
-
gr.Markdown(""
|
| 28 |
-
|
| 29 |
-
""")
|
| 30 |
-
|
| 31 |
prompt_input = gr.Textbox(label="Prompt", placeholder="Describe your scene")
|
| 32 |
duration_input = gr.Slider(label="Duration (sec)", minimum=1, maximum=8, step=1, value=6)
|
| 33 |
submit_btn = gr.Button("Generate Video")
|
| 34 |
output_video = gr.Video(label="Generated Video")
|
| 35 |
|
| 36 |
-
submit_btn.click(
|
|
|
|
|
|
|
| 37 |
|
| 38 |
demo.launch()
|
|
|
|
| 2 |
import time
|
| 3 |
import shutil
|
| 4 |
|
| 5 |
+
def generate_video(prompt, duration):
|
| 6 |
+
duration = max(1, min(duration, 8))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
time.sleep(1)
|
|
|
|
| 8 |
placeholder_video = "placeholder.mp4"
|
| 9 |
output_path = "output.mp4"
|
| 10 |
shutil.copyfile(placeholder_video, output_path)
|
|
|
|
| 11 |
return output_path
|
| 12 |
|
| 13 |
with gr.Blocks() as demo:
|
| 14 |
+
gr.Markdown("## Wan 2.2 Video Generator (Local Test Placeholder)")
|
| 15 |
+
|
|
|
|
|
|
|
| 16 |
prompt_input = gr.Textbox(label="Prompt", placeholder="Describe your scene")
|
| 17 |
duration_input = gr.Slider(label="Duration (sec)", minimum=1, maximum=8, step=1, value=6)
|
| 18 |
submit_btn = gr.Button("Generate Video")
|
| 19 |
output_video = gr.Video(label="Generated Video")
|
| 20 |
|
| 21 |
+
submit_btn.click(lambda prompt, duration: generate_video(prompt, duration),
|
| 22 |
+
inputs=[prompt_input, duration_input],
|
| 23 |
+
outputs=output_video)
|
| 24 |
|
| 25 |
demo.launch()
|