File size: 803 Bytes
49f8af3
bb8ed6f
 
ec26715
bb8ed6f
 
 
 
 
df84583
7aeb03c
 
 
bb8ed6f
ec26715
bb8ed6f
 
f923aab
 
bb8ed6f
7aeb03c
bb8ed6f
 
7aeb03c
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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()