File size: 884 Bytes
04bdd79 d5423f3 04bdd79 d5423f3 04bdd79 d5423f3 04bdd79 b6b2e1b d5423f3 04bdd79 d5423f3 04bdd79 d5423f3 04bdd79 |
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 |
# AUTOGENERATED! DO NOT EDIT! File to edit: ../02_tipos_rua.ipynb.
import gradio as gr
from fastai.vision.all import *
# %% auto 0
__all__ = ['learn_deploy', 'categories', 'image',
'label', 'examples', 'intf', 'classify_image']
# %% ../02_tipos_rua.ipynb 45
import gradio as gr
from fastai.vision.all import *
# %% ../02_tipos_rua.ipynb 46
learn_deploy = load_learner('export.pkl')
# %% ../02_tipos_rua.ipynb 48
categories = ('estrada de chão', 'rua asfaltada')
def classify_image(img):
pred, idx, probs = learn_deploy.predict(img)
return dict(zip(categories, map(float, probs)))
# %% ../02_tipos_rua.ipynb 52
image = gr.inputs.Image(shape=(192, 192))
label = gr.outputs.Label()
examples = ['asfaltada.jpg', 'estrada.jpg']
intf = gr.Interface(fn=classify_image, inputs=image,
outputs=label, examples=examples)
intf.launch(inline=False)
|