rafiahmed patel commited on
Commit
b99b08e
·
1 Parent(s): 4ad6025
Files changed (3) hide show
  1. app.py +24 -4
  2. dog.jpg +0 -0
  3. model.pkl +3 -0
app.py CHANGED
@@ -1,7 +1,27 @@
 
 
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
+
2
+ from fastai.vision.all import *
3
  import gradio as gr
4
 
 
 
5
 
6
+ def is_cat(x): return x[0].isupper()
7
+
8
+ # #posix path error handler from stack overflow
9
+ # import pathlib
10
+ # temp = pathlib.PosixPath
11
+ # pathlib.PosixPath = pathlib.WindowsPath
12
+
13
+ learn = load_learner("model.pkl")
14
+
15
+ categories = ('Dog','Cat')
16
+
17
+ def classify_image(img):
18
+ pred, idx,probs =learn.predict(img)
19
+ return dict(zip(categories, map(float,probs)))
20
+
21
+ image = gr.components.Image(shape = (192,192))
22
+ # image = gr.components
23
+ label = gr.components.Label()
24
+ examples = ['dog.jpg']
25
+
26
+ intf = gr.Interface(fn = classify_image , inputs = image, outputs=label, examples=examples)
27
+ intf.launch(inline = False)
dog.jpg ADDED
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3bf13722aef34ef7438843ae08d7d0dfe631d461732c796c5943aea4e9fc83ea
3
+ size 47058513