File size: 921 Bytes
44c4e71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e6aa4d5
 
44c4e71
 
 
 
 
 
 
 
 
 
e6aa4d5
44c4e71
 
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
30
31
32
33
34
35
36
37
# AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.

# %% auto 0
__all__ = ['learn', 'image', 'label', 'examples', 'intf', 'is_cat']

# %% app.ipynb 1
# Make sure we've got the latest version of fastai:
!pip install -Uqq fastai gradio

# %% app.ipynb 2
!pip install -Uqq fastbook
import fastbook
fastbook.setup_book()

# %% app.ipynb 3
from fastbook import *
from fastai.vision.widgets import *
from fastai.vision.all import *
from urllib.request import urlopen

# %% app.ipynb 5
import gradio as gr

def is_cat(x): return x[0].issuper()

# %% app.ipynb 11
learn = load_learner('model.pkl')

# %% app.ipynb 16
image = gr.inputs.Image(shape=(192,192))
label = gr.outputs.Label()
examples = ['images/4d3b88ed-d0dc-43ec-bbaf-6babf6f310a7.jpg',
            'images/5c283719-addd-4dbf-9847-eda74d0af8e7.jpg']

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