Simon O'Callaghan commited on
Commit
70b950f
·
1 Parent(s): 5af6889

Update app and add pics

Browse files
Files changed (5) hide show
  1. app.py +32 -4
  2. cat.jpg +0 -0
  3. dog.jpeg +0 -0
  4. dunno.jpg +0 -0
  5. model.pkl +3 -0
app.py CHANGED
@@ -1,7 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
1
+ #import gradio as gr
2
+
3
+ #def greet(name):
4
+ # return "Hello " + name + "!!"
5
+
6
+ #iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
+ #iface.launch()
8
+
9
+
10
+
11
+ #|export
12
+ from fastai.vision.all import *
13
  import gradio as gr
14
 
15
+ def is_cat(x): return x[0].isupper()
16
+
17
+ #|export
18
+
19
+ learn = load_learner('model.pkl')
20
+
21
+ #|export
22
+ categories = ('Dog', 'Cat')
23
+
24
+ def classify_images(img):
25
+ pred, idx, probs = learn.predict(img)
26
+ return dict(zip(categories, map(float, probs)))
27
+
28
+
29
+ #|export
30
+ image = gr.inputs.Image(shape=(192,192))
31
+ label = gr.outputs.Label()
32
+ examples = ['dog.jpeg', 'cat.jpg', 'dunno.jpg']
33
 
34
+ intf = gr.Interface(fn=classify_images, inputs=image, outputs=label, examples=examples)
35
+ intf.launch(inline=False)
cat.jpg ADDED
dog.jpeg ADDED
dunno.jpg ADDED
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bf70c3f30e6b97b455132e44eab86bc53260399af3ff2acdc680a2edd00a304e
3
+ size 47061419