William-Downing commited on
Commit
ea42667
·
1 Parent(s): 54c5948

updated the repository

Browse files
Pets_Classification/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ __version__ = "0.0.1"
Pets_Classification/_modidx.py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ # Autogenerated by nbdev
2
+
3
+ d = { 'settings': { 'branch': 'main',
4
+ 'doc_baseurl': '/',
5
+ 'doc_host': 'https://AyyCompadre.github.io',
6
+ 'git_url': 'https://github.com/AyyCompadre/Pets_Classification',
7
+ 'lib_path': 'Pets_Classification'},
8
+ 'syms': {}}
Pets_Classification/app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AUTOGENERATED! DO NOT EDIT! File to edit: ../app.ipynb.
2
+
3
+ # %% auto 0
4
+ __all__ = ['plt', 'learn', 'categories', 'image', 'label', 'examples', 'intf', 'is_cat', 'classify_image']
5
+
6
+ # %% ../app.ipynb 2
7
+ from fastai.vision.all import *
8
+ import gradio as gr
9
+ import pathlib as pl
10
+ plt = platform.system()
11
+
12
+ def is_cat(x): return x[0].isupper()
13
+
14
+ # %% ../app.ipynb 4
15
+ if plt == 'Linux' : pl.WindowsPath = pl.PosixPath
16
+ learn = load_learner('model.pkl')
17
+
18
+ # %% ../app.ipynb 6
19
+ categories = ('Dog', 'Cat')
20
+
21
+ def classify_image(img):
22
+ pred,idx,probs = learn.predict(img)
23
+ return dict(zip(categories, map(float,probs)))
24
+
25
+ # %% ../app.ipynb 8
26
+ image = gr.Image(height=192, width = 192)
27
+ label = gr.Label()
28
+ examples = ['dog.jpg', 'cat.jpg', 'dunno.jpg']
29
+
30
+ intf = gr.Interface(fn=classify_image, inputs = image, outputs=label, examples = examples)
31
+ intf.launch(inline=False)
app ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+
3
+ # In[ ]:
4
+
5
+ #|default_exp
6
+
7
+ # In[5]:
8
+
9
+ get_ipython().run_line_magic("pip", "install gradio==3.50")
10
+ get_ipython().run_line_magic("pip", "install nbdev")
11
+ get_ipython().run_line_magic("nbdev_migrate", '')
12
+ get_ipython().run_line_magic("pip", "install fastai")
13
+ get_ipython().run_line_magic("pip", "install ipywidgets")
14
+ get_ipython().run_line_magic("pip", "install git+https://github.com/fastai/nbdev.git gradio fastcore")
15
+
16
+ # In[6]:
17
+
18
+ import pathlib as pl
19
+
20
+ import gradio as gr
21
+ import nbdev
22
+ #|export
23
+ from fastai.vision.all import *
24
+ from fastcore.net import HTTPError, urljson
25
+
26
+ plt = platform.system()
27
+
28
+
29
+ def is_cat(x):
30
+ return x[0].isupper()
31
+
32
+
33
+ # In[ ]:
34
+
35
+ im = PILImage.create("dog.jpg")
36
+ im.thumbnail((192, 192))
37
+ im
38
+
39
+ # In[ ]:
40
+
41
+ #|export
42
+ if plt == "Linux":
43
+ pl.WindowsPath = pl.PosixPath
44
+ learn = load_learner("model.pkl")
45
+
46
+ # In[ ]:
47
+
48
+ learn.predict(im)
49
+
50
+ # In[ ]:
51
+
52
+ #|export
53
+ categories = ("Dog", "Cat")
54
+
55
+
56
+ def classify_image(img):
57
+ pred, idx, probs = learn.predict(img)
58
+ return dict(zip(categories, map(float, probs)))
59
+
60
+
61
+ # In[ ]:
62
+
63
+ classify_image(im)
64
+
65
+ # In[ ]:
66
+
67
+ #|export
68
+ image = gr.Image(height=192, width=192)
69
+ label = gr.Label()
70
+ examples = ["dog.jpg", "cat.jpg", "dunno.jpg"]
71
+
72
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
73
+ intf.launch(inline=False)
74
+
75
+ # In[7]:
76
+
77
+ from nbdev.export import nb_export
78
+
79
+ nb_export("app.ipynb", "app")
app.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
app.py DELETED
@@ -1,7 +0,0 @@
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()
 
 
 
 
 
 
 
 
cat.jpg ADDED
dog.jpg ADDED
dunno.jpg ADDED
settings.ini ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [DEFAULT]
2
+ # All sections below are required unless otherwise specified.
3
+ # See https://github.com/fastai/nbdev/blob/master/settings.ini for examples.
4
+
5
+ ### Python library ###
6
+ repo = Pets_Classification
7
+ lib_name = Pets_Classification
8
+ version = 0.0.1
9
+ min_python = 3.7
10
+ license = apache2
11
+ black_formatting = False
12
+
13
+ ### nbdev ###
14
+ doc_path = _docs
15
+ lib_path = Pets_Classification
16
+ nbs_path = nbs
17
+ recursive = True
18
+ tst_flags = notest
19
+ put_version_in_init = True
20
+
21
+ ### Docs ###
22
+ branch = main
23
+ custom_sidebar = False
24
+ doc_host = https://%(user)s.github.io
25
+ doc_baseurl = /
26
+ git_url = https://github.com/%(user)s/%(repo)s
27
+ title = %(lib_name)s
28
+
29
+ ### PyPI ###
30
+ audience = Developers
31
+ author = William Downing
32
+ author_email = will.downing00@gmail.com
33
+ copyright = 2024 onwards, %(author)s
34
+ description = This is the calssifier between dogs and cats
35
+ keywords = nbdev jupyter notebook python
36
+ language = English
37
+ status = 3
38
+ user = AyyCompadre
39
+
40
+ ### Optional ###
41
+ # requirements = fastcore pandas
42
+ # dev_requirements =
43
+ # console_scripts =