import gradio as gr from fastai.vision.all import * def house_classifier(x): return x[0].isupper() learn = load_learner('export.pkl') categories = ('alfresco', 'bathroom', 'bedroom', 'garage', 'house backyard', 'house front', 'kitchen', 'living room', 'scenery', 'theatre room') def classify_image(img): pred,idx,probs = learn.predict(img) return dict(zip(categories, map(float,probs))) image = gr.Image() label = gr.Label() examples = ['bedroom.jpg', 'kitchen.jpg', 'alfresco.jpg'] intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) intf.launch(inline=False)