Spaces:
Sleeping
Sleeping
Commit
·
235b994
1
Parent(s):
e559136
update scripts
Browse files- README.md +4 -3
- app.py → app_hotdog.py +11 -4
README.md
CHANGED
@@ -1,13 +1,14 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
emoji: 🤖
|
4 |
colorFrom: pink
|
5 |
colorTo: purple
|
6 |
sdk: gradio
|
7 |
sdk_version: 5.9.1
|
8 |
-
|
9 |
-
|
10 |
short_description: Code base for learning huggingface spaces
|
|
|
11 |
---
|
12 |
|
13 |
# learn-hf-spaces
|
|
|
1 |
---
|
2 |
+
title: HF Spaces
|
3 |
emoji: 🤖
|
4 |
colorFrom: pink
|
5 |
colorTo: purple
|
6 |
sdk: gradio
|
7 |
sdk_version: 5.9.1
|
8 |
+
suggested_hardware: cpu-basic
|
9 |
+
app_file: app_hotdog.py
|
10 |
short_description: Code base for learning huggingface spaces
|
11 |
+
pinned: false
|
12 |
---
|
13 |
|
14 |
# learn-hf-spaces
|
app.py → app_hotdog.py
RENAMED
@@ -3,16 +3,23 @@ from transformers import pipeline
|
|
3 |
|
4 |
pipeline = pipeline(task="image-classification", model="julien-c/hotdog-not-hotdog")
|
5 |
|
|
|
6 |
def predict(input_img):
|
7 |
predictions = pipeline(input_img)
|
8 |
-
return input_img, {p["label"]: p["score"] for p in predictions}
|
|
|
9 |
|
10 |
gradio_app = gr.Interface(
|
11 |
predict,
|
12 |
-
inputs=gr.Image(
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
14 |
title="Hot Dog? Or Not?",
|
15 |
)
|
16 |
|
17 |
if __name__ == "__main__":
|
18 |
-
gradio_app.launch()
|
|
|
3 |
|
4 |
pipeline = pipeline(task="image-classification", model="julien-c/hotdog-not-hotdog")
|
5 |
|
6 |
+
|
7 |
def predict(input_img):
|
8 |
predictions = pipeline(input_img)
|
9 |
+
return input_img, {p["label"]: p["score"] for p in predictions}
|
10 |
+
|
11 |
|
12 |
gradio_app = gr.Interface(
|
13 |
predict,
|
14 |
+
inputs=gr.Image(
|
15 |
+
label="Select hot dog candidate", sources=["upload", "webcam"], type="pil"
|
16 |
+
),
|
17 |
+
outputs=[
|
18 |
+
gr.Image(label="Processed Image"),
|
19 |
+
gr.Label(label="Result", num_top_classes=2),
|
20 |
+
],
|
21 |
title="Hot Dog? Or Not?",
|
22 |
)
|
23 |
|
24 |
if __name__ == "__main__":
|
25 |
+
gradio_app.launch()
|