Spaces:
Sleeping
Sleeping
feat: init Gradio app following https://huggingface.co/docs/hub/spaces-sdks-gradio
Browse files- app.py +20 -4
- requirements.txt +3 -1
app.py
CHANGED
|
@@ -1,9 +1,25 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
|
|
|
| 3 |
|
| 4 |
-
def greet(name):
|
| 5 |
-
return "Hello " + name + "!!"
|
| 6 |
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 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()
|
requirements.txt
CHANGED
|
@@ -1,2 +1,4 @@
|
|
| 1 |
gradio==4.37.2
|
| 2 |
-
gradio_client==1.0.2
|
|
|
|
|
|
|
|
|
| 1 |
gradio==4.37.2
|
| 2 |
+
gradio_client==1.0.2
|
| 3 |
+
transformers
|
| 4 |
+
torch
|