lehmannerich commited on
Commit
0883c37
·
1 Parent(s): b0290db

Just typed from fasai

Browse files
Files changed (2) hide show
  1. app.py +25 -4
  2. model.pkl +3 -0
app.py CHANGED
@@ -1,9 +1,30 @@
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
+ import fastai.vision.all import *
3
 
4
+ _all_ = ['is_cat', 'learn', 'classify_image',
5
+ 'categories', 'image', 'label', 'examples', 'intf']
6
 
7
+ # cell
 
8
 
9
 
10
+ def is_cat(x): return x[0].isupper()
11
+
12
+
13
+ # cell
14
+ learn = load_learner('model.pkl')
15
+
16
+ # cell
17
+ categories = ('Dog', 'Cat')
18
+
19
+
20
+ def classify_image(img):
21
+ pred, idx, probs = learn.predict(img)
22
+ return dict(zip(categories, map(float, probs)))
23
+
24
+
25
+ # cell
26
+ image = gr.input.Image(shape=(192, 192))
27
+ label = gr.outputs.Label()
28
+
29
+ iface = gr.Interface(fn=classify_image, inputs=image, outputs=label)
30
+ iface.launch(inline=False)
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:55427395c909f272407029237124a5d21b8d6f88647f5eb4a57e199a8eff7c59
3
+ size 47046315