| |
|
|
| |
| __all__ = ['learn', 'categories', 'image', 'label', 'Examples', 'classify_image'] |
|
|
| |
| from fastai.vision.all import * |
| import gradio as gr |
|
|
|
|
| |
| learn = load_learner("model.pkl") |
|
|
| |
| categories = {'teddy bear','black bear','grizzly bear'} |
| def classify_image(img): |
| pred,idx,probs = learn.predict(img) |
| return dict(zip(categories, map(float,probs))) |
|
|
| |
| image = gr.Image() |
| label = gr.Label() |
| Examples = ['teddybear.jpg','blackbear.jpg','grizzlybear.jpg'] |
| gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=Examples).launch() |
|
|
|
|