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")