fastai-lesson-2 / app.py
rhogard
add project files
c5bc181
__all__ = ['learn', 'clasify_image', 'categories', 'image', 'label', 'examples', 'intf']
from fastai.vision.all import *
import gradio as gr
# Cell
learn = load_learner('export.pkl')
# Cell
categories = ('Beagle', 'Bulldog', 'Dachshund', 'French Bulldog', 'German Shepherd', 'German Shorthaired Pointer', 'Golden Retriever', 'Labrador Retriever', 'Poodle', 'Rottweiler')
# Cell
def classify_image(img):
pred,idx,probs = learn.predict(img)
return dict(zip(categories, map(float,probs)))
# Cell
image = gr.inputs.Image(shape=(192,192))
label = gr.outputs.Label()
examples = ['Beagle.jpg', 'Bulldog.jpg', 'Dachshund.jpg', 'French Bulldog.jpg']
intf = gr.Interface(fn=classify_image, inputs=image, outpus=label, examples=examples)
intf.launch(inline=False)