multimodalart HF Staff commited on
Commit
3d58992
·
verified ·
1 Parent(s): 78f540b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -103,7 +103,7 @@ def calculate_dimensions(width, height):
103
  @spaces.GPU(duration=120)
104
  def generate_video(prompt, first_image_path, last_image_path, duration_seconds):
105
  # Create a temporary directory for resized images
106
- temp_dir = f"temp_resized_{uuid.uuid4().hex}"
107
  os.makedirs(temp_dir, exist_ok=True)
108
 
109
  with torch.inference_mode():
@@ -118,13 +118,15 @@ def generate_video(prompt, first_image_path, last_image_path, duration_seconds):
118
  # Resize first image
119
  with Image.open(first_image_path) as img:
120
  img_resized = img.resize((target_width, target_height), Image.Resampling.LANCZOS)
121
- resized_first_path = os.path.join(temp_dir, "first_frame_resized.png")
 
122
  img_resized.save(resized_first_path)
123
 
124
  # Resize second image to match the target dimensions
125
  with Image.open(last_image_path) as img:
126
  img_resized = img.resize((target_width, target_height), Image.Resampling.LANCZOS)
127
- resized_last_path = os.path.join(temp_dir, "last_frame_resized.png")
 
128
  img_resized.save(resized_last_path)
129
  print(f"Images resized to {target_width}x{target_height} and saved temporarily.")
130
  # --- End Preprocessing ---
 
103
  @spaces.GPU(duration=120)
104
  def generate_video(prompt, first_image_path, last_image_path, duration_seconds):
105
  # Create a temporary directory for resized images
106
+ temp_dir = "input"
107
  os.makedirs(temp_dir, exist_ok=True)
108
 
109
  with torch.inference_mode():
 
118
  # Resize first image
119
  with Image.open(first_image_path) as img:
120
  img_resized = img.resize((target_width, target_height), Image.Resampling.LANCZOS)
121
+ resized_first_path = os.path.join(temp_dir, f"first_frame_resized_{uuid.uuid4().hex}.png")
122
+ print(resized_first_path)
123
  img_resized.save(resized_first_path)
124
 
125
  # Resize second image to match the target dimensions
126
  with Image.open(last_image_path) as img:
127
  img_resized = img.resize((target_width, target_height), Image.Resampling.LANCZOS)
128
+ resized_last_path = os.path.join(temp_dir, f"last_frame_resized_{uuid.uuid4().hex}.png")
129
+ print(resized_last_path)
130
  img_resized.save(resized_last_path)
131
  print(f"Images resized to {target_width}x{target_height} and saved temporarily.")
132
  # --- End Preprocessing ---