File size: 421 Bytes
dabfb10 e440ffc e930d0c e440ffc dabfb10 e440ffc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
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()
|