TOPSInfosol's picture
Update app.py
0540fd7 verified
from transformers import pipeline
import gradio as gr
# Initialize the pipeline
pipe = pipeline("text-classification", model="himanshutitoria/quick-commerce-perishability-model")
# Prediction function
def predict(text):
result = pipe(text)
return result[0]["label"]
# Define the interface
with gr.Blocks() as iface:
# Add an image at the top
gr.Image(
value="top_image.webp", # Replace with your image URL or file path
label="Perishability Tagging",
show_label=False,
)
input_textbox = gr.Textbox(
label="Enter a Product Name",
placeholder="Enter a name here...",
interactive=True,
)
# Add the main Gradio interface
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()