from fastai.vision.all import * import gradio as gr learn = load_learner("model_bicycles.pkl") labels = learn.dls.vocab def classify_image(img): img = PILImage.create(img) pred, idx, probs = learn.predict(img) return dict(zip(labels, map(float, probs))) image = gr.inputs.Image(shape=(224, 224)) label = gr.outputs.Label() title = "Bicycles Classifier" description = "A bicycle classifier that can classify mountain bikes and city/road bikes." intf = gr.Interface( fn=classify_image, inputs=image, outputs=label, title=title, description=description ) intf.launch(inline=False)