| import gradio as gr |
| import fastbook |
| fastbook.setup_book() |
| from fastbook import * |
|
|
| course_path = Path() |
| learn_inf = load_learner(course_path/'bears_classifier_001.pkl') |
|
|
|
|
| categories = ('black', 'grizzly', 'teddy') |
| def classify_image(im): |
| pred,idx,probs = learn_inf.predict(im) |
| return dict(zip(categories,map(float, probs))) |
|
|
| image = gr.Image() |
| label = gr.Label() |
| examples = [course_path/"inpiedi.png", course_path/"greezly.png", course_path/"teddy.png"] |
|
|
| intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) |
| intf.launch() |