from fastai.vision.all import * import gradio as gr path = Path() path learn = load_learner('export.pkl') labels = learn.dls.vocab def roofpredict(img): img = PILImage.create(img) img = img.to_thumb(500,500) pred,pred_idx,probs = learn.predict(img) return {labels[i]: float(probs[i]) for i in range(len(labels))} title = "Roof Condition Classifier" description = "A classifier to detect roof damage. Upload a photo of a roof." examples = ['damaged roof 2.jpg', 'Johnathan Hutchinson (D1) (1MB).jpg', 'FC-peeling-shingles.jpg', 'photo_13.normal.jpg'] interpretation='default' enable_queue=True gr.Interface(fn=roofpredict, inputs="image", outputs="label", title=title, description =description, examples=examples, interpretation=interpretation, enable_queue=enable_queue ).launch()