emotionAlbert / app.py
umsee
fixed app.py
1821cd3
raw
history blame contribute delete
514 Bytes
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()