-
Notifications
You must be signed in to change notification settings - Fork 0
/
ui.py
34 lines (30 loc) · 1.13 KB
/
ui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import streamlit as st
import requests
BACKEND_URL = "http://127.0.0.1:5000/predict"
st.title("Shoplifting Detection")
st.write("Upload a video and get video with shoplifting detection!")
uploaded_video = st.file_uploader("Choose a video", type=["mp4", "avi"])
if uploaded_video is not None:
if st.button("Predict"):
with open(uploaded_video.name, "wb") as f:
f.write(uploaded_video.getbuffer())
files = {
"video": (
uploaded_video.name,
uploaded_video.read(),
)
}
response = requests.post(BACKEND_URL, files=files)
result = response.json()
if "error" in result:
st.error(result["error"])
else:
output_path = result["output_path"]
video_info = result.get("video_info")
st.success("Prediction complete!")
with open(output_path, "rb") as video_bytes:
st.download_button(
label="Download Processed Video",
data=video_bytes,
file_name=f"processed_{uploaded_video.name}",
)