TestPG / app.py
umang018's picture
Update app.py
c4e8e59 verified
raw
history blame contribute delete
849 Bytes
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()