File size: 849 Bytes
ec68983
 
 
 
 
 
c4e8e59
ec68983
 
 
243a4d7
ec68983
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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

# Load the emotion classification model
@st.cache(allow_output_mutation=True)
def load_model():
    return pipeline('text-classification', model='SamLowe/roberta-base-go_emotions', return_all_scores=True)

# Streamlit app
def main():
    st.title('Emotion Detection Application')
    
    model = load_model()
    
    st.write("Enter a text below to detect its emotions:")
    user_input = st.text_area("Text Input", "")
    
    if st.button("Analyze"):
        if user_input:
            results = model(user_input)
            st.write("Emotion Scores:")
            for result in results[0]:
                st.write(f"{result['label']}: {result['score']:.4f}")
        else:
            st.write("Please enter some text to analyze.")
            
if __name__ == "__main__":
    main()