rahul7star commited on
Commit
07fa2e1
·
verified ·
1 Parent(s): 4808c1f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -6
app.py CHANGED
@@ -7,6 +7,14 @@ import imageio
7
  from diffusers.utils.export_utils import export_to_video
8
  import gradio as gr
9
  import tempfile
 
 
 
 
 
 
 
 
10
  import numpy as np
11
  from PIL import Image
12
  import random
@@ -80,13 +88,15 @@ def generate_video(prompt, height, width, negative_prompt, duration_seconds,
80
  generator=torch.Generator(device="cuda").manual_seed(current_seed),
81
  ).frames[0]
82
 
83
- with tempfile.NamedTemporaryFile(suffix=".mp4", delete=False) as tmpfile:
84
- video_path = tmpfile.name
85
-
86
- export_to_video(output_frames_list, video_path, fps=FIXED_FPS)
87
 
88
- # Return seed as string to avoid TypeError
89
- return video_path, str(current_seed)
 
 
90
 
91
  # Build Gradio UI with all parameters
92
  with gr.Blocks(css="body { max-width: 100vw; overflow-x: hidden; }") as demo:
 
7
  from diffusers.utils.export_utils import export_to_video
8
  import gradio as gr
9
  import tempfile
10
+ --- 1. Imports ---
11
+ import os
12
+ import re
13
+ import json
14
+ import random
15
+ import tempfile
16
+ import traceback
17
+ from functools import partial
18
  import numpy as np
19
  from PIL import Image
20
  import random
 
88
  generator=torch.Generator(device="cuda").manual_seed(current_seed),
89
  ).frames[0]
90
 
91
+ filename = f"t2v_{sanitized_prompt}_{current_seed}.mp4"
92
+ temp_dir = tempfile.mkdtemp()
93
+ video_path = os.path.join(temp_dir, filename)
94
+ export_to_video(output_frames_list, video_path, fps=T2V_FIXED_FPS)
95
 
96
+ print(f"✅ Video saved to: {video_path}")
97
+ download_label = f"📥 Download: {filename}"
98
+ return video_path, current_seed, gr.File(value=video_path, visible=True, label=download_label)
99
+ ath, str(current_seed)
100
 
101
  # Build Gradio UI with all parameters
102
  with gr.Blocks(css="body { max-width: 100vw; overflow-x: hidden; }") as demo: