jmorais commited on
Commit
bad9af5
1 Parent(s): 6f62880

Updated app to run trained model

Browse files
Files changed (1) hide show
  1. app.py +16 -4
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
+ from fastbook import *
2
+ from fastai.vision.widgets import *
3
+ from fastai.vision.all import *
4
+
5
  import gradio as gr
6
 
7
+ learn = load_learner("model.pkl")
8
+ categories = ("Cat", "Dog")
9
+
10
+ def classify_img(img):
11
+ pred, idx, probs = learn.predict(img)
12
+ return dict(zip(categories, map(float, probs)))
13
+
14
+ image = gr.inputs.Image(shape=(192, 192))
15
+ label = gr.outputs.Label()
16
+ examples = ["dog.jpg", "cat.jpg", "rock1.jpg", "rock2.jpg", "rocky.jpg"]
17
 
18
+ iface = gr.Interface(fn=classify_img, inputs=image, outputs=label, examples=examples)
19
+ iface.launch(inline=False)