import gradio as gr from fastai.vision.all import load_learner model = load_learner('export.pkl') categories = ('george', 'not_george') def classify_bird(img): pred, idx, probs = model.predict(img) return dict(zip(categories, map(float, probs))) image = gr.inputs.Image(shape=(256, 256)) label = gr.outputs.Label(num_top_classes=5) examples = ['george1.jpeg', 'george2.jpg', 'george3.jpeg', 'not_george1.jpg', 'not_george2.jpg', 'not_george3.jpg'] iface = gr.Interface( fn=classify_bird, inputs=image, outputs=label, examples=examples, title='George Classifier', description='Determines whether an image is of george', allow_flagging='never' ) iface.launch()