Spaces:
Runtime error
Runtime error
import gradio as gr | |
from fastai.vision.all import * | |
learn = load_learner('model.pkl') | |
labels = learn.dls.vocab | |
def predict(img): | |
pred,idx,probs = learn.predict(img) | |
return {labels[i]: float(probs[i]) for i,_ in enumerate(labels)} | |
with open("article.md") as f: | |
article = f.read() | |
image = gr.inputs.Image(shape=(256,256)) | |
label = gr.outputs.Label() | |
examples = ['house1.jpg','house2.jpg','house3.jpg','house4.jpg','house5.jpg'] | |
title = "Storm Damaged House Classifier with fast.ai" | |
description = "Has your house possibly been damaged by recent storms, use fast.ai to detect damage to your home with this fine-tuned resnet 50 model" | |
intf = gr.Interface(fn=predict, inputs=image, outputs=label, examples=examples,title=title,description=description, article=article) | |
intf.launch() | |