Harshithtd commited on
Commit
46713eb
·
verified ·
1 Parent(s): 2a1fba5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -31,11 +31,11 @@ def predict_image(image):
31
  with torch.no_grad():
32
  outputs = model(processed_image)
33
  probabilities = torch.nn.functional.softmax(outputs, dim=1)
34
- top_probs, top_indices = torch.topk(probabilities, 3)
35
  top_classes = [class_names[idx] for idx in top_indices[0]]
36
 
37
  # Create a result dictionary with class names and probabilities
38
- result = {top_classes[i]: top_probs[0][i].item() for i in range(3)}
39
 
40
  return result
41
 
 
31
  with torch.no_grad():
32
  outputs = model(processed_image)
33
  probabilities = torch.nn.functional.softmax(outputs, dim=1)
34
+ top_probs, top_indices = torch.topk(probabilities, 2)
35
  top_classes = [class_names[idx] for idx in top_indices[0]]
36
 
37
  # Create a result dictionary with class names and probabilities
38
+ result = {top_classes[i]: top_probs[0][i].item() for i in range(2)}
39
 
40
  return result
41