# Import the necessary libraries from fastai.vision.all import * import gradio as gr # Load the trained model learn = load_learner('export.pkl') # Get the labels from the model's dataloader labels = learn.dls.vocab # Function to classify an image using the model def classify_image(img): pred,pred_idx,probs = learn.predict(img) return dict(zip(labels, probs)) # Create the Gradio interface image_input = gr.components.Image() label_output = gr.components.Label() examples = ["bergen.jpg", "oslo.jpg", "newyork.jpg"] iface = gr.Interface( fn=classify_image, inputs=image_input, outputs=label_output, examples=examples ) iface.launch()