whichlight commited on
Commit
78f684b
β€’
1 Parent(s): a9eaf12

updating img files

Browse files
app.py CHANGED
@@ -7,31 +7,30 @@ title = "Open/Closed Door Classifier"
7
  description = "A classifier trained using fastai on search images of open and closed doors." \
8
  "Created for Lesson 2 in the fastai course."
9
 
10
- examples = ['./open-door.jpeg',
11
- './crack_2.jpg', './red_arch.jpg',
12
- './green.jpg', './red.jpg', './opening_door.jpg',
13
- './inside.jpg', './cracked_3.jpg', './old.jpg',
14
- './blue.jpg', './closed-door.jpeg', './crack_1.jpg']
15
-
16
 
 
 
17
 
18
 
19
  learn = load_learner('door_model.pkl')
20
  labels = learn.dls.vocab
21
 
22
- def predict(img):
23
- img = PILImage.create(img)
24
  pred,pred_idx,probs = learn.predict(img)
25
  return {labels[i]: float(probs[i]) for i in range(len(labels))}
26
 
27
 
28
-
29
  iface = gr.Interface(
30
  fn=predict,
31
  inputs=gr.Image(shape=(512, 512)),
32
  outputs=gr.Label(num_top_classes=3),
33
  title=title,
34
  description=description,
35
- examples=examples,
36
- interpretation="default").queue().launch()
37
 
 
7
  description = "A classifier trained using fastai on search images of open and closed doors." \
8
  "Created for Lesson 2 in the fastai course."
9
 
10
+ examples = ['open-door.jpg',
11
+ 'crack_2.jpg', 'red_arch.jpg',
12
+ 'green.jpg', 'red.jpg', 'opening_door.jpg',
13
+ 'inside.jpg', './cracked_3.jpg', './old.jpg',
14
+ 'blue.jpg']
 
15
 
16
+ examples = list(map(lambda x: "examples/" + x, examples))
17
+ #print(examples)
18
 
19
 
20
  learn = load_learner('door_model.pkl')
21
  labels = learn.dls.vocab
22
 
23
+ def predict(img_input):
24
+ img = PILImage.create(img_input)
25
  pred,pred_idx,probs = learn.predict(img)
26
  return {labels[i]: float(probs[i]) for i in range(len(labels))}
27
 
28
 
 
29
  iface = gr.Interface(
30
  fn=predict,
31
  inputs=gr.Image(shape=(512, 512)),
32
  outputs=gr.Label(num_top_classes=3),
33
  title=title,
34
  description=description,
35
+ examples=examples).queue().launch()
 
36
 
blue.jpg β†’ examples/blue.jpg RENAMED
File without changes
closed-door.jpeg β†’ examples/closed-door.jpg RENAMED
File without changes
crack_1.jpg β†’ examples/crack_1.jpg RENAMED
File without changes
crack_2.jpg β†’ examples/crack_2.jpg RENAMED
File without changes
cracked_3.jpg β†’ examples/cracked_3.jpg RENAMED
File without changes
green.jpg β†’ examples/green.jpg RENAMED
File without changes
inside.jpg β†’ examples/inside.jpg RENAMED
File without changes
old.jpg β†’ examples/old.jpg RENAMED
File without changes
open-door.jpeg β†’ examples/open-door.jpg RENAMED
File without changes
opening_door.jpg β†’ examples/opening_door.jpg RENAMED
File without changes
red.jpg β†’ examples/red.jpg RENAMED
File without changes
red_arch.jpg β†’ examples/red_arch.jpg RENAMED
File without changes