Spaces:
Runtime error
Runtime error
File size: 1,021 Bytes
c91e778 6719ca3 c91e778 a13bf72 c91e778 b8efaeb c91e778 b8efaeb 60371ef c91e778 6719ca3 f8c857a b8efaeb 6719ca3 c91e778 b8efaeb 60371ef b8efaeb 60371ef |
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 28 29 30 31 32 33 34 |
from fastai.vision.all import *
import gradio as gr
import skimage
learn = load_learner('model.pkl')
categories = ['damaged power lines', 'normal power lines']
def predict(img):
img = PILImage.create(img)
pred, idx, probs = learn.predict(img)
return dict(zip(categories, map(float, probs)))
images = gr.components.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)
intf.launch(enable_queue=enable_queue,
share=true)
|