alexrods commited on
Commit
250c6f0
·
1 Parent(s): 6ac371e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -32
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
- tfile = tempfile.NamedTemporaryFile(delete=False)
15
- tfile.write(f.read())
16
- file_video = tfile.name
17
 
18
- if st.button("example"):
19
- file_video = "test_video.mp4"
20
 
21
- ## Process video
22
- if file_video is not None:
23
- sc = smartcities()
24
- output = sc.predict(file_video)
25
- col1, col2 = st.columns(2)
26
 
27
- if output is not None:
28
- with col1:
29
- st.subheader("Input: ")
30
- # video = open(file_video, "wb")
31
- # video_bytes = video.read()
32
- # st.video(video, format="video/mp4")
33
- # st.video(video_bytes)
34
- with col2:
35
- st.subheader("Output: ")
36
- output_video = open(output, "rb")
37
- output_bytes = output_video.read()
38
- st.video(output_bytes, format="video/mp4")
39
- st.download_button("Download", output_bytes, file_name="output_video.mp4", mime="video/mp4")
 
 
 
 
 
 
 
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