Spaces:
Runtime error
Runtime error
File size: 958 Bytes
9abef9f 78f684b a9eaf12 78f684b 9abef9f 78f684b 9abef9f a9eaf12 9abef9f 78f684b 9abef9f |
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 35 36 37 |
import gradio as gr
from fastai.vision.all import *
import skimage
title = "Open/Closed Door Classifier"
description = "A classifier trained using fastai on search images of open and closed doors." \
"Created for Lesson 2 in the fastai course."
examples = ['open-door.jpg',
'crack_2.jpg', 'red_arch.jpg',
'green.jpg', 'red.jpg', 'opening_door.jpg',
'inside.jpg', './cracked_3.jpg', './old.jpg',
'blue.jpg']
examples = list(map(lambda x: "examples/" + x, examples))
#print(examples)
learn = load_learner('door_model.pkl')
labels = learn.dls.vocab
def predict(img_input):
img = PILImage.create(img_input)
pred,pred_idx,probs = learn.predict(img)
return {labels[i]: float(probs[i]) for i in range(len(labels))}
iface = gr.Interface(
fn=predict,
inputs=gr.Image(shape=(512, 512)),
outputs=gr.Label(num_top_classes=3),
title=title,
description=description,
examples=examples).queue().launch()
|