whichlight's picture
images update
5d0802c
raw
history blame
960 Bytes
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_input)
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()