Spaces:
Sleeping
Sleeping
Create app.py
Browse filesa very vanilla model for demonstrating sentiment analysis
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
classifier = pipeline('sentiment-analysis')
|
5 |
+
|
6 |
+
def sentiment_analysis(text):
|
7 |
+
result = classifier(text)[0]
|
8 |
+
return f"Label: {result['label']}, Score: {round(result['score'], 4)}"
|
9 |
+
|
10 |
+
iface = gr.Interface(
|
11 |
+
fn=sentiment_analysis,
|
12 |
+
inputs=gr.inputs.Textbox(lines=2, placeholder="Enter text here..."),
|
13 |
+
outputs="text",
|
14 |
+
title="Simple Sentiment Analysis",
|
15 |
+
description="Enter a sentence and see if it's Positive or Negative!"
|
16 |
+
)
|
17 |
+
|
18 |
+
iface.launch()
|