import torch model = torch.hub.load('model.pkl') import requests from PIL import Image from torchvision import transforms # Download human-readable labels for ImageNet. learn=load_learner('model.pkl') categories=('Dogs','Cats') def classify_img(img): pred,idx,probs=learn.predict(img) return dict(zip(categories,map(float,probs))) import gradio as gr image =gr.inputs.Image(shape=(192,192)) label =gr.outputs.Label() examples=['dog.jpg'] intf=gr.Interface(fn=classify_img,inputs=image,outputs=label,examples=examples) intf.launch(inline=False)