File size: 718 Bytes
986d554
 
 
 
 
 
121bd92
6ed882d
 
986d554
 
121bd92
6ed882d
986d554
b0c303c
121bd92
 
 
 
986d554
b9ee075
 
121bd92
986d554
 
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: ../pickerfile.ipynb.

# %% auto 0
__all__ = ['learn', 'categories', 'image', 'label', 'Examples', 'classify_image']

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


# %% ../pickerfile.ipynb 4
learn = load_learner("model.pkl")

# %% ../pickerfile.ipynb 7
categories = {'teddy bear','black bear','grizzly bear'}
def classify_image(img):
  pred,idx,probs = learn.predict(img)
  return dict(zip(categories, map(float,probs)))

# %% ../pickerfile.ipynb 9
image = gr.Image()
label = gr.Label()
Examples = ['teddybear.jpg','blackbear.jpg','grizzlybear.jpg']
gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=Examples).launch()