| from fastai.vision.all import * | |
| import gradio as gr | |
| learn = load_learner('trombones.pkl') | |
| categories = learn.dls.vocab | |
| def predict(img): | |
| img = PILImage.create(img) | |
| pred, pred_idx, probs = learn.predict(img) | |
| return dict(zip(categories, map(float, probs))) | |
| gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(224, 224)), outputs=gr.outputs.Label()).launch(inline=False) |