Spaces:
Sleeping
Sleeping
File size: 941 Bytes
0bef7a0 |
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 |
import streamlit as st
from transformers import pipeline
# Initialize the emotion detection pipeline
emotion_model = pipeline("text-classification", model="j-hartmann/emotion-english-distilroberta-base")
# Set up the title and description
st.title("Emotion Detector in Text")
st.write("Type a text below, and the model will predict the emotion behind it.")
# Input field for text
user_input = st.text_area("Enter your text here:")
if st.button("Detect Emotion"):
if user_input.strip():
# Get emotion predictions
emotion = emotion_model(user_input)[0]
label = emotion['label']
score = emotion['score']
# Display emotion and confidence score
st.write(f"**Detected Emotion:** {label}")
st.write(f"**Confidence Score:** {score:.2f}")
else:
st.error("Please enter some text.")
# Footer
st.markdown("Developed by [Your Name]. Deployed on Hugging Face Spaces.")
|