File size: 1,073 Bytes
fafde43
 
 
b412cbb
 
fafde43
 
 
b412cbb
fafde43
a08c0a1
566921d
fafde43
 
 
 
 
7885d83
fafde43
 
b412cbb
fafde43
 
250c6f0
fafde43
 
 
9779b74
 
 
 
 
da92d74
4ebab5e
cd63ff8
b0d17a8
4ebab5e
b412cbb
 
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
35
36
37
38
39
40
import cv2
import tempfile
import streamlit as st
from prediction import smartcities

# Streamlit Interface
st.header("Smart City Cars and Bikes detection")
st.markdown("Upload a video or select the example")

## Select video to inference
file_video = None

f = st.file_uploader(" Upload a video ", type=["mp4"])
if f is not None:
    tfile = tempfile.NamedTemporaryFile(delete=False)
    tfile.write(f.read())
    file_video = tfile.name

if st.button("example"):
    file_video = "test_video.mp4"

## Process video
if file_video is not None:
    sc = smartcities()
    output = sc.predict(file_video)
    
    if output is not None:
        with st.container():
            st.subheader("Input: ")
            video = open(file_video, "rb")
            video_bytes = video.read()
            st.video(video_bytes, format="video/mp4")
        with st.container():
            st.subheader("Output: ")
            st.video(output, format="video/mp4", start_time=0)
            st.download_button("Download", output, file_name="output_video.mp4", mime="video/mp4")