# AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb. # %% auto 0 __all__ = ['img', 'path', 'filename', 'learn', 'searches', 'title', 'description', 'examples', 'demo', 'classify_image'] # %% app.ipynb 1 from fastbook import search_images_ddg from fastdownload import download_url from fastai.vision.all import * import gradio as gr import torch # %% app.ipynb 4 img = PILImage.create('grizzly.jpg') img.thumbnail((192,192)) img # %% app.ipynb 5 path = Path() filename = path.ls(file_exts='.pkl') filename[0].name # %% app.ipynb 6 learn = load_learner(filename[0].name) # %% app.ipynb 8 searches = ("grizzly bears","black bears","teddy bears") def classify_image(img): pred,idx,probs = learn.predict(img) return dict(zip(searches, map(float,probs))) # %% app.ipynb 10 title = "FastAi demo" description = "This demo is the original" examples = ["grizzly.jpg"] # %% app.ipynb 11 demo = gr.Interface( fn=classify_image, inputs="image", outputs="label", title=title, description=description, examples = examples) demo.launch()