Spaces:
Sleeping
Sleeping
Commit
·
a7cd959
1
Parent(s):
ae3d57d
Upload 9 files
Browse filesDeploy model to hugging face spaces
- app.py +37 -4
- delphinae.jpg +0 -0
- geo.jpg +0 -0
- hummingbird_classifier_v3.pkl +3 -0
- jardini.jpg +0 -0
- lead.webp +0 -0
- micro.jfif +0 -0
- tzacatl.jfif +0 -0
app.py
CHANGED
@@ -1,7 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
|
|
1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.
|
2 |
+
|
3 |
+
# %% auto 0
|
4 |
+
__all__ = ['learn', 'species', 'image', 'label', 'examples', 'intf', 'classify_image']
|
5 |
+
|
6 |
+
# %% app.ipynb 1
|
7 |
+
from fastai.vision.all import *
|
8 |
import gradio as gr
|
9 |
|
10 |
+
# %% app.ipynb 3
|
11 |
+
learn = load_learner('hummingbird_classifier_v3.pkl')
|
12 |
+
|
13 |
+
# %% app.ipynb 5
|
14 |
+
species = ('Adelomyia melanogenys', 'Aglaiocercus coelestis', 'Aglaiocercus kingii', 'Amazilia amabilis',
|
15 |
+
'Amazilia franciae', 'Amazilia rosenbergi', 'Amazilia saucerottei', 'Amazilia tzacatl',
|
16 |
+
'Androdon aequatorialis', 'Anthracothorax nigricollis', 'Boissonneaua flavescens',
|
17 |
+
'Boissonneaua jardini', 'Chaetocercus heliodor', 'Chaetocercus mulsant', 'Chalybura buffonii',
|
18 |
+
'Chalybura urochrysia', 'Chlorostilbon gibsoni', 'Chlorostilbon melanorhynchus',
|
19 |
+
'Chrysolampis mosquitus', 'Coeligena coeligena', 'Coeligena torquata', 'Colibri coruscans',
|
20 |
+
'Colibri delphinae', 'Colibri thalassinus', 'Discosura conversii', 'Doryfera ludovicae',
|
21 |
+
'Ensifera ensifera', 'Eriocnemis vestita', 'Eutoxeres aquila', 'Florisuga mellivora',
|
22 |
+
'Glaucis hirsutus', 'Haplophaedia aureliae', 'Heliangelus exortis', 'Heliodoxa imperatrix',
|
23 |
+
'Heliodoxa jacula', 'Heliodoxa leadbeateri', 'Heliodoxa rubinoides', 'Heliomaster longirostris',
|
24 |
+
'Heliothryx barroti', 'Hylocharis eliciae', 'Klais guimeti', 'Lafresnaya lafresnayi',
|
25 |
+
'Lepidopyga coeruleogularis', 'Lepidopyga goudoti', 'Metallura tyrianthina', 'Ocreatus underwoodii',
|
26 |
+
'Phaethornis anthophilus', 'Phaethornis guy', 'Phaethornis longirostris', 'Phaethornis striigularis',
|
27 |
+
'Phaethornis syrmatophorus', 'Phaethornis yaruqui', 'Ramphomicron microrhynchum', 'Schistes geoffroyi',
|
28 |
+
'Threnetes ruckeri', 'Urochroa bougueri')
|
29 |
+
|
30 |
+
def classify_image(img):
|
31 |
+
pred, idx, probs = learn.predict(img)
|
32 |
+
return dict(zip(species, map(float, probs)))
|
33 |
+
|
34 |
+
# %% app.ipynb 7
|
35 |
+
image = gr.components.Image(shape=(192, 192))
|
36 |
+
label = gr.components.Label()
|
37 |
+
examples = ['lead.webp', 'geo.jpg', 'delphinae.jpg', 'jardini.jpg', 'tzacatl.jfif', 'micro.jfif']
|
38 |
|
39 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
40 |
+
intf.launch(inline=False)
|
delphinae.jpg
ADDED
![]() |
geo.jpg
ADDED
![]() |
hummingbird_classifier_v3.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:bb1f61ff723e1d1dd4c43ad54a87d1ffb91a1ad02d984fbf1e9db38ab2fb0a52
|
3 |
+
size 47133189
|
jardini.jpg
ADDED
![]() |
lead.webp
ADDED
![]() |
micro.jfif
ADDED
Binary file (244 kB). View file
|
|
tzacatl.jfif
ADDED
Binary file (438 kB). View file
|
|