Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
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 =
|
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, "
|
|
|
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, "
|
|
|
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 ---
|