Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,8 +6,8 @@ clf = pipeline("image-classification", model="nateraw/food") # example model
|
|
| 6 |
|
| 7 |
def predict(img):
|
| 8 |
preds = clf(img) # list of {label, score}
|
| 9 |
-
# return top
|
| 10 |
-
return {p["label"]: float(p["score"]) for p in preds[:
|
| 11 |
|
| 12 |
demo = gr.Interface(fn=predict,
|
| 13 |
inputs=gr.Image(type="pil"),
|
|
|
|
| 6 |
|
| 7 |
def predict(img):
|
| 8 |
preds = clf(img) # list of {label, score}
|
| 9 |
+
# return top 10 in format expected by gr.Label
|
| 10 |
+
return {p["label"]: float(p["score"]) for p in preds[:10]}
|
| 11 |
|
| 12 |
demo = gr.Interface(fn=predict,
|
| 13 |
inputs=gr.Image(type="pil"),
|