saima730 commited on
Commit
5ab1003
·
verified ·
1 Parent(s): 17c5a86

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -14
app.py CHANGED
@@ -1,4 +1,8 @@
1
- import gradio as gr
 
 
 
 
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, concatenate_videoclips
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
- # Define Gradio Interface
57
- def gradio_interface(prompt):
58
- video_path = generate_educational_video(prompt)
59
- return video_path
 
 
 
 
60
 
61
- interface = gr.Interface(
62
- fn=gradio_interface,
63
- inputs="text",
64
- outputs="video",
65
- title="Educational Video Generator",
66
- description="Enter a prompt to generate a video."
67
- )
68
 
69
- interface.launch()
 
 
 
 
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.")