Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import
|
| 2 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 3 |
import torch
|
| 4 |
|
|
@@ -15,12 +15,13 @@ def predict_emotion(text):
|
|
| 15 |
prediction = torch.argmax(outputs.logits, dim=-1).item()
|
| 16 |
return "Positive Emotion" if prediction == 1 else "Negative Emotion"
|
| 17 |
|
| 18 |
-
#
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
outputs="text",
|
| 22 |
-
title="ChefBERT Emotion Classifier",
|
| 23 |
-
description="Enter a sentence and ChefBERT will predict whether the emotion is positive (1) or negative (0).")
|
| 24 |
|
| 25 |
-
#
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 3 |
import torch
|
| 4 |
|
|
|
|
| 15 |
prediction = torch.argmax(outputs.logits, dim=-1).item()
|
| 16 |
return "Positive Emotion" if prediction == 1 else "Negative Emotion"
|
| 17 |
|
| 18 |
+
# Streamlit app layout
|
| 19 |
+
st.title("Emotion Classifier")
|
| 20 |
+
st.write("Enter a sentence and ChefBERT will predict whether the emotion is positive (1) or negative (0).")
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
+
# Input box
|
| 23 |
+
user_input = st.text_input("Input Sentence", "")
|
| 24 |
+
|
| 25 |
+
if user_input:
|
| 26 |
+
result = predict_emotion(user_input)
|
| 27 |
+
st.write("Prediction: ", result)
|