Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,28 +3,34 @@ import gradio as gr
|
|
| 3 |
from transformers import pipeline
|
| 4 |
|
| 5 |
|
|
|
|
|
|
|
| 6 |
model = pipeline(task="image-classification", model="julien-c/hotdog-not-hotdog")
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
-
def predict (image):
|
| 12 |
|
| 13 |
-
predictions = model(image)
|
| 14 |
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
gr.Interface(
|
| 21 |
|
| 22 |
-
|
| 23 |
|
| 24 |
-
|
| 25 |
|
| 26 |
-
|
| 27 |
|
| 28 |
-
|
| 29 |
|
| 30 |
-
).launch()
|
|
|
|
| 3 |
from transformers import pipeline
|
| 4 |
|
| 5 |
|
| 6 |
+
|
| 7 |
+
|
| 8 |
model = pipeline(task="image-classification", model="julien-c/hotdog-not-hotdog")
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
|
|
|
| 13 |
|
|
|
|
| 14 |
|
| 15 |
+
def predict(image):
|
| 16 |
+
|
| 17 |
+
predictions = model(image)
|
| 18 |
+
|
| 19 |
+
return {p["label"]: p["score"] for p in predictions}
|
| 20 |
+
|
| 21 |
+
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
gr.Interface(
|
| 27 |
|
| 28 |
+
predict,
|
| 29 |
|
| 30 |
+
inputs=gr.Image(label="Upload image", type="filepath"),
|
| 31 |
|
| 32 |
+
outputs=gr.Label(num_top_classes=2),
|
| 33 |
|
| 34 |
+
title="Hotdog or Not Hotdog?",
|
| 35 |
|
| 36 |
+
).launch()
|