# AUTOGENERATED! DO NOT EDIT! File to edit: drive/MyDrive/Colab Notebooks/dogs-vs-cats.ipynb. # %% auto 0 __all__ = ['learn', 'categories', 'image', 'label', 'examples', 'intf', 'is_cat', 'classify_image'] # %% drive/MyDrive/Colab Notebooks/dogs-vs-cats.ipynb 2 from fastai.vision.all import * import gradio as gr def is_cat(x): return x[0].isupper() # %% drive/MyDrive/Colab Notebooks/dogs-vs-cats.ipynb 4 learn = load_learner('model.pkl') # %% drive/MyDrive/Colab Notebooks/dogs-vs-cats.ipynb 6 categories = ['Dog', 'Cat'] def classify_image(img): pred, idex, prob = learn.predict(img) return dict(zip(categories, map(float, prob))) # %% drive/MyDrive/Colab Notebooks/dogs-vs-cats.ipynb 8 image = gr.inputs.Image(shape=(192,192)) label = gr.outputs.Label() examples = ['dog.jpg', 'cat.jpg', 'dunno.png' ] intf = gr.Interface( title="Dogs vs Cats", description="Upload a photo of a dog or cat and see it get classified!", fn=classify_image, inputs=image, outputs=label, examples=examples) intf.launch(inline=False)