sja820 commited on
Commit
56d3e17
·
verified ·
1 Parent(s): 0335f28

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -4
app.py CHANGED
@@ -1,7 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
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
+ # -*- coding: utf-8 -*-
2
+ """dogs_cats.ipynb
3
+
4
+ Automatically generated by Colaboratory.
5
+
6
+ Original file is located at
7
+ https://colab.research.google.com/drive/1M-mzhZdFQ2XWBSbLCuKzrmLsm0aLEYxQ
8
+
9
+ ## Gradio Pets
10
+ """
11
+
12
  import gradio as gr
13
 
14
+ def is_cat(x): return x[0].isupper()
15
+
16
+
17
+ learn= load_learner('model.pk1')
18
+
19
+ categories= ('Dog', 'Cat')
20
+
21
+
22
+ def classify_image(img):
23
+ pred,idx,probs= learn.predict(img)
24
+ return dict(zip(categories, map(float, probs)))
25
+
26
+ im=PILImage.create('dog.jpg')
27
+ im.thumbnail((192,192))
28
+ im
29
+
30
+ learn.predict(im)
31
+
32
+ classify_image(im)
33
+
34
+ examples= ['dog.jpg', 'cat.jpg']
35
 
36
+ gr.Interface(fn=classify_image, inputs=[gr.Image(type="pil")], outputs=[gr.Label(num_top_classes=2)], examples=examples).launch()