__all__ = ['learn', 'classify_image', 'categories', 'image', 'label', 'examples', 'intf'] # Cell from fastai.vision.all import * import gradio as gr import timm # Cell # Check if AMPMode exists in the current fastai version try: from fastai.callback.fp16 import AMPMode except ImportError: # Define AMPMode if not found (you need to replace this with the actual implementation) class AMPMode: def __init__(self): pass # Cell learn = load_learner('model.pkl') # Cell categories = learn.dls.vocab def classify_image(img): # Ensure img is transformed into a tensor in the right shape img = PILImage.create(img) pred, idx, probs = learn.predict(img) return dict(zip(categories, map(float, probs))) # Cell image = gr.components.Image() label = gr.components.Label() examples = ['Maine_Coon.jpg', 'Beagle.jpg'] # Cell intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) intf.launch(inline=False)