J commited on
Commit
c3c5160
·
1 Parent(s): 7eabf0c

updates to ui

Browse files
Files changed (4) hide show
  1. .gitignore +2 -0
  2. app.py +16 -4
  3. model.pkl +3 -0
  4. tabby.jpg +0 -0
.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ model.pklZone.Identifier
2
+ tabby-cat-names-1467374954.jpgZone.Identifier
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
  import gradio as gr
2
+ from fastai.vision.all import *
3
+ import PIL
4
 
5
+ learned = load_learner('model.pkl')
 
6
 
7
+ labels = learned.dls.vocab
8
+
9
+ def predict (img):
10
+ img = PILImage.create(img)
11
+ pred, pred_idx, probs = learned.predict(img)
12
+ return dict(zip(labels, map(float, probs)))
13
+
14
+ title = "Cat Predictor"
15
+ examples= ["tabby.jpg"]
16
+
17
+ iface = gr.Interface(fn=predict, title=title, examples=examples, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=3))
18
+
19
+ iface.launch(debug=True)
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:693118bf2aedb896a9745dbeec1a65b2b61d02dd793418f21b7b8b9e9084ab70
3
+ size 47065195
tabby.jpg ADDED