from fastai.vision.all import * import gradio as gr learn = load_learner('model.pkl') image = gr.inputs.Image(shape=(128, 128)) label = gr.outputs.Label() examples = ['coral.jpg', 'crabs.jpg', 'dolphin.jpg', 'sea_rays.jpg', 'seahorse.jpg', 'turtle_tortoise.jpg'] categories = ('corals','crabs','dolphin','eel','jelly fish','lobster','nudibranchs','octopus','penguin','puffers','sea rays','sea urchins','seahorse','seal','sharks','squid','starfish','turtle_tortoise','whale') def classify_img(img): pred,idx,probs = learn.predict(img) return dict(zip(categories, map(float, probs))) interface = gr.Interface(fn=classify_img, inputs=image, outputs=label, examples=examples) interface.launch(inline=False)