|
from transformers import pipeline |
|
import gradio as gr |
|
|
|
|
|
pipe = pipeline("text-classification", model="himanshutitoria/quick-commerce-perishability-model") |
|
|
|
|
|
def predict(text): |
|
result = pipe(text) |
|
return result[0]["label"] |
|
|
|
|
|
with gr.Blocks() as iface: |
|
|
|
gr.Image( |
|
value="top_image.webp", |
|
label="Perishability Tagging", |
|
show_label=False, |
|
) |
|
|
|
input_textbox = gr.Textbox( |
|
label="Enter a Product Name", |
|
placeholder="Enter a name here...", |
|
interactive=True, |
|
) |
|
|
|
|
|
with gr.Row(): |
|
gr.Markdown("# Quick Commerce Perishability Tagging") |
|
|
|
outputs = gr.Textbox(label="Predicted result") |
|
gr.Interface( |
|
fn=predict, |
|
inputs=input_textbox, |
|
outputs=outputs, |
|
examples=[ |
|
["Milk"], |
|
["Perfume"], |
|
["Refined oil"], |
|
["Tata Salt"], |
|
["Cheese"], |
|
["Butterscotch Icecream"], |
|
["Thepla"], |
|
], |
|
) |
|
iface.launch() |