Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,21 +1,25 @@
|
|
| 1 |
from transformers import pipeline
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
-
classifier = pipeline("sentiment-analysis")
|
| 5 |
|
| 6 |
def classify_text(text):
|
| 7 |
-
result=classifier(text)
|
| 8 |
-
label=result[0]['label']
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
interface = gr.Interface(
|
| 14 |
fn=classify_text,
|
| 15 |
-
inputs=gr.Textbox("Write anything(*-_-)"),
|
| 16 |
outputs="text",
|
| 17 |
-
title="
|
| 18 |
-
description="Enter
|
| 19 |
)
|
| 20 |
|
| 21 |
-
interface.launch(debug=True,share=True)
|
|
|
|
| 1 |
from transformers import pipeline
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
+
classifier = pipeline("sentiment-analysis", model="cardiffnlp/twitter-roberta-base-sentiment")
|
| 5 |
|
| 6 |
def classify_text(text):
|
| 7 |
+
result = classifier(text)
|
| 8 |
+
label = result[0]['label']
|
| 9 |
+
if label == 'LABEL_0':
|
| 10 |
+
label='Negative'
|
| 11 |
+
if label == 'LABEL_1':
|
| 12 |
+
label='Neutral'
|
| 13 |
+
if label == 'LABEL_2':
|
| 14 |
+
label='Positive'
|
| 15 |
+
return f"{label}"
|
| 16 |
|
| 17 |
interface = gr.Interface(
|
| 18 |
fn=classify_text,
|
| 19 |
+
inputs=gr.Textbox(label="Write anything (*-_-)"),
|
| 20 |
outputs="text",
|
| 21 |
+
title="Sentiment Analysis",
|
| 22 |
+
description="Enter text to check the sentiment (Positive or Negative)."
|
| 23 |
)
|
| 24 |
|
| 25 |
+
interface.launch(debug=True, share=True)
|