Iust1n2 commited on
Commit
6561336
·
1 Parent(s): 05db5bd

Add application file

Browse files
Files changed (2) hide show
  1. app.py +66 -4
  2. dogs_vs_cats_test.py +0 -78
app.py CHANGED
@@ -1,7 +1,69 @@
 
 
 
 
 
 
 
 
 
 
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
+ #!/usr/bin/env python
2
+ # coding: utf-8
3
+
4
+ # # Dog v Cat
5
+
6
+ # In[5]:
7
+
8
+
9
+ #/export
10
+ from fastai.vision.all import *
11
  import gradio as gr
12
 
13
+ def is_cat(x): return x[0].isupper()
14
+
15
+
16
+ # In[6]:
17
+
18
+
19
+ im = PILImage.create('dog1.jpg')
20
+ im.thumbnail((192, 192))
21
+ im
22
+
23
+
24
+ # In[8]:
25
+
26
+
27
+ #/export
28
+ import pathlib
29
+ temp = pathlib.PosixPath
30
+ pathlib.PosixPath = pathlib.WindowsPath
31
+
32
+ learn = load_learner('model.pkl')
33
+
34
+
35
+ # In[11]:
36
+
37
+
38
+ learn.predict(im)
39
+
40
+
41
+ # In[12]:
42
+
43
+
44
+ #/export
45
+ categories = ('Dog', 'Cat')
46
+
47
+ def classify_images(img):
48
+ pred,idx,probs = learn.predict(img)
49
+ return dict(zip(categories, map(float, probs)))
50
+
51
+
52
+ # In[13]:
53
+
54
+
55
+ classify_images(im)
56
+
57
+
58
+ # In[14]:
59
+
60
+
61
+ #/export
62
+ image = gr.inputs.Image(shape = (192,192))
63
+ label = gr.outputs.Label()
64
+ examples = ['dog1.jpg', 'cat1.jpg']
65
+
66
+ intf = gr.Interface(fn = classify_images, inputs = image, outputs = label, examples = examples)
67
+ intf.launch(inline = False)
68
+
69
 
 
 
dogs_vs_cats_test.py DELETED
@@ -1,78 +0,0 @@
1
- #!/usr/bin/env python
2
- # coding: utf-8
3
-
4
- # # Dog v Cat
5
-
6
- # In[5]:
7
-
8
-
9
- #/export
10
- from fastai.vision.all import *
11
- import gradio as gr
12
-
13
- def is_cat(x): return x[0].isupper()
14
-
15
-
16
- # In[6]:
17
-
18
-
19
- im = PILImage.create('dog1.jpg')
20
- im.thumbnail((192, 192))
21
- im
22
-
23
-
24
- # In[8]:
25
-
26
-
27
- #/export
28
- import pathlib
29
- temp = pathlib.PosixPath
30
- pathlib.PosixPath = pathlib.WindowsPath
31
-
32
- learn = load_learner('model.pkl')
33
-
34
-
35
- # In[11]:
36
-
37
-
38
- learn.predict(im)
39
-
40
-
41
- # In[12]:
42
-
43
-
44
- #/export
45
- categories = ('Dog', 'Cat')
46
-
47
- def classify_images(img):
48
- pred,idx,probs = learn.predict(img)
49
- return dict(zip(categories, map(float, probs)))
50
-
51
-
52
- # In[13]:
53
-
54
-
55
- classify_images(im)
56
-
57
-
58
- # In[14]:
59
-
60
-
61
- #/export
62
- image = gr.inputs.Image(shape = (192,192))
63
- label = gr.outputs.Label()
64
- examples = ['dog1.jpg', 'cat1.jpg']
65
-
66
- intf = gr.Interface(fn = classify_images, inputs = image, outputs = label, examples = examples)
67
- intf.launch(inline = False)
68
-
69
-
70
- # ## export -
71
-
72
- # In[28]:
73
-
74
-
75
- import nbdev
76
- nbdev.export.nb_export('dogs_vs_cats_test.ipynb', 'app')
77
- print('Export successful')
78
-