florentgbelidji's picture
Create app.py
308d32e
raw history blame
No virus
877 Bytes
import gradio as gr
from transformers import pipeline
pipe = pipeline("text-classification", model="qualitydatalab/autotrain-car-review-project-966432120")
def predict(text):
label2emoji = {"poor": "☹️", "ok": "😐", "great": "😊"}
preds = pipe(text)[0]
return label2emoji[preds["label"]], round(preds["score"], 5)
gradio_ui = gr.Interface(
fn=predict,
title="Predicting review scores from customer reviews",
description="Enter some review text about an Amazon product and check what the model predicts for it's star rating.",
inputs=[
gr.inputs.Textbox(lines=5, label="Paste some text here"),
],
outputs=[
gr.outputs.Textbox(label="Label"),
gr.outputs.Textbox(label="Score"),
],
examples=[
["I love these running shoes!"], ["Ich hasse dieses Buch"],
],
)
gradio_ui.launch(debug=True)