# AUTOGENERATED! DO NOT EDIT! File to edit: 02_BearClassifierDeployment.ipynb. # %% auto 0 __all__ = ['learn', 'categories', 'image', 'label', 'examples', 'intf', 'classify_image'] # %% 02_BearClassifierDeployment.ipynb 4 # importing dependencies from fastai.vision.all import * import gradio as gr # %% 02_BearClassifierDeployment.ipynb 5 # creating inference learn = load_learner('content/bearClassifier.pkl') # %% 02_BearClassifierDeployment.ipynb 6 categories = ('Black', 'Grizzly', 'Teddy') def classify_image(img): pred, idx, probs = learn.predict(img) return dict(zip(categories, map(float, probs))) # %% 02_BearClassifierDeployment.ipynb 7 # gradio interface Setup image = gr.Image() label = gr.Label() examples = ['content/bear1.jpg', 'content/bear2.jpg', 'content/bear3.jpg', 'content/bear4.jpg'] intf = gr.Interface(fn = classify_image, inputs = image, outputs = label, examples = examples).launch()