File size: 676 Bytes
1455a51
e28e136
1455a51
 
 
 
 
 
 
 
 
 
e97f553
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from transformers import pipeline
import gradio as gr
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification

model_name="distilbert-base-uncased-finetuned-sst-2-english"

tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)

classifier = pipeline("sentiment-analysis",model=model, tokenizer=tokenizer)

def get_sentiment(input_text):
  return classifier(input_text)
  
iface=gr.Interface(fn=get_sentiment,  inputs="text" ,outputs=["text"],  title="Sentiment Analysis",description="Get Sentiment Negative & Positive for given input")
iface.launch(inline=False)