Spaces:
Sleeping
Sleeping
File size: 557 Bytes
4a839d5 c7e9677 4a839d5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# 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()
|