hina19 commited on
Commit
61615e4
Β·
verified Β·
1 Parent(s): 62ee604

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -19,11 +19,12 @@ client = OpenAI(
19
  # Streamlit App UI
20
  st.title("πŸŽ₯ AI-Powered Video Summarization")
21
  # Define custom CSS
 
22
  st.markdown(
23
  """
24
  <style>
25
- body, .stApp {
26
- font-size: 20px !important;
27
  font-weight: bold;
28
  color: black;
29
  }
@@ -31,6 +32,7 @@ st.markdown(
31
  """,
32
  unsafe_allow_html=True
33
  )
 
34
  def set_background(image_file):
35
  with open(image_file, "rb") as image:
36
  encoded_string = base64.b64encode(image.read()).decode()
@@ -55,7 +57,7 @@ def set_background(image_file):
55
  set_background("background.jpg")
56
 
57
 
58
- uploaded_file = st.file_uploader("<h2 style='font-size:30px; color:black;'>πŸ“€ Upload a Video File</h2>", type=["mp4"])
59
 
60
  if uploaded_file:
61
  video_path = "input_video.mp4"
@@ -65,7 +67,7 @@ if uploaded_file:
65
  st.video(video_path)
66
 
67
  # Scene Detection & Frame Extraction
68
- st.write("<h2 style='font-size:30px; color:black;'>πŸ” Detecting scene changes and extracting key frames...</h2>")
69
 
70
  def extract_key_frames(video_path, output_folder="frames"):
71
  os.makedirs(output_folder, exist_ok=True)
@@ -90,7 +92,7 @@ if uploaded_file:
90
  extract_key_frames(video_path)
91
 
92
  # Caption Generation
93
- st.write("<h2 style='font-size:30px; color:black;'>πŸ“ Generating captions for extracted frames...</h2>")
94
 
95
  def generate_caption(image_path):
96
  image = Image.open(image_path).convert("RGB")
@@ -107,7 +109,7 @@ if uploaded_file:
107
  # st.write("πŸ“„ Generated Captions:", captions)
108
 
109
  # Summarization
110
- st.write("<h2 style='font-size:30px; color:black;'>πŸ“– Summarizing captions using AI...</h2>")
111
 
112
  def summarize_captions(captions):
113
  prompt = f"Summarize the following sequence of video frames into a meaningful story under 800 characters:\n\n{captions}"
@@ -125,7 +127,7 @@ if uploaded_file:
125
  st.write("πŸ“Œ Video Summary:", summary)
126
 
127
  # Text-to-Speech
128
- st.write("<h2 style='font-size:30px; color:black;'>πŸ”Š Generating voice narration...</h2>")
129
 
130
  def text_to_speech(text, output_audio="summary_audio.mp3"):
131
  tts = gTTS(text, lang="en")
 
19
  # Streamlit App UI
20
  st.title("πŸŽ₯ AI-Powered Video Summarization")
21
  # Define custom CSS
22
+ # Custom CSS for larger, darker text
23
  st.markdown(
24
  """
25
  <style>
26
+ .big-font {
27
+ font-size: 30px !important;
28
  font-weight: bold;
29
  color: black;
30
  }
 
32
  """,
33
  unsafe_allow_html=True
34
  )
35
+
36
  def set_background(image_file):
37
  with open(image_file, "rb") as image:
38
  encoded_string = base64.b64encode(image.read()).decode()
 
57
  set_background("background.jpg")
58
 
59
 
60
+ uploaded_file = st.file_uploader("πŸ“€ Upload a Video File", type=["mp4"])
61
 
62
  if uploaded_file:
63
  video_path = "input_video.mp4"
 
67
  st.video(video_path)
68
 
69
  # Scene Detection & Frame Extraction
70
+ st.write("πŸ” Detecting scene changes and extracting key frames...")
71
 
72
  def extract_key_frames(video_path, output_folder="frames"):
73
  os.makedirs(output_folder, exist_ok=True)
 
92
  extract_key_frames(video_path)
93
 
94
  # Caption Generation
95
+ st.write("πŸ“ Generating captions for extracted frames...")
96
 
97
  def generate_caption(image_path):
98
  image = Image.open(image_path).convert("RGB")
 
109
  # st.write("πŸ“„ Generated Captions:", captions)
110
 
111
  # Summarization
112
+ st.write("πŸ“– Summarizing captions using AI...")
113
 
114
  def summarize_captions(captions):
115
  prompt = f"Summarize the following sequence of video frames into a meaningful story under 800 characters:\n\n{captions}"
 
127
  st.write("πŸ“Œ Video Summary:", summary)
128
 
129
  # Text-to-Speech
130
+ st.write("πŸ”Š Generating voice narration...")
131
 
132
  def text_to_speech(text, output_audio="summary_audio.mp3"):
133
  tts = gTTS(text, lang="en")