예제 #1
0
파일: GradCam.py 프로젝트: raguram/eva
    def superImpose(self, data, heatMapImages, muSigPair):

        superImposedImages = []
        images = Utility.toImages(data, muSigPair)
        for i, image in enumerate(images):
            image = np.uint8(255 * image)
            heatmap = 1 - heatMapImages[i]
            heatmap = np.uint8(255 * heatmap.squeeze())
            heatmap = cv2.applyColorMap(heatmap, cv2.COLORMAP_JET)

            superImposed = cv2.addWeighted(image, 0.5, heatmap, 0.5, 0)
            superImposedImages.append(superImposed)

        return superImposedImages
예제 #2
0
파일: GradCam.py 프로젝트: raguram/eva
    def visualize(self,
                  data,
                  data_targets,
                  classes,
                  count=5,
                  muSigPair=None,
                  figSize=(15, 15)):

        heatmaps, cam_pred = self.gradCam(data)
        randIndices = Utility.pickRandomElements(data, count)

        rand_data, rand_targets, rand_cam_pred = data[
            randIndices], data_targets[randIndices], cam_pred[randIndices]
        rand_superImposedImages = {}
        for layer in heatmaps:
            rand_superImposedImages[layer] = self.superImpose(
                rand_data, heatmaps[layer], muSigPair)

        self.plot(Utility.toImages(rand_data, muSigPair), rand_targets,
                  rand_cam_pred, rand_superImposedImages, classes, figSize)