File size: 856 Bytes
b19e2d4
 
 
 
 
 
 
f0023b6
 
b19e2d4
 
 
 
 
 
 
 
 
 
 
 
 
f0023b6
b19e2d4
 
1
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
# AUTOGENERATED! DO NOT EDIT! File to edit: ../testing.ipynb.

# %% auto 0
__all__ = ['learn', 'categories', 'examples', 'intf', 'classify_img']

# %% ../testing.ipynb 1
from fastai.vision.all import *
import gradio as gr

# %% ../testing.ipynb 3
learn = load_learner("model.pkl")

# %% ../testing.ipynb 5
categories = ('American Robin', 'Downy Woodpecker', 'Great Blue Heron',  'Hairy Woodpecker', 'House Sparrow')
def classify_img(img):
  pred,idx,probs = learn.predict(img)
  return dict(zip(categories, map(float,probs)))

# %% ../testing.ipynb 7
# image = gr.Image(shape=(256,256))
# label = gr.Label()
examples = ['american_robin.jpeg', 'downy_woodpecker.jpeg', 'great_blue_heron.jpeg', 'hairy_woodpecker.jpeg', 'house_sparrow.jpeg']

intf = gr.Interface(fn=classify_img, inputs='image', outputs='label', examples=examples)
intf.launch(inline=False)