Eiriksak commited on
Commit
3ec88f5
1 Parent(s): 48a6fb4
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -2,18 +2,17 @@ import gradio as gr
2
  from fastai.vision.all import *
3
  import json
4
 
5
- def is_cat(x): return x[0].isupper()
6
-
7
-
8
  learn = load_learner('model.pkl')
9
 
10
  with open('categories.json', 'r') as f:
11
- labels = json.load(f)
 
 
12
 
13
  def predict(img):
14
  img = PILImage.create(img)
15
- pred,pred_idx,probs = learn.predict(img)
16
- return {labels[str(i)]: float(probs[i]) for i in range(len(labels))}
17
 
18
 
19
  title = "Predict flower species"
 
2
  from fastai.vision.all import *
3
  import json
4
 
 
 
 
5
  learn = load_learner('model.pkl')
6
 
7
  with open('categories.json', 'r') as f:
8
+ categories = json.load(f)
9
+
10
+ labels = learn.dls.vocab
11
 
12
  def predict(img):
13
  img = PILImage.create(img)
14
+ _, _, probs = learn.predict(img)
15
+ return {f"{categories[labels[i]]} ({labels[i]})": float(probs[i]) for i in range(len(labels))}
16
 
17
 
18
  title = "Predict flower species"