Iust1n2 commited on
Commit
c8f4557
·
1 Parent(s): 8b2aa31

Adding changes

Browse files
Files changed (3) hide show
  1. cat1.jpg +0 -0
  2. dog1.jpg +0 -0
  3. dogs_vs_cats_test.py +78 -0
cat1.jpg ADDED
dog1.jpg ADDED
dogs_vs_cats_test.py ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+