Spaces:
Runtime error
Runtime error
Update app.py
Browse files12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849import osos.environ["KERAS_BACKEND"] = "jax"import streamlit as stimport kerasimport numpy as npimport cv2from PIL import Imagelabels = ["angry","disgust","fear","happy","neutral","sad","surprise"]@st.cache_resourcedef load_model():return keras.saving.load_model("hf://fdfddfdsaassd/vgg19-emotion-recognition-ckplus-rafdb")model = load_model()# UI DESIGNst.set_page_config(page_title="Emotion AI", page_icon="🧠", layout="centered")st.markdown("""<h1 style='text-align:center; color:#6C63FF;'>🧠 Emotion AI Detector</h1><p style='text-align:center;'>Upload a face image and detect emotion using VGG19 (RAF-DB + CK+)</p>""", unsafe_allow_html=True)file = st.file_uploader("📤 Upload image", type=["jpg","png","jpeg"])if file:img = Image.open(file)st.image(img, caption="Uploaded Image", use_container_width=True)img = np.array(img)if img.shape[-1] == 4:img = cv2.cvtColor(img, cv2.COLOR_RGBA2RGB)img = cv2.resize(img, (224,224))img = img / 255.0img = np.expand_dims(img, axis=0)pred = model.predict(img)[0]idx = np.argmax(pred)st.markdown("---")st.markdown(f"### 😶 Prediction: **{labels[idx]}**")st.bar_chart(pred)1234567891011121314151617181920212223242526272829303132333435363738import streamlit as stimport kerasimport numpy as npimport cv2from PIL import Imagefrom huggingface_hub import hf_hub_downloadlabels = ["angry","disgust","fear","happy","neutral","sad","surprise"]@st.cache_resourcedef load_model():model_path = hf_hub_download(repo_id="fdfddfdsaassd/vgg19-emotion-recognition-ckplus-rafdb",filename="model.keras" # или model.h5 — СМОТРИ В РЕПО)return keras.saving.load_model(model_path)model = load_model()st.title("🧠 Emotion AI")file = st.file_uploader("Upload image")if file:img = Image.open(file)st.image(img)img = np.array(img)if img.shape[-1] == 4:img = cv2.cvtColor(img, cv2.COLOR_RGBA2RGB)img = cv2.resize(img, (224,224)) / 255.0img = np.expand_dims(img, 0)pred = model.predict(img)[0]st.write(labels[np.argmax(pred)])
app.py+12-23