import gradio as gr from fastai.vision.all import * import pathlib plt = platform.system() if plt == 'Linux': pathlib.WindowsPath = pathlib.PosixPath learn = load_learner('model.pkl') categories = ('Flower','Sunflower') def classify(img): pred,_,probs = learn.predict(img) return dict(zip(categories, map(float,probs))) image = gr.inputs.Image(shape=(192,192)) label = gr.outputs.Label() examples = ['images/0.png','images/1.png','images/2.png','images/3.png','images/4.png','images/5.png','images/6.png','images/7.png','images/8.png','images/9.png'] iface = gr.Interface(fn=classify, inputs=image, outputs=label, examples=examples) iface.launch()