__all__=['is_cat','learner','classify_image','categories','image','label','examples','intf'] import gradio as gr from fastai.vision.all import * def is_cat(x): return x[0].isupper() example=['dog.jpg','cat.jpg','cat_dog.jpg'] categories=('dog','cat') def resize_image(image): # Resize the image to 192x192 pixels return image.resize((192, 192)) learner=load_learner('model.pkl') def classify_image(img): pred,idx,prob=learner.predict(img) return dict(zip(categories,map(float,prob))) image=gr.Image(width=192,height=192) label=gr.Label() intf=gr.Interface(fn=classify_image,inputs=image,outputs=label,examples=example) intf.launch(inline=False)