# AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb. # %% auto 0 __all__ = ['learn', 'categories', 'image', 'label', 'examples', 'intf', 'classify_athlete'] # %% app.ipynb 1 import gradio as gr # %% app.ipynb 2 from fastai.vision.all import * # %% app.ipynb 3 learn = load_learner('model.pkl') # %% app.ipynb 4 categories = {'Ronaldo', 'messi', 'Michael Jordan', 'Rafael Nadal', 'Roger Federer'} def classify_athlete(img): pred,idx,probs = learn.predict(img) return dict(zip(categories, map(float,probs))) # %% app.ipynb 6 image = gr.inputs.Image(shape = (192,192)) label = gr.outputs.Label() examples = ['cr7.jpeg','messi.jpeg','michael_jordan.jpeg'] intf = gr.Interface(fn = classify_athlete,inputs = image, outputs = label, examples = examples) intf.launch(inline = False)