Spaces:
Runtime error
Runtime error
| 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() |