File size: 2,874 Bytes
d8826e0
8c91f99
d8826e0
 
 
 
23b033b
 
f4fb995
d8826e0
8c91f99
0a5753a
8c91f99
d8826e0
8c91f99
4754d22
cc38371
e24d926
 
 
4754d22
 
 
aafb61a
23b033b
8c91f99
23b033b
d8826e0
 
23b033b
cc38371
23b033b
 
 
 
 
cc38371
23b033b
 
 
 
 
cc38371
 
 
 
23b033b
cc38371
23b033b
cc38371
 
23b033b
 
cc38371
 
 
 
23b033b
8c91f99
cc38371
 
470e1d4
2354f05
cc38371
 
 
6ac34c6
cc38371
8c91f99
cc38371
8c91f99
 
cc38371
9d99f4c
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import streamlit as st
from camera_input_live import camera_input_live
from utils import object_detection_brainai as odb
object_detection = odb.ObjectDetectionModel()

st.set_page_config(
    page_title = "객체 인식", 
    page_icon = ":black_cat:",
    layout = "wide" )

if "random_class" not in st.session_state:
    st.session_state.random_class = object_detection.call_class()

st.sidebar.header("메뉴")
source_radio = st.sidebar.radio("μ„ νƒν•˜μ„Έμš”", ["IMAGE", "VIDEO", "GAME", "WEBCAM"])

col1, col2 = st.columns([3,2])
with col1:
    st.title(":blue[Object Detection] :black_cat:")
with col2:
    if source_radio == "GAME":
        if st.button('μƒˆλ‘œμš΄ 객체'):
            st.session_state.random_class = object_detection.call_class()

if source_radio == "IMAGE":
    st.write(":green[μ™Όμͺ½ 메뉴 'Browse files' λ²„νŠΌμ„ ν΄λ¦­ν•˜μ—¬ 이미지 νŒŒμΌμ„ μ„ νƒν•˜λ©΄ AI 좔둠이 μ‹œμž‘λ©λ‹ˆλ‹€.]")
    st.sidebar.header("이미지 파일 μ—…λ‘œλ“œ")
    input_img = st.sidebar.file_uploader("이미지 νŒŒμΌμ„ μ„ νƒν•˜μ„Έμš”.", type=("jpg", "png"))

    if input_img is not None:
        result_img, detected_object = object_detection.process(input_img)
        col1, col2 = st.columns(2)
        with col1:
            st.image(result_img)
        with col2:
            st.header(detected_object)

    else:
        col1, col2 = st.columns(2)
        with col1:
            st.image("data/table.jpg")
        with col2:
            st.header("Objected detected: chair, potted plant, vase, dining table")

if source_radio == "VIDEO":
    st.write(":green[μ™Όμͺ½ 메뉴 'Browse files' λ²„νŠΌμ„ ν΄λ¦­ν•˜μ—¬ λΉ„λ””μ˜€ νŒŒμΌμ„ μ„ νƒν•˜λ©΄ AI 좔둠이 μ‹œμž‘λ©λ‹ˆλ‹€.]")
    st.sidebar.header("λΉ„λ””μ˜€ 파일 μ—…λ‘œλ“œ")
    input_video = st.sidebar.file_uploader("λΉ„λ””μ˜€ νŒŒμΌμ„ μ„ νƒν•˜μ„Έμš”.", type=("mp4"))
    if input_video is not None:
        output_video_path = object_detection.play_video(input_video)
        st.video(output_video_path)
    else:
        st.video("data/breakfast.mp4")
  
if source_radio == "GAME":
    st.sidebar.header("이미지 파일 μ—…λ‘œλ“œ")
    input_img = st.sidebar.file_uploader("이미지 νŒŒμΌμ„ μ„ νƒν•˜μ„Έμš”.", type=("jpg", "png")) 

    if input_img is not None:
        result_img, detected_object = object_detection.process(input_img)
        if st.session_state.random_class in detected_object:
            st.title(f':{st.session_state.random_class}: μ°ΎμŠ΅λ‹ˆλ‹€!')

        else: 
            st.title(f':{st.session_state.random_class}: 찾을 수 μ—†μŠ΅λ‹ˆλ‹€!')
        st.image(result_img)
    else:
        st.title(f':{st.session_state.random_class}: μžˆλŠ” 이미지λ₯Ό μ—…λ‘œλ“œ')

if source_radio == "WEBCAM":
    input_img = camera_input_live()
    if input_img:
        result_img, detected_object = object_detection.process(input_img)
        st.image(result_img)