| import gradio as gr | |
| from fastai.vision.all import * | |
| import skimage | |
| learn = load_learner('model.pkl') | |
| labels = learn.dls.vocab | |
| def predict(image): | |
| image = PILImage.create(image) | |
| brand, idx, probs = learn.predict(image) | |
| return dict(zip(labels, map(float,probs))) | |
| demo = gr.Interface(fn=predict, inputs=gr.Image(), outputs=gr.Label()) | |
| demo.launch() |