satish860 commited on
Commit
22784ab
·
1 Parent(s): 8dcc4d3

corrected run time error

Browse files
Files changed (2) hide show
  1. .ipynb_checkpoints/app-checkpoint.py +18 -0
  2. app.py +1 -1
.ipynb_checkpoints/app-checkpoint.py CHANGED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from fastai.vision.all import *
3
+
4
+ learner = load_learner('model.pkl')
5
+ categories = learner.dls.vocab
6
+
7
+ def predict(img):
8
+ preds,idx,probs = learner.predict(img)
9
+ return dict(zip(categories,map(float,probs)))
10
+
11
+ examples = ['Arborio.jpg','Basmati.jpg','Ipsala.jpg','Jasmine.jpg','Karacadag.jpg']
12
+
13
+
14
+ demo = gr.Interface(fn=predict,
15
+ inputs=gr.inputs.Image(shape=(224, 224)),
16
+ outputs= gr.outputs.Label()
17
+ )
18
+ demo.launch(inline=False)
app.py CHANGED
@@ -2,7 +2,7 @@ import gradio as gr
2
  from fastai.vision.all import *
3
 
4
  learner = load_learner('model.pkl')
5
- categories = learn.dls.vocab
6
 
7
  def predict(img):
8
  preds,idx,probs = learner.predict(img)
 
2
  from fastai.vision.all import *
3
 
4
  learner = load_learner('model.pkl')
5
+ categories = learner.dls.vocab
6
 
7
  def predict(img):
8
  preds,idx,probs = learner.predict(img)