Spaces:
Sleeping
Sleeping
richardhcli commited on
Commit ·
6f80da5
1
Parent(s): a411ab7
test2
Browse files
app.py
CHANGED
|
@@ -1,42 +1,38 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
|
| 4 |
-
|
| 5 |
|
| 6 |
-
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
|
| 22 |
|
| 23 |
|
|
|
|
|
|
|
| 24 |
|
| 25 |
#=================================================
|
| 26 |
|
| 27 |
# import time
|
| 28 |
# timenow = time.ctime()
|
| 29 |
-
timenow = "10:10 AM"
|
| 30 |
|
| 31 |
-
def greet(name):
|
| 32 |
-
|
| 33 |
|
| 34 |
-
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 35 |
|
| 36 |
-
demo.launch()
|
| 37 |
|
| 38 |
-
# if __name__ == "__main__":
|
| 39 |
-
# if IsTutorial:
|
| 40 |
-
# demo.launch()
|
| 41 |
-
# else:
|
| 42 |
-
# gradio_app.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
|
| 4 |
+
from transformers import pipeline
|
| 5 |
|
| 6 |
+
pipeline = pipeline(task="image-classification", model="julien-c/hotdog-not-hotdog")
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
+
def predict(input_img):
|
| 12 |
+
predictions = pipeline(input_img)
|
| 13 |
+
return input_img, {p["label"]: p["score"] for p in predictions}
|
| 14 |
|
| 15 |
+
gradio_app = gr.Interface(
|
| 16 |
+
predict,
|
| 17 |
+
inputs=gr.Image(label="Select hot dog candidate", sources=['upload', 'webcam'], type="pil"),
|
| 18 |
+
outputs=[gr.Image(label="Processed Image"), gr.Label(label="Result", num_top_classes=2)],
|
| 19 |
+
title="Hot Dog? Or Not?",
|
| 20 |
+
)
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
+
if __name__ == "__main__":
|
| 25 |
+
gradio_app.launch()
|
| 26 |
|
| 27 |
#=================================================
|
| 28 |
|
| 29 |
# import time
|
| 30 |
# timenow = time.ctime()
|
|
|
|
| 31 |
|
| 32 |
+
# def greet(name):
|
| 33 |
+
# return "Hello " + name + "!!" + f"Time now is {timenow}"
|
| 34 |
|
| 35 |
+
# demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 36 |
|
| 37 |
+
# demo.launch()
|
| 38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|