Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,19 +1,17 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
from transformers import pipeline
|
3 |
-
|
4 |
-
#
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
gr.
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
description="This model detects complex emotions like guilt, sarcasm, happiness, etc."
|
19 |
-
).launch()
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Force PyTorch backend to avoid loading TensorFlow (and Keras)
|
5 |
+
classifier = pipeline("text-classification", model="Varnikasiva/sentiment-classification-bert-mini", framework="pt")
|
6 |
+
|
7 |
+
def predict(text):
|
8 |
+
result = classifier(text)[0]
|
9 |
+
return f"Label: {result['label']} (Score: {round(result['score'], 2)})"
|
10 |
+
|
11 |
+
gr.Interface(
|
12 |
+
fn=predict,
|
13 |
+
inputs=gr.Textbox(lines=3, placeholder="Type your text here..."),
|
14 |
+
outputs="text",
|
15 |
+
title="Sentiment Classification with BERT Mini",
|
16 |
+
description="Predicts nuanced emotions like sadness, sarcasm, guilt, happiness, and more."
|
17 |
+
).launch()
|
|
|
|