GameHasNoGame commited on
Commit
14f886a
·
verified ·
1 Parent(s): 70f4300

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -7,11 +7,13 @@ learn = load_learner('food_classif_model_v1.pkl')
7
  def predict_image(img):
8
  pred,los,prob = learn.predict(img)
9
  top_values, top_indx = torch.topk(prob, 3) # show 3 max values
 
10
 
11
  if (top_values < 0.4).all():
12
- return 'I do not know what is that'
13
  else:
14
- return f'{food_indx[top_indx[0]]} = {top_values[0]}\n{food_indx[top_indx[1]]} = {top_values[1]}\n{food_indx[top_indx[2]]} = {top_values[2]}'
 
15
 
16
 
17
  # UI huggface
 
7
  def predict_image(img):
8
  pred,los,prob = learn.predict(img)
9
  top_values, top_indx = torch.topk(prob, 3) # show 3 max values
10
+ text_out = ''
11
 
12
  if (top_values < 0.4).all():
13
+ text_out = 'I do not know what is that'
14
  else:
15
+ text_out = f'{food_indx[top_indx[0]]} = {top_values[0]}\n{food_indx[top_indx[1]]} = {top_values[1]}\n{food_indx[top_indx[2]]} = {top_values[2]}'
16
+ return text_out
17
 
18
 
19
  # UI huggface