Spaces:
Sleeping
Sleeping
Create app.py
Browse filesCreated app.py file
app.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
classifier = pipeline("sentiment-analysis", model="michellejieli/emotion_text_classifier")
|
| 5 |
+
|
| 6 |
+
st.title("Emotion in Text Classifier")
|
| 7 |
+
st.write("Enter any sentence, and the model will predict the expressed emotion in it!")
|
| 8 |
+
|
| 9 |
+
user_input = st.text_area("Input Text", "Type your prompt here...")
|
| 10 |
+
|
| 11 |
+
if st.button("Analyze Emotion"):
|
| 12 |
+
if user_input.strip():
|
| 13 |
+
result = classifier(user_input)
|
| 14 |
+
emotion = result[0]['label']
|
| 15 |
+
score = result[0]['score']
|
| 16 |
+
|
| 17 |
+
st.write(f"**Predicted Emotion:** {emotion}")
|
| 18 |
+
st.write(f"**Confidence Score:** {score:.4f}")
|
| 19 |
+
else:
|
| 20 |
+
st.write("Please enter some text to analyze.")
|
| 21 |
+
|