Siddharth Maddali commited on
Commit
1fee263
1 Parent(s): 12523f5

Initial commit of 4way classifier.

Browse files
.gitignore CHANGED
@@ -1,2 +1,3 @@
1
  # vim buffer files
2
  *.swp
 
 
1
  # vim buffer files
2
  *.swp
3
+ *.ipynb
.ipynb_checkpoints/app-checkpoint.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AUTOGENERATED! DO NOT EDIT! File to edit: four-way-classifier.ipynb.
2
+
3
+ # %% auto 0
4
+ __all__ = ['learn', 'categories', 'image', 'label', 'examples', 'interf', 'classify_image']
5
+
6
+ # %% four-way-classifier.ipynb 1
7
+ from fastai.vision.all import *
8
+ import gradio as gr
9
+ import PIL
10
+ import glob
11
+
12
+ # %% four-way-classifier.ipynb 3
13
+ learn = load_learner( 'simple-image-classifier.pkl' )
14
+
15
+ # %% four-way-classifier.ipynb 5
16
+ categories = [ 'bird', 'forest', 'otter', 'snake' ]
17
+
18
+ def classify_image( img ):
19
+ pred, idx, probs = learn.predict( img )
20
+ # print( 'This is a %s'%pred )
21
+ return dict( zip( categories, map( float, probs ) ) )
22
+
23
+ # %% four-way-classifier.ipynb 6
24
+ image = gr.components.Image()
25
+ label = gr.components.Label()
26
+ examples = glob.glob( './resized-*.jpg' )
27
+
28
+ interf = gr.Interface( fn=classify_image, inputs=image, outputs=label, examples=examples, allow_flagging='manual' )
29
+ interf.launch( inline=True )
03987623409862737409280474529876.jpg ADDED
2348976234782938476192387162319.jpg ADDED
2498756234958762345238495823745624759.jpg ADDED
9687263544023498279387456293482342.jpg ADDED
app.py CHANGED
@@ -1,7 +1,44 @@
 
 
 
 
 
 
 
1
  import gradio as gr
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
- def greet( name ):
4
- return 'Hello %s!!'%name
 
 
 
 
5
 
6
- iface = gr.Interface( fn=greet, inputs='text', outputs='text' )
7
- iface.launch()
 
 
 
 
 
 
 
 
 
1
+ # AUTOGENERATED! DO NOT EDIT! File to edit: four-way-classifier.ipynb.
2
+
3
+ # %% auto 0
4
+ __all__ = ['learn', 'categories', 'description', 'image', 'label', 'examples', 'interf', 'classify_image']
5
+
6
+ # %% four-way-classifier.ipynb 1
7
+ from fastai.vision.all import *
8
  import gradio as gr
9
+ import PIL
10
+ import glob
11
+
12
+ # %% four-way-classifier.ipynb 3
13
+ learn = load_learner( 'simple-image-classifier.pkl' )
14
+
15
+ # %% four-way-classifier.ipynb 5
16
+ categories = [ 'bird', 'forest', 'otter', 'snake' ]
17
+
18
+ def classify_image( img ):
19
+ pred, idx, probs = learn.predict( img )
20
+ # print( 'This is a %s'%pred )
21
+ return dict( zip( categories, map( float, probs ) ) )
22
+
23
+ # %% four-way-classifier.ipynb 7
24
+ description='''
25
+ A simple 4-way classifier that categorizes images as 'snake', 'bird', 'otter' or 'forest'.
26
+ Refined from an initial ResNet18 model downloaded from HuggingFace.
27
 
28
+ **DISCLAIMER**: the images here are merely for demonstration purposes. I don't own any of them
29
+ and I'm not making money from them.
30
+ '''
31
+ image = gr.components.Image()
32
+ label = gr.components.Label()
33
+ examples = glob.glob( './*.jpg' )
34
 
35
+ interf = gr.Interface(
36
+ title='Simple 4-way image classifier',
37
+ description=description,
38
+ fn=classify_image,
39
+ inputs=image,
40
+ outputs=label,
41
+ examples=examples,
42
+ allow_flagging='manual'
43
+ )
44
+ interf.launch( inline=True )
simple-image-classifier.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d02885ded4227701e2061e81a94d034b8fa8a7a84584bcf8401f7e0743f6ec3d
3
+ size 46982768