Commit
•
d4bc77d
1
Parent(s):
99b8fc2
Update app.py
Browse files
app.py
CHANGED
@@ -23,7 +23,7 @@ import gc
|
|
23 |
from openai import OpenAI
|
24 |
import base64
|
25 |
from io import BytesIO
|
26 |
-
from moviepy
|
27 |
|
28 |
# Load Hugging Face token if needed
|
29 |
hf_token = os.getenv("HF_TOKEN")
|
@@ -290,8 +290,8 @@ def generate_video_from_text(
|
|
290 |
height, width = video_np.shape[1:3]
|
291 |
|
292 |
clip = ImageSequenceClip(list(video_np), fps=frame_rate)
|
293 |
-
|
294 |
-
|
295 |
# Explicitly delete tensors and clear cache
|
296 |
del images
|
297 |
del video_np
|
@@ -383,8 +383,8 @@ def generate_video_from_image(
|
|
383 |
height, width = video_np.shape[1:3]
|
384 |
|
385 |
clip = ImageSequenceClip(list(video_np), fps=frame_rate)
|
386 |
-
|
387 |
-
|
388 |
except Exception as e:
|
389 |
raise gr.Error(
|
390 |
f"An error occurred while generating the video. Please try again. Error: {e}",
|
|
|
23 |
from openai import OpenAI
|
24 |
import base64
|
25 |
from io import BytesIO
|
26 |
+
from moviepy import ImageSequenceClip
|
27 |
|
28 |
# Load Hugging Face token if needed
|
29 |
hf_token = os.getenv("HF_TOKEN")
|
|
|
290 |
height, width = video_np.shape[1:3]
|
291 |
|
292 |
clip = ImageSequenceClip(list(video_np), fps=frame_rate)
|
293 |
+
resized = clip.resized((width,height))
|
294 |
+
resized.write_videofile(output_path, codec="libx264", audio=False)
|
295 |
# Explicitly delete tensors and clear cache
|
296 |
del images
|
297 |
del video_np
|
|
|
383 |
height, width = video_np.shape[1:3]
|
384 |
|
385 |
clip = ImageSequenceClip(list(video_np), fps=frame_rate)
|
386 |
+
resized = clip.resized((width,height))
|
387 |
+
resized.write_videofile(output_path, codec="libx264", audio=False)
|
388 |
except Exception as e:
|
389 |
raise gr.Error(
|
390 |
f"An error occurred while generating the video. Please try again. Error: {e}",
|