manan05 commited on
Commit
2c08f94
1 Parent(s): bd7f417

Added classifier model

Browse files
Files changed (4) hide show
  1. app.py +16 -4
  2. export.pkl +3 -0
  3. lion.jpg +0 -0
  4. requirements.txt +1 -0
app.py CHANGED
@@ -1,7 +1,19 @@
 
 
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
+ __all__ = ['learnafter', 'classify_images', 'categories', 'image', 'label', 'examples', 'iface']
2
+
3
  import gradio as gr
4
+ from fastai.vision.all import *
5
+
6
+ learnafter = load_learner('export.pkl')
7
+
8
+ categories = ('cheetah','lion','tiger')
9
+
10
+ def classify_images(img):
11
+ pred, idx, probs = learnafter.predict(img)
12
+ return dict(zip(categories, map(float, probs)))
13
 
14
+ image = gr.inputs.Image(shape=(224, 224))
15
+ label = gr.outputs.Label()
16
+ examples = ['lion.jpg']
17
 
18
+ iface = gr.Interface(fn=classify_images, inputs=image, outputs=label)
19
+ iface.launch(inline=False)
export.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:15f87cefc0b933318832ddc7b96cd10e055dc5d022621a01b4d02ca422a2e29a
3
+ size 46970575
lion.jpg ADDED
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ fastai==2.7.12