Update app.py
Browse files
app.py
CHANGED
@@ -11,8 +11,9 @@ from transformers import (
|
|
11 |
AutoImageProcessor,
|
12 |
AutoModelForObjectDetection
|
13 |
)
|
14 |
-
import os
|
15 |
import tempfile
|
|
|
|
|
16 |
|
17 |
# -------------------- Configuration -------------------- #
|
18 |
DEVICE = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
@@ -259,19 +260,10 @@ def analyze_video(video_path):
|
|
259 |
print(f"\nπ― Final Score: {score}") # Debugging line
|
260 |
return score # β
Ensure this score is returned properly
|
261 |
|
262 |
-
|
263 |
-
|
264 |
# -------------------- Execution -------------------- #
|
265 |
-
|
266 |
-
import tempfile
|
267 |
|
268 |
-
|
269 |
-
with open(file_name) as f:
|
270 |
-
st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
|
271 |
-
local_css("style.css") # Ensure you have a separate style.css file
|
272 |
-
|
273 |
-
# Sidebar for Navigation
|
274 |
-
# Navigation
|
275 |
st.sidebar.title("Navigation")
|
276 |
page = st.sidebar.radio("", ["Home", "Analyze Video", "About"])
|
277 |
|
@@ -307,7 +299,7 @@ if page == "Home":
|
|
307 |
|
308 |
|
309 |
elif page == "Analyze Video":
|
310 |
-
uploaded_file = st.file_uploader("Upload a Video", type=["mp4", "mov"]
|
311 |
|
312 |
if uploaded_file is not None:
|
313 |
# Save uploaded file to a temporary location
|
@@ -317,14 +309,14 @@ elif page == "Analyze Video":
|
|
317 |
|
318 |
st.video(temp_video_path)
|
319 |
|
320 |
-
if st.button("Analyze Video",
|
321 |
with st.spinner("Analyzing..."):
|
322 |
try:
|
323 |
score = analyze_video(temp_video_path) # β
Ensure function exists
|
324 |
|
325 |
-
# Debugging Line
|
326 |
st.write(f"Analysis Score: {score}")
|
327 |
float(score)
|
|
|
328 |
# Display result based on score
|
329 |
if score >= 3.5 :
|
330 |
st.markdown(f"""
|
|
|
11 |
AutoImageProcessor,
|
12 |
AutoModelForObjectDetection
|
13 |
)
|
|
|
14 |
import tempfile
|
15 |
+
import streamlit as st
|
16 |
+
from huggingface_hub import hf_hub_download
|
17 |
|
18 |
# -------------------- Configuration -------------------- #
|
19 |
DEVICE = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
|
|
260 |
print(f"\nπ― Final Score: {score}") # Debugging line
|
261 |
return score # β
Ensure this score is returned properly
|
262 |
|
|
|
|
|
263 |
# -------------------- Execution -------------------- #
|
264 |
+
# Streamlit Interface
|
|
|
265 |
|
266 |
+
# Side Navigation
|
|
|
|
|
|
|
|
|
|
|
|
|
267 |
st.sidebar.title("Navigation")
|
268 |
page = st.sidebar.radio("", ["Home", "Analyze Video", "About"])
|
269 |
|
|
|
299 |
|
300 |
|
301 |
elif page == "Analyze Video":
|
302 |
+
uploaded_file = st.file_uploader("Upload a Video", type=["mp4", "mov"])
|
303 |
|
304 |
if uploaded_file is not None:
|
305 |
# Save uploaded file to a temporary location
|
|
|
309 |
|
310 |
st.video(temp_video_path)
|
311 |
|
312 |
+
if st.button("Analyze Video", label_visibility="collapsed"):
|
313 |
with st.spinner("Analyzing..."):
|
314 |
try:
|
315 |
score = analyze_video(temp_video_path) # β
Ensure function exists
|
316 |
|
|
|
317 |
st.write(f"Analysis Score: {score}")
|
318 |
float(score)
|
319 |
+
|
320 |
# Display result based on score
|
321 |
if score >= 3.5 :
|
322 |
st.markdown(f"""
|