Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,8 @@
|
|
1 |
-
|
|
|
|
|
|
|
|
|
2 |
import torch
|
3 |
from transformers import pipeline
|
4 |
from diffusers import AnimateDiffPipeline, MotionAdapter, EulerDiscreteScheduler
|
@@ -6,7 +10,7 @@ from diffusers.utils import export_to_gif
|
|
6 |
from huggingface_hub import hf_hub_download
|
7 |
from safetensors.torch import load_file
|
8 |
from gtts import gTTS
|
9 |
-
from moviepy.editor import VideoFileClip, AudioFileClip
|
10 |
import os
|
11 |
|
12 |
# Load the text generation model
|
@@ -53,17 +57,19 @@ def generate_educational_video(prompt):
|
|
53 |
video_file = create_video(animation_file, audio_file)
|
54 |
return video_file
|
55 |
|
56 |
-
#
|
57 |
-
|
58 |
-
|
59 |
-
|
|
|
|
|
|
|
|
|
60 |
|
61 |
-
|
62 |
-
|
63 |
-
inputs="text",
|
64 |
-
outputs="video",
|
65 |
-
title="Educational Video Generator",
|
66 |
-
description="Enter a prompt to generate a video."
|
67 |
-
)
|
68 |
|
69 |
-
|
|
|
|
|
|
|
|
1 |
+
# Install necessary packages
|
2 |
+
!pip install streamlit transformers diffusers gtts moviepy safetensors torch gradio
|
3 |
+
|
4 |
+
# Import libraries
|
5 |
+
import streamlit as st
|
6 |
import torch
|
7 |
from transformers import pipeline
|
8 |
from diffusers import AnimateDiffPipeline, MotionAdapter, EulerDiscreteScheduler
|
|
|
10 |
from huggingface_hub import hf_hub_download
|
11 |
from safetensors.torch import load_file
|
12 |
from gtts import gTTS
|
13 |
+
from moviepy.editor import VideoFileClip, AudioFileClip
|
14 |
import os
|
15 |
|
16 |
# Load the text generation model
|
|
|
57 |
video_file = create_video(animation_file, audio_file)
|
58 |
return video_file
|
59 |
|
60 |
+
# Streamlit UI
|
61 |
+
st.title("Educational Video Generator")
|
62 |
+
|
63 |
+
prompt = st.text_input("Enter your prompt here:")
|
64 |
+
|
65 |
+
if st.button("Generate Video"):
|
66 |
+
if prompt:
|
67 |
+
st.write("Generating video, please wait...")
|
68 |
|
69 |
+
# Generate the video
|
70 |
+
video_path = generate_educational_video(prompt)
|
|
|
|
|
|
|
|
|
|
|
71 |
|
72 |
+
# Display the video in Streamlit
|
73 |
+
st.video(video_path)
|
74 |
+
else:
|
75 |
+
st.warning("Please enter a prompt.")
|