import gradio as gr from fastai.vision.all import * title = "Interstellar Classifier" description = "Built for fast.ai 'Practical Deep Learning'" inputs = gr.components.Image() outputs = gr.components.Label() examples = "examples" model = load_learner("model/model.pkl") labels = model.dls.vocab def predict(img): pred, pred_idx, probs = model.predict(img) return dict(zip(labels, map(float, probs))) demo = gr.Interface( fn=predict, inputs=inputs, outputs=outputs, examples=examples, title=title, description=description, ).queue(default_concurrency_limit=5) demo.launch()