Mohammadreza Ghaffarzadeh commited on
Commit
fece23c
1 Parent(s): 17bb216

now is completely finished

Browse files
Files changed (1) hide show
  1. app.py +1 -1
app.py CHANGED
@@ -19,7 +19,7 @@ def classifier(image):
19
  logits = outputs.logits
20
  probabilities = torch.nn.functional.softmax(logits, dim=-1)
21
  predicted_class_idxs = probabilities.topk(5, dim=-1)[1].tolist()[0]
22
- probabilities = probabilities.tolist()[0][:5]
23
  classes = [model.config.id2label[idx] for idx in predicted_class_idxs]
24
  df = pd.DataFrame({'food':classes , 'posibility': probabilities})
25
  return df.to_html(index=False)
 
19
  logits = outputs.logits
20
  probabilities = torch.nn.functional.softmax(logits, dim=-1)
21
  predicted_class_idxs = probabilities.topk(5, dim=-1)[1].tolist()[0]
22
+ probabilities = sorted(probabilities.tolist()[0], reverse=True)[:5]
23
  classes = [model.config.id2label[idx] for idx in predicted_class_idxs]
24
  df = pd.DataFrame({'food':classes , 'posibility': probabilities})
25
  return df.to_html(index=False)