Spaces:
Build error
Build error
Hot Dog or Not Classification Model (#1)
Browse files- feat: hot dog or not model classification (9415477dcf435e03f2345c264b8545db0bada5e6)
- feat: hot dog or not model classification (1fc6d29cdc99453c19d6ad7bef363547cc8080d4)
- app.py +18 -4
- hw.py +7 -0
- requirements.txt +2 -0
app.py
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
| 1 |
+
# Hot Dog or Not Classification
|
| 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(input_img):
|
| 9 |
+
predictions = pipeline(input_img)
|
| 10 |
+
|
| 11 |
+
return input_img, {p['label']: p['score'] for p in predictions}
|
| 12 |
|
| 13 |
+
gradio_app = Interface(
|
| 14 |
+
predict,
|
| 15 |
+
inputs=gr.Image(label='Select hot dog candidate', sources=['upload', 'webcam'], type='pil'),
|
| 16 |
+
outputs=[gr.Image(label='Processed Image'), gr.Label(label='Result', num_top_classes=2)],
|
| 17 |
+
title='Hot Dog? Or Not?',
|
| 18 |
+
)
|
| 19 |
|
| 20 |
+
if __name__ == '__main__':
|
| 21 |
+
gradio_app.launch()
|
hw.py
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
def greet(name):
|
| 4 |
+
return "Hello from Hugging Face Spaces " + name + "!!"
|
| 5 |
+
|
| 6 |
+
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 7 |
+
iface.launch()
|
requirements.txt
CHANGED
|
@@ -1 +1,3 @@
|
|
| 1 |
gradio
|
|
|
|
|
|
|
|
|
| 1 |
gradio
|
| 2 |
+
transformers
|
| 3 |
+
torch
|