# AUTOGENERATED! DO NOT EDIT! File to edit: ../01.ipynb. # %% auto 0 __all__ = ['learner', 'labels', 'image', 'predict'] # %% ../01.ipynb 3 from fastai.vision.all import * # %% ../01.ipynb 4 learner = load_learner('model.pkl') # %% ../01.ipynb 5 labels = learner.dls.vocab def predict(img): img = PILImage.create(img) pred,pred_idx,probs = learner.predict(img) return {labels[i]: float(probs[i]) for i in range(len(labels))} # %% ../01.ipynb 7 import gradio as gr # %% ../01.ipynb 8 image = gr.inputs.Image(shape=(512, 512)) labels = gr.outputs.Label(num_top_classes=3) gr.Interface(fn=predict, inputs=image, outputs=labels) gr.launch(inline=False)