twertrwe / app.py
fdfddfdsaassd's picture
Upload 5 files
e367c6c verified
raw
history blame contribute delete
590 Bytes
import streamlit as st
import tensorflow as tf
import numpy as np
import cv2
from PIL import Image
model = tf.keras.models.load_model("emotion_model_rafdb.h5", compile=False)
labels = ["angry","disgust","fear","happy","neutral","sad","surprise"]
st.title("Emotion AI")
file = st.file_uploader("Upload image")
if file:
img = Image.open(file)
st.image(img)
img = np.array(img)
img = cv2.resize(img,(224,224))/255.0
img = np.expand_dims(img,0)
pred = model.predict(img)[0]
idx = np.argmax(pred)
st.write("Emotion:", labels[idx])