again switched to softmax as exp was crossing confidence leavel over 100
Browse files
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 |
-
|
36 |
-
|
37 |
-
exp_outputs = torch.exp(outputs.flatten())
|
38 |
-
|
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)
|