TextAnalizer / app.py
kumar989's picture
Update app.py
3a96c51
raw
history blame contribute delete
590 Bytes
from transformers import pipeline
import gradio as gr
sentiment_analysis = pipeline("sentiment-analysis",model="siebert/sentiment-roberta-large-english")
# print(sentiment_analysis("I love this!"))
def model(a):
x=sentiment_analysis(a)[0]
if x['label']=='POSITIVE':
d={x['label']:x['score'],'NEGATIVE':1-x['score']}
else:
d={'POSITIVE':1-x['score'],x['label']:x['score']}
return d
demo = gr.Interface(fn=model, inputs="text", outputs="label")
demo.launch()
# import gradio as gr
# gr.Interface.load("models/siebert/sentiment-roberta-large-english").launch()