def visualize_test_time(self, content_dict, visualize_indices,
                            verbose_folder):
        # save classifier preds
        sel_sigmoids = self.sigmoids[visualize_indices]
        sigmoid_images = visualize_barplot_array(sel_sigmoids)
        row_name = 'sigmoid_images'
        content_dict[row_name] = save_imgs_direct(verbose_folder, row_name,
                                                  sigmoid_images)

        sel_softmax_dists = self.softmax_differences[visualize_indices]
        sigmoid_images = visualize_barplot_array(sel_softmax_dists)
        row_name = 'softmax_of_differences'
        content_dict[row_name] = save_imgs_direct(verbose_folder, row_name,
                                                  sigmoid_images)
Esempio n. 2
0
    def log_pair_predictions(self, img_pair, softmax_prediction, label, name,
                             step, phase):

        image_pairs = img_pair.data.cpu().numpy().squeeze()
        softmax_prediction = softmax_prediction.data.cpu().numpy().squeeze()

        first_row = image_pairs[:, 0]
        first_row = first_row[:self._n_logged_samples]
        first_row = np.concatenate(unstack(first_row, 0), 2)

        second_row = image_pairs[:, 1]
        second_row = second_row[:self._n_logged_samples]
        second_row = np.concatenate(unstack(second_row, 0), 2)

        pred_score_images = visualize_barplot_array(
            softmax_prediction[:self._n_logged_samples])
        pred_score_images = [
            np.transpose((img.astype(np.float32)) / 255., [2, 0, 1])
            for img in pred_score_images
        ]
        pred_row = np.concatenate(pred_score_images, axis=2)

        label_row = get_text_row(label,
                                 self._n_logged_samples,
                                 shape=(30, pred_score_images[0].shape[1]))

        full_image = (np.concatenate(
            [first_row, second_row, pred_row, label_row], 1) + 1.) / 2.0

        self._summ_writer.add_image('{}_{}'.format(name, phase), full_image,
                                    step)
 def visualize_test_time(self, content_dict, visualize_indices,
                         verbose_folder):
     # save classifier preds
     sel_softmax = self.out_softmax[visualize_indices]
     sigmoid_images = visualize_barplot_array(sel_softmax)
     row_name = 'softmax'
     content_dict[row_name] = save_imgs_direct(verbose_folder, row_name,
                                               sigmoid_images)
    def vis_dist_over_traj(self, inputs, step):
        images = inputs.demo_seq_images

        cols = []
        n_ex = 10

        for t in range(images.shape[1]):
            outputs = self.forward({
                'current_img': images[:, t],
                'goal_img': images[:, -1]
            })

            sigmoid = []
            for i in range(len(outputs)):
                sigmoid.append(
                    outputs[i].out_sigmoid.data.cpu().numpy().squeeze())
            sigmoids = np.stack(sigmoid, axis=1)

            sig_img_t = visualize_barplot_array(sigmoids[:n_ex])

            img_column_t = []
            images_npy = images.data.cpu().numpy().squeeze()
            for b in range(n_ex):
                img_column_t.append(ptrch2uint8(images_npy[b, t]))
                img_column_t.append(np.transpose(sig_img_t[b], [2, 0, 1]))
            img_column_t = np.concatenate(img_column_t, axis=1)
            cols.append(img_column_t)

        image = np.concatenate(cols, axis=2)
        # cv2.imwrite('/nfs/kun1/users/febert/data/vmpc_exp/dist_over_traj.png', np.transpose(image, [1,2,0]))
        self._logger.log_image(image, 'dist_over_traj', step, phase='test')
        self._logger.log_video(np.stack(cols, axis=0),
                               'dist_over_traj_gif',
                               step,
                               phase='test')

        print('logged dist over traj')