# AUTOGENERATED! DO NOT EDIT! File to edit: ../Model into Production.ipynb. # %% auto 0 __all__ = ['learn', 'categories', 'image', 'label', 'examples', 'intf', 'is_cat', 'classify_image'] # %% ../Model into Production.ipynb 1 from fastai.vision.all import * # %% ../Model into Production.ipynb 2 import gradio as gr from gradio import * from gradio.components import Image, Label # %% ../Model into Production.ipynb 3 def is_cat(x): return x[0].issupper() # %% ../Model into Production.ipynb 5 learn = load_learner('model.pkl') # %% ../Model into Production.ipynb 7 categories = ('Dog', 'Cat') def classify_image(img): pred, idx, probs = learn.predict(img) return dict(zip(categories, map(float, probs))) # %% ../Model into Production.ipynb 9 # Initialize the image input component with the specified shape image = Image() # Initialize the label output component without the 'type' argument label = Label() examples = ['dog.jpeg'] intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) intf.launch(share=True)