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