File size: 514 Bytes
7c087cb
 
 
 
 
 
 
 
 
 
1821cd3
7c087cb
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import gradio as gr
from transformers import pipeline, AutoModelForSequenceClassification,AutoTokenizer

model = AutoModelForSequenceClassification.from_pretrained('albert')
tokenizer = AutoTokenizer.from_pretrained('albert')

classifier = pipeline('sentiment-analysis',model=model,tokenizer=tokenizer,top_k=None)

def classify(statement):
    preds = classifier(statement)
    return{i['label']:float(i['score']) for i in preds[0]}

demo = gr.Interface(fn=classify,inputs='text',outputs=gr.Label())
demo.launch()