// Multiply each weight with its conv output and then, sum
for i, w in enumerate(weights):
cam += w * target[i, :, :]
cam = cv2.resize(cam, (224, 224))
cam = np.maximum(cam, 0)
cam = (cam - np.min(cam)) / (np.max(cam) - np.min(cam)) // Normalize between 0-1
cam = np.uint8(cam * 255) // Scale between 0-255 to visualize
return cam
After Change
cam = np.maximum(cam, 0)
cam = (cam - np.min(cam)) / (np.max(cam) - np.min(cam)) // Normalize between 0-1
cam = np.uint8(cam * 255) // Scale between 0-255 to visualize
cam = np.uint8(Image.fromarray(cam).resize((input_image.shape[2],
input_image.shape[3]), Image.ANTIALIAS))
// ^ I am extremely unhappy with this line. Originally resizing was done in cv2 which
// supports resizing numpy matrices, however, when I moved the repository to PIL, this