Spaces:
Running
Running
gpantaz
commited on
Commit
·
79ba67c
1
Parent(s):
737c454
Add application file
Browse files
app.py
CHANGED
@@ -1,25 +1,25 @@
|
|
1 |
-
import os
|
2 |
-
|
3 |
import gradio as gr
|
4 |
-
from
|
5 |
|
6 |
-
|
7 |
|
8 |
-
auth_token = os.environ.get("HF_TOKEN", None)
|
9 |
-
if auth_token:
|
10 |
-
login(token=auth_token)
|
11 |
|
|
|
|
|
|
|
12 |
|
13 |
-
title = """
|
14 |
-
<div align="center">
|
15 |
-
<span>Tokenization Playground</span>
|
16 |
-
</div>
|
17 |
-
"""
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
if __name__ == "__main__":
|
24 |
-
|
25 |
-
# demo.launch(share=True)
|
|
|
|
|
|
|
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()
|
|