DetectFoodApp / app.py
vu0018's picture
Update app.py
c7e9677 verified
raw
history blame contribute delete
557 Bytes
# app.py
import gradio as gr
from transformers import pipeline
clf = pipeline("image-classification", model="nateraw/food") # example model
def predict(img):
preds = clf(img) # list of {label, score}
# return top 10 in format expected by gr.Label
return {p["label"]: float(p["score"]) for p in preds[:10]}
demo = gr.Interface(fn=predict,
inputs=gr.Image(type="pil"),
outputs=gr.Label(num_top_classes=3),
title="🍽️ Food detector")
if __name__ == "__main__":
demo.launch()