Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -150,26 +150,43 @@ def infer_camera_edit(
|
|
| 150 |
|
| 151 |
return result, seed, prompt
|
| 152 |
|
| 153 |
-
def create_video_between_images(input_image
|
| 154 |
"""Create a video between the input and output images."""
|
| 155 |
if input_image is None or output_image is None:
|
| 156 |
raise gr.Error("Both input and output images are required to create a video.")
|
| 157 |
-
|
| 158 |
try:
|
| 159 |
-
#
|
| 160 |
-
if isinstance(input_image,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as tmp:
|
| 162 |
input_image.save(tmp.name)
|
| 163 |
input_image_path = tmp.name
|
| 164 |
-
|
| 165 |
input_image_path = input_image
|
|
|
|
|
|
|
| 166 |
|
| 167 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as tmp:
|
| 169 |
output_image.save(tmp.name)
|
| 170 |
output_image_path = tmp.name
|
| 171 |
-
|
| 172 |
output_image_path = output_image
|
|
|
|
|
|
|
| 173 |
|
| 174 |
# Generate the video
|
| 175 |
video_path = _generate_video_segment(
|
|
|
|
| 150 |
|
| 151 |
return result, seed, prompt
|
| 152 |
|
| 153 |
+
def create_video_between_images(input_image, output_image, prompt: str) -> str:
|
| 154 |
"""Create a video between the input and output images."""
|
| 155 |
if input_image is None or output_image is None:
|
| 156 |
raise gr.Error("Both input and output images are required to create a video.")
|
| 157 |
+
|
| 158 |
try:
|
| 159 |
+
# Convert input image to file path
|
| 160 |
+
if isinstance(input_image, np.ndarray):
|
| 161 |
+
# Convert numpy array to PIL Image
|
| 162 |
+
input_pil = Image.fromarray(input_image.astype('uint8'))
|
| 163 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as tmp:
|
| 164 |
+
input_pil.save(tmp.name)
|
| 165 |
+
input_image_path = tmp.name
|
| 166 |
+
elif isinstance(input_image, Image.Image):
|
| 167 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as tmp:
|
| 168 |
input_image.save(tmp.name)
|
| 169 |
input_image_path = tmp.name
|
| 170 |
+
elif isinstance(input_image, str):
|
| 171 |
input_image_path = input_image
|
| 172 |
+
else:
|
| 173 |
+
raise gr.Error(f"Unsupported input image type: {type(input_image)}")
|
| 174 |
|
| 175 |
+
# Convert output image to file path
|
| 176 |
+
if isinstance(output_image, np.ndarray):
|
| 177 |
+
# Convert numpy array to PIL Image
|
| 178 |
+
output_pil = Image.fromarray(output_image.astype('uint8'))
|
| 179 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as tmp:
|
| 180 |
+
output_pil.save(tmp.name)
|
| 181 |
+
output_image_path = tmp.name
|
| 182 |
+
elif isinstance(output_image, Image.Image):
|
| 183 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as tmp:
|
| 184 |
output_image.save(tmp.name)
|
| 185 |
output_image_path = tmp.name
|
| 186 |
+
elif isinstance(output_image, str):
|
| 187 |
output_image_path = output_image
|
| 188 |
+
else:
|
| 189 |
+
raise gr.Error(f"Unsupported output image type: {type(output_image)}")
|
| 190 |
|
| 191 |
# Generate the video
|
| 192 |
video_path = _generate_video_segment(
|