danielcwq commited on
Commit
f31ffba
·
1 Parent(s): 353a189

pushing first DL model to huggingface

Browse files
Files changed (6) hide show
  1. .DS_Store +0 -0
  2. CatsClassifier.pkl +3 -0
  3. ambiguous.jpg +0 -0
  4. app.py +20 -4
  5. cat.jpg +0 -0
  6. dog.jpg +0 -0
.DS_Store ADDED
Binary file (6.15 kB). View file
 
CatsClassifier.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5589472f554647dbf4115edfd518b01583038316943b0e699cc031e0038bb71c
3
+ size 47061355
ambiguous.jpg ADDED
app.py CHANGED
@@ -1,9 +1,25 @@
1
  import gradio as gr
 
 
 
2
 
3
 
4
- def greet(name):
5
- return "Hello " + name + "!!"
6
 
7
 
8
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
9
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from fastai.vision.all import *
3
+ _all_ = ['is_cat', 'learn', 'classify_image',
4
+ 'categories', 'image', 'label', 'examples', 'intf']
5
 
6
 
7
+ def is_cat(x): return x[0].isupper()
 
8
 
9
 
10
+ learn = load_learner('CatsClassifier.pkl')
11
+ categories = ("Dog", "Cat")
12
+
13
+
14
+ def classify_image(img):
15
+ pred, idx, probs = learn.predict(img)
16
+ return dict(zip(categories, map(float, probs)))
17
+
18
+
19
+ image = gr.inputs.Image(shape=(192, 192))
20
+ label = gr.outputs.Label()
21
+ examples = ['dog.jpg', 'cat.jpeg', 'ambiguous.jpg']
22
+
23
+ intf = gr.Interface(fn=classify_image, inputs=image,
24
+ outputs=label, examples=examples)
25
+ intf.launch(inline=False)
cat.jpg ADDED
dog.jpg ADDED