alexnasa commited on
Commit
6ed7319
·
verified ·
1 Parent(s): 65ac2a1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -9
app.py CHANGED
@@ -1,5 +1,6 @@
1
  import sys
2
  from pathlib import Path
 
3
 
4
  # Add packages to Python path
5
  current_dir = Path(__file__).parent
@@ -150,11 +151,11 @@ def encode_prompt(
150
  if negative_prompt:
151
  video_context_negative, audio_context_negative = encode_text_simple(text_encoder, negative_prompt)
152
 
153
- # Save embeddings to file
154
  output_dir = Path("embeddings")
155
  output_dir.mkdir(exist_ok=True)
156
- output_path = output_dir / f"embedding_{int(time.time())}.pt"
157
-
158
  # Save embeddings (with negative contexts if provided)
159
  embedding_data = {
160
  'video_context': video_context.cpu(),
@@ -405,18 +406,20 @@ def generate_video(
405
  frame_rate = 24.0
406
  num_frames = int(duration * frame_rate) + 1 # +1 to ensure we meet the duration
407
 
408
- # Create output directory if it doesn't exist
 
409
  output_dir = Path("outputs")
410
  output_dir.mkdir(exist_ok=True)
411
- output_path = output_dir / f"video_{current_seed}.mp4"
 
 
 
412
 
413
  # Handle image input
414
  images = []
415
- temp_image_path = None # Initialize to None
416
-
417
  if input_image is not None:
418
- # Save uploaded image temporarily
419
- temp_image_path = output_dir / f"temp_input_{current_seed}.jpg"
420
  if hasattr(input_image, 'save'):
421
  input_image.save(temp_image_path)
422
  else:
 
1
  import sys
2
  from pathlib import Path
3
+ import uuid
4
 
5
  # Add packages to Python path
6
  current_dir = Path(__file__).parent
 
151
  if negative_prompt:
152
  video_context_negative, audio_context_negative = encode_text_simple(text_encoder, negative_prompt)
153
 
154
+ run_id = uuid.uuid4().hex
155
  output_dir = Path("embeddings")
156
  output_dir.mkdir(exist_ok=True)
157
+ output_path = output_dir / f"embedding_{run_id}.pt"
158
+
159
  # Save embeddings (with negative contexts if provided)
160
  embedding_data = {
161
  'video_context': video_context.cpu(),
 
406
  frame_rate = 24.0
407
  num_frames = int(duration * frame_rate) + 1 # +1 to ensure we meet the duration
408
 
409
+ run_id = uuid.uuid4().hex
410
+
411
  output_dir = Path("outputs")
412
  output_dir.mkdir(exist_ok=True)
413
+
414
+ output_path = output_dir / f"video_{run_id}.mp4"
415
+ temp_image_path = output_dir / f"temp_input_{run_id}.jpg"
416
+
417
 
418
  # Handle image input
419
  images = []
420
+
 
421
  if input_image is not None:
422
+
 
423
  if hasattr(input_image, 'save'):
424
  input_image.save(temp_image_path)
425
  else: