import gradio as gr from fastai.vision.all import * learn = load_learner('seiba-edisa-apple-bins.pkl') categories = learn.dls.vocab def predict(img): # img = PILImage.create(img) _,_,probs = learn.predict(img) return dict(zip(categories, map(float,probs))) title = "Apple bins classifier" examples = ['clean-01.JPG','clean-02.JPG','clean-03.JPG','clean-04.JPG','dirty-01.JPG','dirty-02.JPG','dirty-03.JPG','dirty-04.JPG'] interpretation='default' enable_queue=True gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(192, 192)), outputs=gr.outputs.Label(num_top_classes=2), title=title, examples=examples).launch(inline=False)