sanket03 commited on
Commit
696592b
·
1 Parent(s): 5cd7415

replaced softmax with exp as it is already in the model arch

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -32,9 +32,11 @@ def inference(input_img, transparency = 0.5, target_layer_number = -1, num_top_c
32
  # input_img = input_img
33
  input_img = input_img.unsqueeze(0)
34
  outputs = model(input_img)
35
- softmax = torch.nn.Softmax(dim=0)
36
- o = softmax(outputs.flatten())
37
- confidences = {classes[i]: float(o[i]) for i in range(10)}
 
 
38
  _, prediction = torch.max(outputs, 1)
39
  target_layers = [model.layer3_r3[target_layer_number]]
40
  cam = GradCAM(model=model, target_layers=target_layers, use_cuda=False)
 
32
  # input_img = input_img
33
  input_img = input_img.unsqueeze(0)
34
  outputs = model(input_img)
35
+ # softmax = torch.nn.Softmax(dim=0)
36
+ # o = softmax(outputs.flatten())
37
+ exp_outputs = torch.exp(outputs.flatten())
38
+ # confidences = {classes[i]: float(o[i]) for i in range(10)}
39
+ confidences = {classes[i]: float(exp_outputs[i]) for i in range(10)}
40
  _, prediction = torch.max(outputs, 1)
41
  target_layers = [model.layer3_r3[target_layer_number]]
42
  cam = GradCAM(model=model, target_layers=target_layers, use_cuda=False)