sanket03 commited on
Commit
72dc25c
·
1 Parent(s): 696592b

again switched to softmax as exp was crossing confidence leavel over 100

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -32,11 +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
- 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)
 
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)