File size: 911 Bytes
1eafe63
eeffac2
1eafe63
 
 
d975bf6
 
 
1eafe63
 
 
 
 
 
 
 
 
 
 
 
 
 
d975bf6
 
1eafe63
 
 
eeffac2
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
27
28
29
# AUTOGENERATED! DO NOT EDIT! File to edit: ../toad_frog_testing.ipynb.

# %% auto 0
__all__ = ['toad_frog_model', 'categories', 'image', 'label', 'examples', 'gradio_interface', 'classify_image']

# %% ../toad_frog_testing.ipynb 3
from fastai.vision.all import *
import gradio as gr

# %% ../toad_frog_testing.ipynb 7
toad_frog_model = load_learner("toadfrog.pkl")

# %% ../toad_frog_testing.ipynb 11
categories = ('Frog', 'Toad')

def classify_image(img_path: str):
    prediction, index, probabilities = toad_frog_model.predict(img_path)
    return dict(zip(categories, map(float, probabilities)))

# %% ../toad_frog_testing.ipynb 14
image = gr.inputs.Image(shape=(192,192))
label = gr.outputs.Label()
examples = ["testing/sample_toad.jpg", "testing/sample_frog.jpg"]


gradio_interface = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
gradio_interface.launch(inline=False)