Spaces:
Runtime error
Runtime error
lowrollr
commited on
Commit
•
532c4ef
1
Parent(s):
16530ac
app
Browse files- app.py +26 -0
- example_images/eagle.jpg +0 -0
- example_images/falcon.jpg +0 -0
- example_images/hawk.jpg +0 -0
- example_images/owl.jpg +0 -0
- example_images/vulture.jpg +0 -0
- export.pkl +3 -0
app.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from fastai.vision.all import load_learner
|
3 |
+
|
4 |
+
model = load_learner('export.pkl')
|
5 |
+
|
6 |
+
categories = tuple(['eagle', 'hawk', 'falcon', 'owl', 'vulture'].sort())
|
7 |
+
|
8 |
+
def classify_bird(img):
|
9 |
+
pred, idx, probs = model.predict(img)
|
10 |
+
return dict(zip(categories, map(float, probs)))
|
11 |
+
|
12 |
+
image = gr.inputs.Image(shape=(256, 256))
|
13 |
+
label = gr.outputs.Label(num_top_classes=5)
|
14 |
+
|
15 |
+
examples = ['eagle.jpg', 'hawk.jpg', 'falcon.jpg', 'owl.jpg', 'vulture.jpg']
|
16 |
+
|
17 |
+
iface = gr.Interface(
|
18 |
+
fn=classify_bird,
|
19 |
+
inputs=image,
|
20 |
+
outputs=label,
|
21 |
+
examples=examples,
|
22 |
+
title='Birds of Prey Classifier',
|
23 |
+
description='Classifies images as one of 5 classes: eagle, hawk, falcon, owl, vulture',
|
24 |
+
allow_flagging=False
|
25 |
+
)
|
26 |
+
iface.launch()
|
example_images/eagle.jpg
ADDED
example_images/falcon.jpg
ADDED
example_images/hawk.jpg
ADDED
example_images/owl.jpg
ADDED
example_images/vulture.jpg
ADDED
export.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:65ceb5097fafd37d5b07ebd3ae474b987889654cc6effbbd62af0e89fc5bf703
|
3 |
+
size 46970347
|