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