import gradio as gr | |
from transformers import pipeline | |
classifier = pipeline("text-classification", model="juliensimon/distilbert-amazon-shoe-reviews") | |
def predict(review): | |
prediction = classifier(review) | |
stars = (int)(prediction['label'].split('_')[1]) | |
score = prediction['score'] | |
return "{} {:.0f}%".format("\U00002B50"*stars, score) | |
iface = gr.Interface(fn=predict, inputs="text", outputs="text") | |
iface.launch() | |