File size: 389 Bytes
e73e52d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import gradio as gr
from transformers import pipeline

sentiment = pipeline("sentiment-analysis")

def get_sentiment(input_text):
  result = sentiment(input_text)
  final = result[0]["label"]
  if final == "POSITIVE":
    return "POSITIVE SENTIMENT"
  else:
    return "NEGATIVE SENTIMENT"


app = gr.Interface(fn=get_sentiment, inputs=gr.components.Textbox(), outputs="text")
app.launch()