def save_attn_map(maps, imgs, path):
        # append images with maps
        img = torch.cat(imgs, maps), 0)
        # making a grid of two columns, images in one and attention in the other
        grid = make_grid(img,nrow=maps.size(0),padding=10)

        npimg = grid.detach().cpu().numpy() # to numpy array

        npimg = (npimg * 255).astype(np.uint8)

        fig, ax = plt.subplots(figsize = (8,2))
        ax.axis("off")
        # transpose numpy array to the PIL format, i.e., Channels x W x H
        ax.imshow(np.transpose(npimg, (1,2,0))) 

        fig.savefig("{}.pdf".format(path),bbox_inches='tight')
        plt.close(fig)

I have the function above, where tensors maps and images have the same size (Batch x Channel x W x H). But when I plot the array npimg, the image I get is totally messed up. What could it be? I tried make a grid with imgs just in case, but I get the same weird thing:

00001.jpg1109×484 322 KB