Spaces:
Build error
Build error
Ross May
commited on
Commit
·
fc83b3c
1
Parent(s):
7d01084
Woodpecker App
Browse files- Untitled-1.ipynb +0 -0
- app.py +34 -4
- blk_woodpeck.jpg +0 -0
- eur_woodpeck.jpg +0 -0
- grt_spot_woodpeck.jpg +0 -0
Untitled-1.ipynb
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
app.py
CHANGED
|
@@ -1,7 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
| 1 |
+
# import gradio as gr
|
| 2 |
+
|
| 3 |
+
# def greet(name):
|
| 4 |
+
# return "Hello " + name + "!!"
|
| 5 |
+
|
| 6 |
+
# iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 7 |
+
# iface.launch()
|
| 8 |
+
from fastai.vision.all import *
|
| 9 |
import gradio as gr
|
| 10 |
|
| 11 |
+
learn = load_learner("../../lecture2/model_lec2.pkl")
|
| 12 |
+
|
| 13 |
+
brd_category = (
|
| 14 |
+
"Black Woodpecker",
|
| 15 |
+
"Eurasian Three-Toed Woodpecker",
|
| 16 |
+
"Great Spotted Woodpecker",
|
| 17 |
+
"Green Woodpecker",
|
| 18 |
+
"Grey-Headed Woodpecker",
|
| 19 |
+
"Lesser Spotted Woodpecker",
|
| 20 |
+
"Middle Spotted Woodpecker",
|
| 21 |
+
"White-Backed Woodpecker",
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
def classify_image(img):
|
| 25 |
+
pred,idx,probs = learn.predict(img)
|
| 26 |
+
return dict(zip(brd_category, map(float,probs)))
|
| 27 |
+
|
| 28 |
+
image = gr.inputs.Image(shape=(192,192))
|
| 29 |
+
label = gr.outputs.Label()
|
| 30 |
+
examples = [
|
| 31 |
+
"blk_woodpeck.jpg",
|
| 32 |
+
"grt_spot_woodpeck.jpg",
|
| 33 |
+
"eur_woodpeck.jpg",
|
| 34 |
+
]
|
| 35 |
|
| 36 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
| 37 |
+
intf.launch(inline=False)
|
blk_woodpeck.jpg
ADDED
|
eur_woodpeck.jpg
ADDED
|
grt_spot_woodpeck.jpg
ADDED
|