import gradio as gr from fastai.vision.all import * learn = load_learner("model.pkl") categories = ("contrail", "no contrail") def classify_image(image): category, idx, probabilities = learn.predict(image) return dict(zip(categories, map(float, probabilities))) image = gr.Image(shape=(400, 400)) label = gr.outputs.Label() examples = ["contrail.png", "sky.png"] interface = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) interface.launch(inline=False)