Spaces:
Build error
Build error
File size: 503 Bytes
f66f337 f11db1b f66f337 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
import gradio as gr
from transformers import pipeline
classifier = pipeline("text-classification", model="distilbert-amazon-shoe-reviews_ubuntu")
def predict(review):
prediction = classifier(review)
print(prediction)
stars = prediction[0]['label']
stars = (int)(stars.split('_')[1])+1
score = 100*prediction[0]['score']
return "{} {:.0f}%".format("\U00002B50"*stars, score)
iface = gr.Interface(fn=predict, inputs="text", outputs="text")
iface.launch() |