flying_sails / app.py
Stephen Hudson
Update app.py
6844400
raw
history blame contribute delete
775 Bytes
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/02_app.ipynb.
# %% auto 0
__all__ = ['learn', 'image', 'label', 'examples', 'intf', 'classify_image']
# %% ../nbs/02_app.ipynb 2
from fastai.vision.all import PILImage, load_learner
import gradio as gr
# %% ../nbs/02_app.ipynb 4
learn = load_learner('models/sailboat_sails_classification.pkl')
# %% ../nbs/02_app.ipynb 6
def classify_image(img):
pred, idx, probs = learn.predict(img)
return dict(zip(learn.dls.vocab, map(float, probs)))
# %% ../nbs/02_app.ipynb 9
image = gr.Image(shape=(192, 192))
label = gr.Label(show_label=False)
examples = [f'sailboat{i}.png' for i in range(1,5)]
# examples
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
intf.launch(inline=False)