Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from fastai.vision.all import * | |
| learner = load_learner('export.pkl') | |
| animals = ['fox', 'elephant'] | |
| def classify_img(img): | |
| pred, idx, prob = learner.predict(img) | |
| return dict(zip(animals[::-1], map(float, prob))) | |
| inputs = gr.Image(shape = (224, 224)) | |
| outputs = gr.Label() | |
| examples = ['./elephant1.jpeg', './elephant2.png', './fox1.jpg'] | |
| intf = gr.Interface(inputs = inputs, outputs = outputs, fn = classify_img, examples = examples) | |
| intf.launch(inline = False) |