Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
import cv2
|
| 3 |
from camera_input_live import camera_input_live
|
| 4 |
from utils import object_detection_brainai as odb
|
| 5 |
object_detection = odb.ObjectDetectionModel()
|
|
@@ -15,7 +14,7 @@ if "random_class" not in st.session_state:
|
|
| 15 |
st.sidebar.header("λ©λ΄")
|
| 16 |
source_radio = st.sidebar.radio("μ ννμΈμ", ["IMAGE", "VIDEO", "GAME", "WEBCAM"])
|
| 17 |
|
| 18 |
-
col1, col2 = st.columns([3,
|
| 19 |
with col1:
|
| 20 |
st.title(":blue[Object Detection] :black_cat:")
|
| 21 |
with col2:
|
|
@@ -29,46 +28,47 @@ if source_radio == "IMAGE":
|
|
| 29 |
input_img = st.sidebar.file_uploader("μ΄λ―Έμ§ νμΌμ μ ννμΈμ.", type=("jpg", "png"))
|
| 30 |
|
| 31 |
if input_img is not None:
|
| 32 |
-
result_img, detected_object = object_detection.
|
| 33 |
col1, col2 = st.columns(2)
|
| 34 |
with col1:
|
| 35 |
st.image(result_img)
|
| 36 |
with col2:
|
| 37 |
st.header(detected_object)
|
|
|
|
| 38 |
else:
|
| 39 |
col1, col2 = st.columns(2)
|
| 40 |
with col1:
|
| 41 |
st.image("data/table.jpg")
|
| 42 |
with col2:
|
| 43 |
-
st.header("
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
st.write(":green[μΌμͺ½ λ©λ΄ 'Browse files' λ²νΌμ ν΄λ¦νμ¬ λΉλμ€ νμΌμ μ ννλ©΄ AI μΆλ‘ μ΄ μμλ©λλ€.]"
|
| 47 |
st.sidebar.header("λΉλμ€ νμΌ μ
λ‘λ")
|
| 48 |
-
input_video = st.sidebar.file_uploader("λΉλμ€ νμΌμ μ ννμΈμ.
|
| 49 |
if input_video is not None:
|
| 50 |
-
|
| 51 |
-
st.video(
|
| 52 |
else:
|
| 53 |
st.video("data/breakfast.mp4")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
-
elif source_radio == "GAME":
|
| 56 |
-
input_img = st.sidebar.file_uploader("μ΄λ―Έμ§ νμΌμ μ ννμΈμ.", type=("jpg", "png"))
|
| 57 |
if input_img is not None:
|
| 58 |
-
result_img, detected_object = object_detection.
|
| 59 |
-
if st.session_state.random_class
|
| 60 |
st.title(f':{st.session_state.random_class}: μ°Ύμ΅λλ€!')
|
| 61 |
-
else:
|
| 62 |
-
st.title(f':{st.session_state.random_class}: μ°Ύμ μ μμ΅λλ€')
|
| 63 |
-
|
| 64 |
-
st.image(result_img)
|
| 65 |
|
|
|
|
|
|
|
|
|
|
| 66 |
else:
|
| 67 |
-
|
| 68 |
|
| 69 |
-
|
| 70 |
input_img = camera_input_live()
|
| 71 |
if input_img:
|
| 72 |
-
result_img, detected_object = object_detection.
|
| 73 |
st.image(result_img)
|
| 74 |
-
|
|
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
from camera_input_live import camera_input_live
|
| 3 |
from utils import object_detection_brainai as odb
|
| 4 |
object_detection = odb.ObjectDetectionModel()
|
|
|
|
| 14 |
st.sidebar.header("λ©λ΄")
|
| 15 |
source_radio = st.sidebar.radio("μ ννμΈμ", ["IMAGE", "VIDEO", "GAME", "WEBCAM"])
|
| 16 |
|
| 17 |
+
col1, col2 = st.columns([3,2])
|
| 18 |
with col1:
|
| 19 |
st.title(":blue[Object Detection] :black_cat:")
|
| 20 |
with col2:
|
|
|
|
| 28 |
input_img = st.sidebar.file_uploader("μ΄λ―Έμ§ νμΌμ μ ννμΈμ.", type=("jpg", "png"))
|
| 29 |
|
| 30 |
if input_img is not None:
|
| 31 |
+
result_img, detected_object = object_detection.process(input_img)
|
| 32 |
col1, col2 = st.columns(2)
|
| 33 |
with col1:
|
| 34 |
st.image(result_img)
|
| 35 |
with col2:
|
| 36 |
st.header(detected_object)
|
| 37 |
+
|
| 38 |
else:
|
| 39 |
col1, col2 = st.columns(2)
|
| 40 |
with col1:
|
| 41 |
st.image("data/table.jpg")
|
| 42 |
with col2:
|
| 43 |
+
st.header("Objected detected: chair, potted plant, vase, dining table")
|
| 44 |
+
|
| 45 |
+
if source_radio == "VIDEO":
|
| 46 |
+
st.write(":green[μΌμͺ½ λ©λ΄ 'Browse files' λ²νΌμ ν΄λ¦νμ¬ λΉλμ€ νμΌμ μ ννλ©΄ AI μΆλ‘ μ΄ μμλ©λλ€.]")
|
| 47 |
st.sidebar.header("λΉλμ€ νμΌ μ
λ‘λ")
|
| 48 |
+
input_video = st.sidebar.file_uploader("λΉλμ€ νμΌμ μ ννμΈμ.", type=("mp4"))
|
| 49 |
if input_video is not None:
|
| 50 |
+
output_video_path = object_detection.play_video(input_video)
|
| 51 |
+
st.video(output_video_path)
|
| 52 |
else:
|
| 53 |
st.video("data/breakfast.mp4")
|
| 54 |
+
|
| 55 |
+
if source_radio == "GAME":
|
| 56 |
+
st.sidebar.header("μ΄λ―Έμ§ νμΌ μ
λ‘λ")
|
| 57 |
+
input_img = st.sidebar.file_uploader("μ΄λ―Έμ§ νμΌμ μ ννμΈμ.", type=("jpg", "png"))
|
| 58 |
|
|
|
|
|
|
|
| 59 |
if input_img is not None:
|
| 60 |
+
result_img, detected_object = object_detection.process(input_img)
|
| 61 |
+
if st.session_state.random_class in detected_object:
|
| 62 |
st.title(f':{st.session_state.random_class}: μ°Ύμ΅λλ€!')
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
+
else:
|
| 65 |
+
st.title(f':{st.session_state.random_class}: μ°Ύμ μ μμ΅λλ€!')
|
| 66 |
+
st.image(result_img)
|
| 67 |
else:
|
| 68 |
+
st.title(f':{st.session_state.random_class}: μλ μ΄λ―Έμ§λ₯Ό μ
λ‘λ')
|
| 69 |
|
| 70 |
+
if source_radio == "WEBCAM":
|
| 71 |
input_img = camera_input_live()
|
| 72 |
if input_img:
|
| 73 |
+
result_img, detected_object = object_detection.process(input_img)
|
| 74 |
st.image(result_img)
|
|
|