Spaces:
Runtime error
Runtime error
Commit
·
e39d03a
1
Parent(s):
8521848
updating examples debug
Browse files
app.py
CHANGED
|
@@ -8,6 +8,8 @@ title = "Open/Closed Door Classifier"
|
|
| 8 |
description = "A classifier trained using fastai on search images of open and closed doors." \
|
| 9 |
"Created for Lesson 2 in the fastai course."
|
| 10 |
|
|
|
|
|
|
|
| 11 |
examples = ["open-door.jpg",
|
| 12 |
"crack_2.jpg", "red_arch.jpg",
|
| 13 |
"green.jpg", "red.jpg", "opening_door.jpg",
|
|
@@ -22,23 +24,24 @@ examples = list(
|
|
| 22 |
"examples/" + x),
|
| 23 |
examples))
|
| 24 |
#print(examples)
|
|
|
|
| 25 |
|
| 26 |
|
| 27 |
learn = load_learner('door_model.pkl')
|
| 28 |
labels = learn.dls.vocab
|
| 29 |
|
| 30 |
-
def predict(
|
| 31 |
-
img = PILImage.create(
|
| 32 |
-
pred,pred_idx,probs = learn.predict(
|
| 33 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 34 |
|
| 35 |
|
| 36 |
iface = gr.Interface(
|
| 37 |
fn=predict,
|
| 38 |
-
inputs=gr.Image(
|
| 39 |
outputs=gr.Label(num_top_classes=3),
|
| 40 |
title=title,
|
| 41 |
description=description,
|
| 42 |
-
examples=examples).queue().launch()
|
| 43 |
|
| 44 |
|
|
|
|
| 8 |
description = "A classifier trained using fastai on search images of open and closed doors." \
|
| 9 |
"Created for Lesson 2 in the fastai course."
|
| 10 |
|
| 11 |
+
'''
|
| 12 |
+
|
| 13 |
examples = ["open-door.jpg",
|
| 14 |
"crack_2.jpg", "red_arch.jpg",
|
| 15 |
"green.jpg", "red.jpg", "opening_door.jpg",
|
|
|
|
| 24 |
"examples/" + x),
|
| 25 |
examples))
|
| 26 |
#print(examples)
|
| 27 |
+
'''
|
| 28 |
|
| 29 |
|
| 30 |
learn = load_learner('door_model.pkl')
|
| 31 |
labels = learn.dls.vocab
|
| 32 |
|
| 33 |
+
def predict(img):
|
| 34 |
+
img = PILImage.create(img)
|
| 35 |
+
pred,pred_idx,probs = learn.predict(img)
|
| 36 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 37 |
|
| 38 |
|
| 39 |
iface = gr.Interface(
|
| 40 |
fn=predict,
|
| 41 |
+
inputs=gr.Image(shape=(512, 512)),
|
| 42 |
outputs=gr.Label(num_top_classes=3),
|
| 43 |
title=title,
|
| 44 |
description=description,
|
| 45 |
+
examples=['examples/red.jpg']).queue().launch()
|
| 46 |
|
| 47 |
|