peter2000's picture
Update app.py
bff104f
raw history blame
No virus
1.16 kB
import gradio as gr
from transformers import pipeline
pipe = pipeline("text-classification", model="peter2000/xlm-roberta-base-finetuned-ecoicop")
def predict(text):
preds = pipe(text)[0]
return preds["label"].split('_')[1],preds["label"].split('_')[0], round(preds["score"], 5)
gradio_ui = gr.Interface(
fn=predict,
title="Predicting E-Coicop Product Categories",
description="Enter some product text (trained on name, category and url) from an online supermarket and predict the corresponding ECOICOP (level 5) product category for food and baverages.",
inputs=[
gr.inputs.Textbox(lines=5, label="Paste some text here"),
],
outputs=[
gr.outputs.Textbox(label="Label"),
gr.outputs.Textbox(label="Score"),
],
examples=[
["Tiefkühl Eiscreme & Eiswürfel Bechereis <sep> rewe beste wahl peanut butter eiscreme <sep> REWE Beste Wahl Peanut Butter Eiscreme 500ml"],
["epicerie-sucree <sep> cereales chocolat fraise nat <sep> Céréales chocolat & fraise NAT"],
["Pelati e passate <sep> unknown <sep> Mutti Polpa di Pomodoro 3 x 400 g"]
],
)
gradio_ui.launch(debug=True)