Héctor Tarrido-Picart
Update app.py
f8c857a
raw
history blame
1.07 kB
from fastai.vision.all import *
import gradio as gr
import skimage
learn = load_learner('model.pkl')
categories = ['power line down',
'power line arcing',
'palm tree after hurricane']
def predict(img):
img = PILImage.create(img)
pred, idx, probs = learn.predict(img)
return dict(zip(categories, map(float, probs)))
images = gr.inputs.Image(shape=(512, 512))
labels = gr.outputs.Label()
examples = ['powerline_down.jpg', 'powerline_tree.jpg']
title = "Power Line after Disaster Classifier"
description = "A classifier trained to identify power lines, trees on power lines after a storm. Created as a demo for fastai. Copyright: Apagon LLC."
interpretation = 'default'
enable_queue = True
intf = gr.Interface(fn=predict,
inputs=images,
outputs=labels,
examples=examples,
title=title,
description=description,
interpretation=interpretation,
enable_queue=enable_queue)
intf.launch()