Spaces:
Sleeping
Sleeping
File size: 1,116 Bytes
eeb3ca3 8676f00 44d2b03 eeb3ca3 8676f00 eeb3ca3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
import gradio as gr
from transformers import pipeline
senti_pipeline = pipeline("sentiment-analysis")
senti_pipeline("I am extremely happy to share this video with all of you")
senti_pipeline("I am sad that you haven't subscribed to my channel yet")
def sentiment_gradio(input):
result = senti_pipeline(input)
if result[0]["label"] == "POSITIVE":
pos_score = round(result[0]["score"], 2)
neg_score = 1 - pos_score
else:
neg_score = round(1*result[0]["score"], 2)
pos_score = 1 - neg_score
res = {'Positive': pos_score, 'Negative': neg_score}
return res
examples = ['I am extremely happy to share this video with all of you','I am tired due to heavy work','the movie was good']
sentiment_analysis_interface = gr.Interface(fn = sentiment_gradio,
inputs="text",
outputs= gr.outputs.Label(num_top_classes=2),
interpretation="default",examples = examples, title="SENTIMENT ANALYSIS")
sentiment_analysis_interface.launch(debug=True) |