# Import libraries from fastai.vision.all import * import gradio as gr # Load model learn = load_learner('labrador.pkl') # Define categories categories = ('Black', 'Golden') # Define function to classify image def classify_image(img): pred, idx, probs = learn.predict(img) return dict(zip(categories, map(float, probs))) # Define Gradio interface image = gr.inputs.Image(shape=(192, 192)) label = gr.outputs.Label() examples = ['black.png', 'golden.png', 'banana.jpg'] intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) intf.launch(inline=False)