Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import pipeline
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
pipe = pipeline("image-classification", model="julien-c/hotdog-not-hotdog")
|
| 5 |
+
|
| 6 |
+
def predict(img):
|
| 7 |
+
predictions = pipe(img)
|
| 8 |
+
return img, {p["label"]: p["score"] for p in predictions}
|
| 9 |
+
|
| 10 |
+
interface = gr.Interface(fn = predict,
|
| 11 |
+
inputs = gr.Image(label = "select hot dog image", sources = ['upload', 'webcam'], type='pil'),
|
| 12 |
+
outputs = [gr.Image(label = "processed image"), gr.Label(label = "result", num_top_classes = 2)],
|
| 13 |
+
title = "hot dog or not")
|
| 14 |
+
|
| 15 |
+
interface.launch()
|