Spaces:
Running
Running
| import streamlit as st | |
| from PIL import Image | |
| from transformers import pipeline | |
| st.set_page_config(page_title="Emotion AI", page_icon="🧠", layout="centered") | |
| st.title("🧠 Emotion Recognition AI") | |
| st.write("Upload a face image and detect emotion") | |
| # современная модель (работает без .h5 и TensorFlow) | |
| def load_model(): | |
| return pipeline( | |
| "image-classification", | |
| model="trpakov/vit-face-expression" | |
| ) | |
| model = load_model() | |
| file = st.file_uploader("Upload image", type=["jpg","png","jpeg"]) | |
| if file: | |
| img = Image.open(file) | |
| st.image(img, use_container_width=True) | |
| result = model(img) | |
| st.markdown("## Prediction") | |
| for r in result: | |
| st.write(f"**{r['label']}** : {round(r['score'], 3)}") |