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