Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
import transformers
|
4 |
+
|
5 |
+
from transformers import pipeline
|
6 |
+
|
7 |
+
pipe = pipeline("sentiment-analysis", model="cardiffnlp/twitter-roberta-base-sentiment-latest")
|
8 |
+
|
9 |
+
def get_sentiment(text):
|
10 |
+
return pipe(text)[0]["label"]
|
11 |
+
|
12 |
+
iface = gr.Interface(fn = get_sentiment,
|
13 |
+
inputs = "text",
|
14 |
+
outputs = 'text',
|
15 |
+
title= 'Sentiment Analysis',
|
16 |
+
description = 'Get Sentiment Negative/Positive for the given input')
|
17 |
+
|
18 |
+
iface.launch(inline=False)
|