2010b9 commited on
Commit
06ae1bb
1 Parent(s): df7c1ec

Update app with an image classifier

Browse files
Files changed (1) hide show
  1. app.py +13 -4
app.py CHANGED
@@ -1,9 +1,18 @@
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.learner import load_learner
3
 
4
+ model = load_learner("model.pkl")
5
 
 
 
6
 
7
+ def classify_image(image):
8
+ preds = model.predict(image)[2]
9
+ return dict(zip(["Bird", "Forest"], preds.tolist()))
10
 
11
+
12
+ gr.Interface(
13
+ fn=classify_image,
14
+ inputs=gr.Image(),
15
+ outputs=gr.Label(num_top_classes=2),
16
+ examples=["images/bird.jpeg", "images/forest.jpeg"],
17
+ title="Bird or Forest?",
18
+ ).launch()