Spaces:
Runtime error
Runtime error
yexuefeng commited on
Commit ·
3b511cb
1
Parent(s): d6e8f65
fix bugs
Browse files
app.py
CHANGED
|
@@ -3,12 +3,17 @@ import gradio as gr
|
|
| 3 |
|
| 4 |
categories = ("grizzly bear", "black bear", "teddy bear")
|
| 5 |
|
|
|
|
|
|
|
| 6 |
def classify_image(img):
|
| 7 |
pred, idx, probs = learn.predict(img)
|
| 8 |
return dict(zip(categories, map(float, probs)))
|
| 9 |
|
|
|
|
|
|
|
|
|
|
| 10 |
def greet(name):
|
| 11 |
return "Hello " + name + "!!"
|
| 12 |
|
| 13 |
-
demo = gr.Interface(fn=
|
| 14 |
demo.launch()
|
|
|
|
| 3 |
|
| 4 |
categories = ("grizzly bear", "black bear", "teddy bear")
|
| 5 |
|
| 6 |
+
learn = load_learner("export.pkl")
|
| 7 |
+
|
| 8 |
def classify_image(img):
|
| 9 |
pred, idx, probs = learn.predict(img)
|
| 10 |
return dict(zip(categories, map(float, probs)))
|
| 11 |
|
| 12 |
+
image = gr.inputs.Image(shape=(192, 192))
|
| 13 |
+
examples = ["bears.jpg", "teddy.jpg", "grizzly.jpg"]
|
| 14 |
+
label = gr.outputs.Label()
|
| 15 |
def greet(name):
|
| 16 |
return "Hello " + name + "!!"
|
| 17 |
|
| 18 |
+
demo = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
| 19 |
demo.launch()
|