import gradio as gr import skimage from fastai.vision.all import * learn = load_learner('model.pkl') categories = ('Coyote','Dog','Fox','Wolf') def classify_image(img): img = PILImage.create(img) pred,idx,probs = learn.predict(img) return dict(zip(categories, map(float,probs))) image = gr.inputs.Image(shape=(192, 192)) label = gr.outputs.Label() interpretation='default' examples = ['Dog.jpg','Wolf.jpg','Fox.jpg','Coyote.jpg'] title = "Wolf-like Animal Classifier" description = "A wolf-like animal classifier trained with fastai." intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples, description=description, title=title, interpretation=interpretation) intf.launch(inline=False)