Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
## https://medium.com/@sa.pieri.98/build-your-first-hugging-face-space-with-gradio-a-beginners-guide-14bc42d66887
|
2 |
+
|
3 |
+
import gradio as gr
|
4 |
+
from transformers import pipeline
|
5 |
+
|
6 |
+
pipeline = pipeline(task="image-classification", model="julien-c/hotdog-not-hotdog")
|
7 |
+
|
8 |
+
def predict(image):
|
9 |
+
predictions = pipeline(image)
|
10 |
+
return [p["label"]: p["score"] for p in predictions]
|
11 |
+
|
12 |
+
gr.interface(
|
13 |
+
predict,
|
14 |
+
inputs = gr.Image(label="Upload hot dog candidate", type = "filepath"),
|
15 |
+
outputs = gr.Label(num_top_classes=2),
|
16 |
+
title="hot Dog? or Not ?"
|
17 |
+
).launch()
|
18 |
+
|