karancl commited on
Commit
df4237f
·
1 Parent(s): cb10eb2

feat: Update app.py and add model with LFS

Browse files
Files changed (3) hide show
  1. .gitignore +1 -0
  2. app.py +45 -4
  3. model (1).pkl +3 -0
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ .DS_Store
app.py CHANGED
@@ -1,7 +1,48 @@
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
1
+ # -*- coding: utf-8 -*-
2
+ """app
3
+
4
+ Automatically generated by Colab.
5
+
6
+ Original file is located at
7
+ https://colab.research.google.com/drive/1SudNQMVhTicfHu2_eWce7kTx7dNNFgIE
8
+ """
9
+
10
+ from fastai.vision.all import *
11
  import gradio as gr
12
 
13
+ def is_cat(x):
14
+ return x[0].isupper()
15
+
16
+ im = PILImage.create('dog.webp')
17
+ im.thumbnail((192,192))
18
+ im
19
+
20
+ #|export
21
+ learn = load_learner('model (1).pkl')
22
+
23
+ learn.predict(im)
24
+
25
+ #|export
26
+ categories = ('Dog','Cat')
27
+
28
+ def classify_image(img):
29
+ pred,idx,probs = learn.predict(img)
30
+ return dict(zip(categories, map(float,probs)))
31
+
32
+ classify_image(im)
33
+
34
+ #|export
35
+ image = gr.Image()
36
+ label = gr.Label()
37
+
38
+ examples = ['dog.jpg', 'cat.jpg', 'dunno.jpg']
39
+
40
+ intf = gr.Interface(fn=classify_image, inputs = image, outputs = label, examples = examples)
41
+ intf.launch(inline=False)
42
+
43
+ """*** we will export some essential selected cells as the prediction script as a python file using the below commands"""
44
+
45
+ !pip install nbdev
46
+
47
+ !pip install --upgrade nbdev
48
 
 
 
model (1).pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dee7b4ff81acaef681bc94e16ce2b4e5bd0bb206341d7c8089354109b4aa37df
3
+ size 47069063