jbilcke-hf HF staff commited on
Commit
d267cd3
1 Parent(s): 8705203

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -6,7 +6,7 @@ import os
6
  from glob import glob
7
  from pathlib import Path
8
  from typing import Optional
9
-
10
  import base64
11
  from io import BytesIO
12
  import tempfile
@@ -224,7 +224,10 @@ def sample(
224
 
225
  os.makedirs(output_folder, exist_ok=True)
226
  base_count = len(glob(os.path.join(output_folder, "*.mp4")))
227
- video_path = os.path.join(output_folder, f"{base_count:06d}.mp4")
 
 
 
228
 
229
  with torch.autocast("cuda"):
230
  frames = pipe(
@@ -241,15 +244,15 @@ def sample(
241
 
242
  # we leave default values here
243
  # alternatively we have implemented our own here: export_to_video_file(...)
244
- export_to_video(frames, video_path, fps=hardcoded_fps)
245
 
246
  torch.manual_seed(seed)
247
 
248
- final_video_path = interpolate_video_frames(video_path, enhanced_video_path, output_fps=desired_fps, desired_duration=desired_duration)
249
 
250
 
251
  # Read the content of the video file and encode it to base64
252
- with open(video_path, "rb") as video_file:
253
  video_base64 = base64.b64encode(video_file.read()).decode('utf-8')
254
 
255
  # Prepend the appropriate data URI header with MIME type
 
6
  from glob import glob
7
  from pathlib import Path
8
  from typing import Optional
9
+ import uuid
10
  import base64
11
  from io import BytesIO
12
  import tempfile
 
224
 
225
  os.makedirs(output_folder, exist_ok=True)
226
  base_count = len(glob(os.path.join(output_folder, "*.mp4")))
227
+
228
+ video_uuid = str(uuid.uuid4()).replace("-", "")
229
+ raw_video_path = f"/tmp/{video_uuid}_raw.mp4"
230
+ enhanced_video_path = f"/tmp/{video_uuid}_enhanced.mp4"
231
 
232
  with torch.autocast("cuda"):
233
  frames = pipe(
 
244
 
245
  # we leave default values here
246
  # alternatively we have implemented our own here: export_to_video_file(...)
247
+ export_to_video(frames, raw_video_path, fps=hardcoded_fps)
248
 
249
  torch.manual_seed(seed)
250
 
251
+ final_video_path = interpolate_video_frames(raw_video_path, enhanced_video_path, output_fps=desired_fps, desired_duration=desired_duration)
252
 
253
 
254
  # Read the content of the video file and encode it to base64
255
+ with open(final_video_path, "rb") as video_file:
256
  video_base64 = base64.b64encode(video_file.read()).decode('utf-8')
257
 
258
  # Prepend the appropriate data URI header with MIME type