Spaces:
Runtime error
Runtime error
File size: 860 Bytes
ea38205 b4a58fd c002f9a 1677649 c002f9a b4a58fd c002f9a b8f48f7 88318eb f005442 ea38205 b8f48f7 b4a58fd b8f48f7 e4e9735 ea38205 |
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 |
import gradio as gr
import nltk
from nltk.sentiment import SentimentIntensityAnalyzer
nltk.download('vader_lexicon')
# from transformers import AutoTokenizer, AutoModelForSequenceClassification
# import torch
# pretrained = "rohanphadke/roberta-finetuned-triplebottomline"
# tokenizer = AutoTokenizer.from_pretrained(pretrained)
# model = AutoModelForSequenceClassification.from_pretrained(pretrained)
sia = SentimentIntensityAnalyzer()
# threshold = 0.5
labels = {0: 'people', 1: 'planet', 2:'profit'}
return_labels = {'people': 0.25, 'planet':0.5, 'profit':0.75}
return_sentiment = {'positive': 0.25, 'neutral':0.5, 'negative':0.75}
def greet(name):
return "Hello " + name + "!!"
def predict_text(text):
return return_labels, sia.polarity_scores(text)
demo = gr.Interface(fn=predict_text, inputs="text", outputs=["label", "label"])
demo.launch() |