-
Hello, I'm following the TorchCam setup guide to analyze the feature maps produced by the base network of MobileNetSSD. I have an implementation in Pytorch and am running this code from the README: if __name__ == '__main__':
model = create_mobilenetv1_ssd(3, is_test=True)
#Load weights and set to eval mode
model.load_state_dict(torch.load('models\\mb1-ssd-Epoch-10-Loss-9.08724578221639.pth'))
model.eval()
img_path = 'dataset\\JPEGImages\\0a9614a7-IMG_7552.jpg'
img = read_image(img_path)
img = to_pil_image(img)
transform = transforms.Compose([
transforms.Resize((300, 300)),
transforms.ToTensor()
])
input_image = transform(img).unsqueeze(0)
with SmoothGradCAMpp(model, target_layer=model.base_net[-1]) as cam_extractor:
out = model(input_image)
print(out[0].squeeze(0).argmax().item())
activation_map = cam_extractor(5835, out) This is the output of a model prediction. confidences = torch.cat(confidences, 1)
locations = torch.cat(locations, 1)
if self.is_test:
confidences = F.softmax(confidences, dim=2)
boxes = box_utils.convert_locations_to_boxes(
locations, self.priors, self.config.center_variance, self.config.size_variance
)
boxes = box_utils.center_form_to_corner_form(boxes)
return confidences, boxes
else:
return confidences, locations I'm getting
This seems to indicate scores is a tuple, not a tensor as it should be. I cannot figure out why this is. Can someone assist? When I send only out[0] to cam_extractor, I get that the index of the class index from the line |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
My output was a tuple containing confidence scores and bounding box locations - had to ensure that only the confidence score tensor was used. |
Beta Was this translation helpful? Give feedback.
My output was a tuple containing confidence scores and bounding box locations - had to ensure that only the confidence score tensor was used.