whichlight commited on
Commit
e39d03a
·
1 Parent(s): 8521848

updating examples debug

Browse files
Files changed (1) hide show
  1. app.py +8 -5
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(img_input):
31
- img = PILImage.create(img_input)
32
- pred,pred_idx,probs = learn.predict(img_input)
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(type='filepath', shape=(512, 512)),
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