| from fastai.vision.all import * |
| import gradio as gr |
|
|
| def ice_cream(x): return x[0].isupper() |
|
|
| learn = load_learner('export.pkl') |
|
|
| categories = ('choco chip', 'classical chocolate','mint chocolate') |
|
|
| def classify_image(img): |
| pred,idx,probs = learn.predict(img) |
| return dict(zip(categories,map(float,probs))) |
|
|
| image = gr.Image(width=192,height=192) |
| label = gr.Label() |
| examples = ['images/img1.png','images/img2.png','images/image.png'] |
|
|
| intf = gr.Interface(fn=classify_image,inputs=image,outputs=label,examples=examples) |
| intf.launch(inline=False) |