File size: 1,630 Bytes
095392e
 
 
 
 
 
 
 
 
 
 
 
 
b4ea58a
095392e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dd2eb44
095392e
 
 
 
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
import streamlit as st
import time
import cv2
from utils import emotion_detection_brainai as edb
emotion_model = edb.EmotionModel()

st.set_page_config(
    page_title = "Emotion Detection", 
    page_icon = "	:full_moon_with_face:",
    layout = "wide")

st.title(":rainbow[감정 인식] 	:full_moon_with_face:")
st.sidebar.header("메뉴")
source_radio = st.sidebar.radio("μ„ νƒν•˜μ„Έμš”", ["IMAGE", "VIDEO"])

if source_radio == "IMAGE":
    st.sidebar.header("이미지 파일 μ—…λ‘œλ“œ")
    img = st.sidebar.file_uploader("이미지 νŒŒμΌμ„ μ„ νƒν•˜μ„Έμš”.", type=("jpg", "png"))
    st.write(":green[μ™Όμͺ½ 메뉴 'Browse files' λ²„νŠΌμ„ ν΄λ¦­ν•˜μ—¬ 이미지 νŒŒμΌμ„ μ„ νƒν•˜λ©΄ AI 좔둠이 μ‹œμž‘λ©λ‹ˆλ‹€.]" )
    if img is not None:
        result_img = emotion_model.process(img)
        st.image(result_img)
    
    else:
        image_name = [ "anger", "happy", "neutral", "sad",  "surprise",]
        cols = st.columns(len(image_name)) 
        for i, name in enumerate(image_name):
            path = "data/" + name + ".jpg"
            with cols[i]:
                st.image(path, caption=name)
    
elif source_radio == "VIDEO":
    
    st.sidebar.header("λΉ„λ””μ˜€ 파일 μ—…λ‘œλ“œ")
    input_video = st.sidebar.file_uploader("λΉ„λ””μ˜€ νŒŒμΌμ„ μ„ νƒν•˜μ„Έμš”..", type=("mp4"))
    st.write(":green[μ™Όμͺ½ 메뉴 'Browse files' λ²„νŠΌμ„ ν΄λ¦­ν•˜μ—¬ λΉ„λ””μ˜€ νŒŒμΌμ„ μ„ νƒν•˜λ©΄ AI 좔둠이 μ‹œμž‘λ©λ‹ˆλ‹€.]" )
    if input_video is not None:
        temp_file = emotion_model .play_video(input_video)
        st.video(temp_file)
        
    else:
        st.video("data/emotions.mp4")