satani commited on
Commit
96032dc
1 Parent(s): da1f323

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -4
app.py CHANGED
@@ -1,7 +1,16 @@
 
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 fastai.vision.all import *
2
  import gradio as gr
3
 
4
+ path = Path()
5
+ learn_inf = load_learner(path/'export.pkl')
6
+ def classify_image(img):
7
+ pred,pred_idx,probs = learn_inf.predict(img)
8
+ return f'Prediction: {pred}; Probability: float({probs[pred_idx]:.04f})'
9
+
10
+ image = gr.inputs.Image(shape=(224, 224))
11
+ label = gr.outputs.Label()
12
+ examples = ['1.jpg', '2.jpg', '3.jpg']
13
+
14
 
15
+ iface = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
16
+ iface.launch(inline=False)