Update app.py
Browse files
app.py
CHANGED
@@ -1,42 +1,50 @@
|
|
1 |
-
import tempfile
|
2 |
-
import streamlit as st
|
|
|
3 |
from prediction import smartcities
|
4 |
|
5 |
-
# Streamlit Interface
|
6 |
-
st.header("Smart City Cars and Bikes detection")
|
7 |
-
st.markdown("Upload a video or select the example")
|
8 |
|
9 |
-
## Select video to inference
|
10 |
-
file_video = str
|
11 |
|
12 |
-
f = st.file_uploader(" Upload a video ", type=["mp4"])
|
13 |
-
if f is not None:
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
|
18 |
-
if st.button("example"):
|
19 |
-
|
20 |
|
21 |
-
## Process video
|
22 |
-
if file_video is not None:
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
|
42 |
|
|
|
1 |
+
# import tempfile
|
2 |
+
# import streamlit as st
|
3 |
+
import gradio as gr
|
4 |
from prediction import smartcities
|
5 |
|
6 |
+
# # Streamlit Interface
|
7 |
+
# st.header("Smart City Cars and Bikes detection")
|
8 |
+
# st.markdown("Upload a video or select the example")
|
9 |
|
10 |
+
# ## Select video to inference
|
11 |
+
# file_video = str
|
12 |
|
13 |
+
# f = st.file_uploader(" Upload a video ", type=["mp4"])
|
14 |
+
# if f is not None:
|
15 |
+
# tfile = tempfile.NamedTemporaryFile(delete=False)
|
16 |
+
# tfile.write(f.read())
|
17 |
+
# file_video = tfile.name
|
18 |
|
19 |
+
# if st.button("example"):
|
20 |
+
# file_video = "test_video.mp4"
|
21 |
|
22 |
+
# ## Process video
|
23 |
+
# if file_video is not None:
|
24 |
+
# sc = smartcities()
|
25 |
+
# output = sc.predict(file_video)
|
26 |
+
# col1, col2 = st.columns(2)
|
27 |
|
28 |
+
# if output is not None:
|
29 |
+
# with col1:
|
30 |
+
# st.subheader("Input: ")
|
31 |
+
# # video = open(file_video, "wb")
|
32 |
+
# # video_bytes = video.read()
|
33 |
+
# # st.video(video, format="video/mp4")
|
34 |
+
# # st.video(video_bytes)
|
35 |
+
# with col2:
|
36 |
+
# st.subheader("Output: ")
|
37 |
+
# output_video = open(output, "rb")
|
38 |
+
# output_bytes = output_video.read()
|
39 |
+
# st.video(output_bytes, format="video/mp4")
|
40 |
+
# st.download_button("Download", output_bytes, file_name="output_video.mp4", mime="video/mp4")
|
41 |
+
def object_detection(input):
|
42 |
+
sc = smartcities()
|
43 |
+
output = sc.predict(input)
|
44 |
+
|
45 |
+
demo = gr.Interface.load(object_detection, input="video", output="video")
|
46 |
+
demo.launch()
|
47 |
+
|
48 |
|
49 |
|
50 |
|