alexrods's picture
Update app.py
250c6f0
raw
history blame
1.46 kB
# import tempfile
# import streamlit as st
import gradio as gr
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 = str
# 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)
# col1, col2 = st.columns(2)
# if output is not None:
# with col1:
# st.subheader("Input: ")
# # video = open(file_video, "wb")
# # video_bytes = video.read()
# # st.video(video, format="video/mp4")
# # st.video(video_bytes)
# with col2:
# st.subheader("Output: ")
# output_video = open(output, "rb")
# output_bytes = output_video.read()
# st.video(output_bytes, format="video/mp4")
# st.download_button("Download", output_bytes, file_name="output_video.mp4", mime="video/mp4")
def object_detection(input):
sc = smartcities()
output = sc.predict(input)
demo = gr.Interface.load(object_detection, input="video", output="video")
demo.launch()