Пример #1
0
 def draw_iqa(img, q, target_a, pred_a):
     fig, ax = tfplot.subplots(figsize=(6, 6))
     ax.imshow(img)
     ax.set_title(question2str(q))
     ax.set_xlabel(
         answer2str(target_a) + answer2str(pred_a, 'Predicted'))
     return fig
Пример #2
0
        def draw_iqa(img, q, target_a, pred_a, weights):
            d = self.d
            H, W = img.shape[:2]

            weights = weights.reshape(d*d, d*d)
            weights_a2b = np.mean(weights, axis=1).reshape(4,4)
            weights_b2a = np.mean(np.transpose(weights), axis=1).reshape(4,4)
            mean_w = (weights_a2b + weights_b2a) / 2
            mean_w = mean_w / np.max(mean_w)



            # print(mean_w.shape, img.shape)
            # print("===========")

            fig, ax = tfplot.subplots(figsize=(6, 6))
            ax.imshow(img, extent=[0,H,0,W])
            mid = ax.imshow(mean_w, cmap='jet',
                      alpha=0.5, extent=[0, H, 0, W])
            fig.colorbar(mid)
            ax.set_title(question2str(q))
            ax.set_xlabel(answer2str(target_a)+answer2str(pred_a, 'Predicted'))
            return fig