Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import tempfile
|
3 |
+
from video_processor import process_video
|
4 |
+
from qa_engine import get_answer
|
5 |
+
from database import insert_video_data, search_similar_videos
|
6 |
+
|
7 |
+
st.title("Intelligent Video Q&A App with Gemini Vision Pro")
|
8 |
+
|
9 |
+
uploaded_file = st.file_uploader("Choose a video file", type=["mp4", "avi", "mov"])
|
10 |
+
if uploaded_file is not None:
|
11 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp4") as tmp_file:
|
12 |
+
tmp_file.write(uploaded_file.getvalue())
|
13 |
+
video_path = tmp_file.name
|
14 |
+
|
15 |
+
summary_words = st.slider("Number of words in summary", 50, 500, 200)
|
16 |
+
|
17 |
+
if st.button("Process Video"):
|
18 |
+
with st.spinner("Processing video with Gemini Vision Pro..."):
|
19 |
+
video_data = process_video(video_path, summary_words)
|
20 |
+
insert_video_data(video_data)
|
21 |
+
st.success("Video processed successfully!")
|
22 |
+
|
23 |
+
st.subheader("Video Summary")
|
24 |
+
st.write(video_data['summary'])
|
25 |
+
|
26 |
+
st.subheader("Extracted Code")
|
27 |
+
st.code(video_data['extracted_code'])
|
28 |
+
|
29 |
+
st.subheader("Similar Videos")
|
30 |
+
similar_videos = search_similar_videos(video_data['summary'])
|
31 |
+
for video in similar_videos:
|
32 |
+
st.write(f"- {video['title']}")
|
33 |
+
|
34 |
+
question = st.text_input("Ask a question about the video:")
|
35 |
+
if question and 'video_data' in locals():
|
36 |
+
answer = get_answer(question, video_data)
|
37 |
+
st.write("Answer:", answer)
|