sthio90 commited on
Commit
50b464b
·
1 Parent(s): ee220d9

Card #1 - Initiation

Browse files
Files changed (1) hide show
  1. app.py +41 -0
app.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ # coding: utf-8
3
+ # Dogs vs Cats
4
+
5
+ # In[7]:
6
+
7
+
8
+ #|export
9
+ from fastai.vision.all import *
10
+ import gradio as gr
11
+
12
+ def is_cat(x): return x[0].isupper()
13
+
14
+
15
+ # In[9]:
16
+
17
+
18
+ #|export
19
+ learn = load_learner('model.pkl')
20
+
21
+
22
+
23
+ # In[12]:
24
+
25
+
26
+ #|export
27
+ categories = ('Dog', 'Cat')
28
+
29
+ def classify_image(img):
30
+ pred,idx,probs = learn.predict(img)
31
+ return dict(zip(categories, map(float,probs)))
32
+
33
+
34
+ #|export
35
+ image = gr.inputs.Image(shape=(192,192))
36
+ label = gr.outputs.Label()
37
+ examples = ['dog.jpg', 'cat.jpg', 'dunno.jpg']
38
+
39
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
40
+ intf.launch(inline=False, share=True)
41
+