__all__=['learn', 'classify_image','categories','image','label', 'examples','intf'] # cell from fastai.vision.all import * import gradio as gr # Load the trained model learn = load_learner('export.pkl') #cell categories =('trousers','tshirt') # Define the classification function def classify_image(img): pred, idx, probs = learn.predict(img) # Assuming your model's classes are 'T-shirt' and 'Trousers' categories = ['T-shirt', 'Trousers'] return {categories[i]: float(probs[i]) for i in range(len(categories))} # Define the Gradio interface image = gr.inputs.Image(shape=(192, 192)) label = gr.outputs.Label(num_top_classes=2) examples = ['trousers6.jpg','yellow tshirt.jpg'] intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) intf.launch(inline=False)