whichlight commited on
Commit
9abef9f
1 Parent(s): f6360dd

initial commit, deploying to huggingface

Browse files
Files changed (13) hide show
  1. app.py +36 -0
  2. blue.jpg +0 -0
  3. closed-door.jpeg +0 -0
  4. crack_1.jpg +0 -0
  5. crack_2.jpg +0 -0
  6. cracked_3.jpg +0 -0
  7. green.jpg +0 -0
  8. inside.jpg +0 -0
  9. old.jpg +0 -0
  10. open-door.jpeg +0 -0
  11. opening_door.jpg +0 -0
  12. red.jpg +0 -0
  13. red_arch.jpg +0 -0
app.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from fastai.vision.all import *
3
+ import skimage
4
+
5
+
6
+ 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
+ learn = load_learner('door_model.pkl')
18
+ labels = learn.dls.vocab
19
+
20
+ def predict(img):
21
+ img = PILImage.create(img)
22
+ pred,pred_idx,probs = learn.predict(img)
23
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
24
+
25
+
26
+
27
+ iface = gr.Interface(
28
+ fn=predict,
29
+ inputs=gr.inputs.Image(shape=(512, 512)),
30
+ outputs=gr.outputs.Label(num_top_classes=3),
31
+ title=title,
32
+ description=description,
33
+ examples=examples,
34
+ interpretation="default",
35
+ enable_queue=True).launch(share=True)
36
+
blue.jpg ADDED
closed-door.jpeg ADDED
crack_1.jpg ADDED
crack_2.jpg ADDED
cracked_3.jpg ADDED
green.jpg ADDED
inside.jpg ADDED
old.jpg ADDED
open-door.jpeg ADDED
opening_door.jpg ADDED
red.jpg ADDED
red_arch.jpg ADDED