File size: 921 Bytes
0f97416
3f1920d
0f97416
107ea52
3f1920d
8e632d2
 
 
3f1920d
8e632d2
 
 
4df4eb4
051f891
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
from transformers import pipeline

print ("Load hv model...")

# Load the pre-trained emotion classification pipeline
model_name = "bhadresh-savani/distilbert-base-uncased-emotion"
emotion_classifier = pipeline("text-classification", model=model_name)

# Title and Description
st.title("Emotion Classifier")
st.write("""write down how your day went or what your mood is.
On this space used model "bhadresh-savani/distilbert-base-uncased-emotion"
""")

# Input text box
input_text = st.text_area("Enter text to analyze emotions:", "")

if st.button("Classify Emotion"):
    if input_text.strip() == "":
        st.write("Please enter some text to classify.")
    else:
        # Get classification results
        results = emotion_classifier(input_text)
        st.subheader("Predicted Emotions:")
        for result in results:
            st.write(f"**{result['label']}**: {result['score']:.4f}")