BrainAI-1's picture
Update app.py
dd2eb44 verified
Raw
History Blame Contribute Delete
1.63 kB
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")