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