Ejemplo n.º 1
0
    def _SAVE_IMAGE(self,
                    save_path,
                    fake_list,
                    Attention=False,
                    mode='fake',
                    circle=False,
                    arrow=False,
                    no_label=False):
        fake_images = torch.cat(fake_list, dim=3)
        if 'fake' not in os.path.basename(save_path):
            save_path = save_path.replace('.jpg', '_fake.jpg')
        if Attention:
            mode = mode + '_attn'
        else:
            fake_images = denorm(fake_images)

        save_path = save_path.replace('fake', mode)
        if circle:
            fake_images = create_circle(fake_images, self.config.image_size)
        if not no_label:
            fake_images = torch.cat((self.get_labels(), fake_images), dim=0)
        save_image(fake_images, save_path, nrow=1, padding=0)
        # if arrow or no_label:
        if arrow:
            create_arrow(
                save_path,
                arrow,
                image_size=self.config.image_size,
                horizontal=no_label)
        return save_path
Ejemplo n.º 2
0
    def Create_Visual_List(self, batch, Multimodal=False):
        batch = to_data(batch)
        if Multimodal:
            fake_image_list = single_source(batch)
            fake_attn_list = single_source(denorm(batch))
            fake_image_list = color_frame(
                fake_image_list, thick=5, color='green', first=True)
            fake_attn_list = color_frame(
                fake_attn_list, thick=5, color='green', first=True)
            fake_image_list = [fake_image_list.cpu()]
            fake_attn_list = [fake_attn_list.cpu()]
        else:
            fake_image_list = [batch.cpu()]
            fake_attn_list = [denorm(batch).cpu()]

        return fake_image_list, fake_attn_list
Ejemplo n.º 3
0
    def Create_Visual_List(self, batch):
        fake_image_list = single_source(to_data(batch))
        fake_attn_list = single_source(denorm(to_data(batch)))

        fake_image_list = color_frame(
            fake_image_list, thick=5, color='green', first=True)
        fake_attn_list = color_frame(
            fake_attn_list, thick=5, color='green', first=True)

        fake_image_list = [fake_image_list.cpu()]
        fake_attn_list = [fake_attn_list.cpu()]

        return fake_image_list, fake_attn_list
Ejemplo n.º 4
0
 def imshow(self, img):
     import matplotlib.pyplot as plt
     img = to_data(denorm(img), cpu=True).numpy()
     img = img.transpose(1, 2, 0)
     plt.imshow(img)
     plt.show()