| | |
| |
|
| | __all__ = ['learn', 'categories', 'image', 'label', 'examples', 'demo', 'classify'] |
| |
|
| | |
| | from fastai.vision.all import * |
| | import gradio as gr |
| |
|
| |
|
| | |
| | learn = load_learner('export.pkl') |
| |
|
| |
|
| | |
| | categories = ('ankylosaurus', 'brontosaurus', 'pterodactyl', 'trex', 'triceraptops') |
| |
|
| | def classify(img): |
| | pred, idx, probs = learn.predict(img) |
| | return dict(zip(categories, map(float,probs))) |
| |
|
| | |
| | image = gr.Image(width=512, height=512) |
| | label = gr.Label(num_top_classes=3) |
| | examples = ['ankylosaurus.jpg', 'images.jpeg'] |
| |
|
| | demo = gr.Interface(fn=classify, inputs=image, outputs=label, examples=examples) |
| | demo.launch(inline=False) |
| |
|