Daleef Rahman commited on
Commit
adfe3bd
·
1 Parent(s): ac5e28e
Files changed (1) hide show
  1. app.py +20 -4
app.py CHANGED
@@ -1,7 +1,23 @@
 
1
  import gradio as gr
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastai.vision.all import *
2
  import gradio as gr
3
 
4
+ learn = load_learner('model.pkl')
5
+ categories = ('Black', 'Grizzly', 'Teddy')
6
 
7
+ def classify_image(img):
8
+ pred, idx, probs = learn.predict(img)
9
+ return dict(zip(categories, map(float, probs)))
10
+
11
+ # Modern API (Gradio 4.x)
12
+ image = gr.Image(type="pil", height=192, width=192, label="Upload an Image")
13
+ label = gr.Label()
14
+ examples = ['black.jpg', 'bear.jpg', 'teddy.jpg']
15
+
16
+ intf = gr.Interface(
17
+ fn=classify_image,
18
+ inputs=image,
19
+ outputs=label,
20
+ examples=examples
21
+ )
22
+
23
+ intf.launch()