from fastai.vision.all import * import gradio as gr learn = load_learner("model.pkl") labels = learn.dls.vocab labels = [" ".join([word.capitalize() for word in (label).split("_")]) for label in labels] def predict(img): img = PILImage.create(img) _,_,probs = learn.predict(img) return dict(zip(labels, map(float, probs))) examples = [PILImage.create(img) for img in ["phoebe.jpg", "chandler.jpg", "joey.jpg", "monica.jpg"]] title = "Which Disney character are you?" description = "A disney character image classification app created as part fast.ai DL course - Part 1." intf = gr.Interface(fn=predict, inputs="image", outputs="label", title=title, description=description, examples=examples) intf.launch(inline=False)