Kathir commited on
Commit
f3fb2e1
·
1 Parent(s): 81515a3

Added Low accuracy warning

Browse files
Files changed (2) hide show
  1. __pycache__/model.cpython-310.pyc +0 -0
  2. app.py +6 -4
__pycache__/model.cpython-310.pyc ADDED
Binary file (744 Bytes). View file
 
app.py CHANGED
@@ -1,4 +1,3 @@
1
-
2
  import torch
3
  import torchvision
4
  import os
@@ -33,9 +32,12 @@ def predict(img):
33
  with torch.inference_mode():
34
  pred_logits = vit_b16_model(img)
35
  preds = torch.softmax(pred_logits, dim=1)
36
-
37
- # Create a prediction label and prediction probability dictionary for each prediction class
38
- pred_and_prob_labels = {class_names[i]: preds[0][i].item() for i in range(len(class_names))}
 
 
 
39
 
40
  return pred_and_prob_labels
41
 
 
 
1
  import torch
2
  import torchvision
3
  import os
 
32
  with torch.inference_mode():
33
  pred_logits = vit_b16_model(img)
34
  preds = torch.softmax(pred_logits, dim=1)
35
+ if preds[0].max().item() * 100 > 20:
36
+ # Create a prediction label and prediction probability dictionary for each prediction class
37
+ pred_and_prob_labels = {class_names[i]: preds[0][i].item() for i in range(len(class_names))}
38
+
39
+ else:
40
+ pred_and_prob_labels = {"Low Accuracy Warning !!! Kindly verify whether the given image is a Bird.": preds[0].max().item()}
41
 
42
  return pred_and_prob_labels
43