emotionAlbert / app.py
umsee
made the rudimentary app.py with gradio interface
7c087cb
raw
history blame
No virus
515 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['labels']:float(i['score']) for i in preds[0]}
demo = gr.Interface(fn=classify,inputs='text',outputs=gr.Label())
demo.launch()