# AUTOGENERATED! DO NOT EDIT! File to edit: is_a_cat.ipynb. # %% auto 0 __all__ = ['learn', 'labels', 'image', 'examples', 'is_cat', 'predict'] # %% is_a_cat.ipynb 1 from fastai.vision.all import * import gradio as gr def is_cat(x): return x[0].isupper() # %% is_a_cat.ipynb 2 learn = load_learner('model.pkl') # %% is_a_cat.ipynb 3 labels = learn.dls.vocab def predict(img): img = PILImage.create(img) pred,pred_idx,probs = learn.predict(img) return {labels[i]: float(probs[i]) for i in range(len(labels))} # %% is_a_cat.ipynb 4 image = gr.Image(width=512, height=512) examples = ["example1.webp"] gr.Interface(fn=predict, inputs="image", examples=examples, outputs="label").launch(share=False)