from fastai.vision.all import * import gradio as gr import skimage # Load the pre-trained model learn_inf = load_learner('export.pkl') labels = learn_inf.dls.vocab # Prediction function def predict(img): img = PILImage.create(img) pred, pred_idx, probs = learn_inf.predict(img) return {labels[i]: float(probs[i]) for i in range(len(labels))} # Create and launch the Gradio interface interface = gr.Interface( fn=predict, inputs=gr.Image(), outputs=gr.Label(num_top_classes=3), title="Domestic animal Classifier", description="Domestic animal classifier using a deep learning model" ) interface.launch(share=True)