From 3c3703b03e300a662924e5f81ab79a6ff8f23f18 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 15 Apr 2024 13:30:25 +0200 Subject: [PATCH 001/133] Create my_dataset.py Create my own data_loader --- data/my_dataset.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 data/my_dataset.py diff --git a/data/my_dataset.py b/data/my_dataset.py new file mode 100644 index 00000000000..e8ccb761c43 --- /dev/null +++ b/data/my_dataset.py @@ -0,0 +1,38 @@ +from data.base_dataset import BaseDataset, get_transform +from data.image_folder import make_dataset +import tifffile as tiff +from PIL import Image + +class MyDataset(BaseDataset): + """Custom dataset class.""" + + def __init__(self, opt): + """Initialize this dataset class. + + Parameters: + opt (Option class) -- stores all the experiment flags; needs to be a subclass of BaseOptions + """ + BaseDataset.__init__(self, opt) + self.A_paths = sorted(make_dataset(opt.dataroot, opt.max_dataset_size)) + input_nc = self.opt.output_nc if self.opt.direction == 'BtoA' else self.opt.input_nc + self.transform = get_transform(opt, grayscale=(input_nc == 1)) + + def __getitem__(self, index): + """Return a data point and its metadata information. + + Parameters: + index - - a random integer for data indexing + + Returns a dictionary that contains A and A_paths + A(tensor) - - an image in one domain + A_paths(str) - - the path of the image + """ + A_path = self.A_paths[index] + A_img = tiff.imread(A_path) # Load the TIFF image + A_img = Image.fromarray(A_img.squeeze(), mode='L') # Convert the NumPy array to a PIL image + A = self.transform(A_img) + return {'A': A, 'A_paths': A_path} + + def __len__(self): + """Return the total number of images in the dataset.""" + return len(self.A_paths) From 591c710b2be05c5bfb950680fa1249309208e8ae Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 15 Apr 2024 14:06:41 +0200 Subject: [PATCH 002/133] Update base_options.py changes in base_options --- options/base_options.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/options/base_options.py b/options/base_options.py index 3b951f4c447..177f0128466 100644 --- a/options/base_options.py +++ b/options/base_options.py @@ -26,8 +26,8 @@ def initialize(self, parser): parser.add_argument('--checkpoints_dir', type=str, default='./checkpoints', help='models are saved here') # model parameters parser.add_argument('--model', type=str, default='cycle_gan', help='chooses which model to use. [cycle_gan | pix2pix | test | colorization]') - parser.add_argument('--input_nc', type=int, default=3, help='# of input image channels: 3 for RGB and 1 for grayscale') - parser.add_argument('--output_nc', type=int, default=3, help='# of output image channels: 3 for RGB and 1 for grayscale') + parser.add_argument('--input_nc', type=int, default=1, help='# of input image channels: 3 for RGB and 1 for grayscale') + parser.add_argument('--output_nc', type=int, default=1, help='# of output image channels: 3 for RGB and 1 for grayscale') parser.add_argument('--ngf', type=int, default=64, help='# of gen filters in the last conv layer') parser.add_argument('--ndf', type=int, default=64, help='# of discrim filters in the first conv layer') parser.add_argument('--netD', type=str, default='basic', help='specify discriminator architecture [basic | n_layers | pixel]. The basic model is a 70x70 PatchGAN. n_layers allows you to specify the layers in the discriminator') @@ -38,7 +38,7 @@ def initialize(self, parser): parser.add_argument('--init_gain', type=float, default=0.02, help='scaling factor for normal, xavier and orthogonal.') parser.add_argument('--no_dropout', action='store_true', help='no dropout for the generator') # dataset parameters - parser.add_argument('--dataset_mode', type=str, default='unaligned', help='chooses how datasets are loaded. [unaligned | aligned | single | colorization]') + parser.add_argument('--dataset_mode', type=str, default='mydataset', help='chooses how datasets are loaded. [unaligned | aligned | single | colorization | mydataset]') parser.add_argument('--direction', type=str, default='AtoB', help='AtoB or BtoA') parser.add_argument('--serial_batches', action='store_true', help='if true, takes images in order to make batches, otherwise takes them randomly') parser.add_argument('--num_threads', default=4, type=int, help='# threads for loading data') From cb2751884106df169d12bfac340a8d8040f26936 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 15 Apr 2024 16:21:09 +0200 Subject: [PATCH 003/133] Rename my_dataset.py to mydataset_dataset.py Rename file --- data/{my_dataset.py => mydataset_dataset.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename data/{my_dataset.py => mydataset_dataset.py} (100%) diff --git a/data/my_dataset.py b/data/mydataset_dataset.py similarity index 100% rename from data/my_dataset.py rename to data/mydataset_dataset.py From 87567e809a384a6daa023f5d265b8a9fea51a64a Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Thu, 18 Apr 2024 17:23:16 +0200 Subject: [PATCH 004/133] Update test.py Changes for tif --- test.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test.py b/test.py index b91d302fa36..8069532d835 100644 --- a/test.py +++ b/test.py @@ -76,5 +76,15 @@ img_path = model.get_image_paths() # get image paths if i % 5 == 0: # save images to an HTML file print('processing (%04d)-th image... %s' % (i, img_path)) - save_images(webpage, visuals, img_path, aspect_ratio=opt.aspect_ratio, width=opt.display_winsize, use_wandb=opt.use_wandb) + # Save images as TIFF + for label, image_numpy in visuals.items(): + image_path = img_path[0] if len(img_path) == 1 else img_path[i] + image_name, ext = os.path.splitext(os.path.basename(image_path)) + save_path = os.path.join(web_dir, f'{image_name}_{label}.tiff') + imageio.imwrite(save_path, image_numpy) + if opt.use_wandb: + wandb.save(save_path) + # Stampare l'estensione di ogni immagine + print(f"L'estensione dell'immagine {image_name}_{label} è: {ext}") + #save_images(webpage, visuals, img_path, aspect_ratio=opt.aspect_ratio, width=opt.display_winsize, use_wandb=opt.use_wandb) webpage.save() # save the HTML From 1cf457f511e78e0a2231923eedf656c4e1306ea3 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Thu, 18 Apr 2024 18:55:09 +0200 Subject: [PATCH 005/133] Update test.py Adding missing import --- test.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test.py b/test.py index 8069532d835..a29099caffe 100644 --- a/test.py +++ b/test.py @@ -26,6 +26,7 @@ See training and test tips at: https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix/blob/master/docs/tips.md See frequently asked questions at: https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix/blob/master/docs/qa.md """ +import imageio import os from options.test_options import TestOptions from data import create_dataset From e9f69d6b8d522312faf2ffdacb9e8e8d0f1b96cb Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Thu, 18 Apr 2024 19:06:06 +0200 Subject: [PATCH 006/133] Update test.py Trying to fix issue --- test.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test.py b/test.py index a29099caffe..1d2b0b6c1cc 100644 --- a/test.py +++ b/test.py @@ -82,10 +82,13 @@ image_path = img_path[0] if len(img_path) == 1 else img_path[i] image_name, ext = os.path.splitext(os.path.basename(image_path)) save_path = os.path.join(web_dir, f'{image_name}_{label}.tiff') + # Sposta il tensore sulla CPU e quindi convertilo in un array NumPy + image_numpy = image_numpy.cpu().numpy() imageio.imwrite(save_path, image_numpy) if opt.use_wandb: wandb.save(save_path) # Stampare l'estensione di ogni immagine print(f"L'estensione dell'immagine {image_name}_{label} è: {ext}") + #save_images(webpage, visuals, img_path, aspect_ratio=opt.aspect_ratio, width=opt.display_winsize, use_wandb=opt.use_wandb) webpage.save() # save the HTML From 33fa1a5b243363eb25b5d7f94310dcb9f6c6a241 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Thu, 18 Apr 2024 19:14:32 +0200 Subject: [PATCH 007/133] Update test.py Trying to fix issue_2 --- test.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test.py b/test.py index 1d2b0b6c1cc..add3737351b 100644 --- a/test.py +++ b/test.py @@ -26,7 +26,7 @@ See training and test tips at: https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix/blob/master/docs/tips.md See frequently asked questions at: https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix/blob/master/docs/qa.md """ -import imageio +import tifffile import os from options.test_options import TestOptions from data import create_dataset @@ -83,8 +83,9 @@ image_name, ext = os.path.splitext(os.path.basename(image_path)) save_path = os.path.join(web_dir, f'{image_name}_{label}.tiff') # Sposta il tensore sulla CPU e quindi convertilo in un array NumPy - image_numpy = image_numpy.cpu().numpy() - imageio.imwrite(save_path, image_numpy) + image_numpy = image_numpy.cpu().numpy() + # Salva l'immagine come tiff utilizzando tifffile + tifffile.imwrite(save_path, image_numpy) if opt.use_wandb: wandb.save(save_path) # Stampare l'estensione di ogni immagine From 9d85be3492867486ef59620c381ac2e09424921b Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Thu, 18 Apr 2024 19:22:57 +0200 Subject: [PATCH 008/133] Update test.py Issue solved --- test.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/test.py b/test.py index add3737351b..b2010fc5284 100644 --- a/test.py +++ b/test.py @@ -82,14 +82,11 @@ image_path = img_path[0] if len(img_path) == 1 else img_path[i] image_name, ext = os.path.splitext(os.path.basename(image_path)) save_path = os.path.join(web_dir, f'{image_name}_{label}.tiff') - # Sposta il tensore sulla CPU e quindi convertilo in un array NumPy image_numpy = image_numpy.cpu().numpy() # Salva l'immagine come tiff utilizzando tifffile tifffile.imwrite(save_path, image_numpy) if opt.use_wandb: wandb.save(save_path) - # Stampare l'estensione di ogni immagine - print(f"L'estensione dell'immagine {image_name}_{label} è: {ext}") #save_images(webpage, visuals, img_path, aspect_ratio=opt.aspect_ratio, width=opt.display_winsize, use_wandb=opt.use_wandb) webpage.save() # save the HTML From 8b3354e2fb8f71ca520b1e8a125015f1617889b8 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Fri, 19 Apr 2024 00:05:15 +0200 Subject: [PATCH 009/133] Update test.py Fixing uint16 --- test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.py b/test.py index b2010fc5284..2f65f665a62 100644 --- a/test.py +++ b/test.py @@ -84,7 +84,7 @@ save_path = os.path.join(web_dir, f'{image_name}_{label}.tiff') image_numpy = image_numpy.cpu().numpy() # Salva l'immagine come tiff utilizzando tifffile - tifffile.imwrite(save_path, image_numpy) + tifffile.imwrite(save_path, image_numpy(np.uint16)) if opt.use_wandb: wandb.save(save_path) From f4250cad4af9a11365f1248f7356801934c29a02 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Fri, 19 Apr 2024 00:15:56 +0200 Subject: [PATCH 010/133] Update test.py Missing import --- test.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test.py b/test.py index 2f65f665a62..058c0128427 100644 --- a/test.py +++ b/test.py @@ -28,6 +28,7 @@ """ import tifffile import os +import numpy as np from options.test_options import TestOptions from data import create_dataset from models import create_model From 96ab16d854ef7aa19d5c3deaaaa6ea82053e9a64 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Fri, 19 Apr 2024 00:21:21 +0200 Subject: [PATCH 011/133] Update test.py Missing thing --- test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.py b/test.py index 058c0128427..e197b0ac4fd 100644 --- a/test.py +++ b/test.py @@ -85,7 +85,7 @@ save_path = os.path.join(web_dir, f'{image_name}_{label}.tiff') image_numpy = image_numpy.cpu().numpy() # Salva l'immagine come tiff utilizzando tifffile - tifffile.imwrite(save_path, image_numpy(np.uint16)) + tifffile.imwrite(save_path, image_numpy.astype(np.uint16)) if opt.use_wandb: wandb.save(save_path) From 7f3c98713c19542df674568648554a5d202c7b74 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 29 Apr 2024 14:16:00 +0200 Subject: [PATCH 012/133] Update mydataset_dataset.py Debug code added --- data/mydataset_dataset.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/data/mydataset_dataset.py b/data/mydataset_dataset.py index e8ccb761c43..01e49501e0d 100644 --- a/data/mydataset_dataset.py +++ b/data/mydataset_dataset.py @@ -29,8 +29,14 @@ def __getitem__(self, index): """ A_path = self.A_paths[index] A_img = tiff.imread(A_path) # Load the TIFF image + print("Valori dell'immagine prima del dataloader:") + print(A_img) A_img = Image.fromarray(A_img.squeeze(), mode='L') # Convert the NumPy array to a PIL image + print("Valori dell'immagine dopo prime operazioni:") + print(A_img) A = self.transform(A_img) + print("Valori dell'immagine dopo transform:") + print(A_img) return {'A': A, 'A_paths': A_path} def __len__(self): From bfe1533006f9170c078acd81010d000ec04a3b40 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 29 Apr 2024 17:47:41 +0200 Subject: [PATCH 013/133] Create myaligned_dataset New file added --- data/myaligned_dataset | 45 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 data/myaligned_dataset diff --git a/data/myaligned_dataset b/data/myaligned_dataset new file mode 100644 index 00000000000..39af2dca401 --- /dev/null +++ b/data/myaligned_dataset @@ -0,0 +1,45 @@ +from data.base_dataset import BaseDataset, get_transform +from data.image_folder import make_dataset +import tifffile as tiff +from PIL import Image + + +class MyAlignedDataset(BaseDataset): + """Custom aligned dataset class for TIFF images.""" + + def __init__(self, opt): + """Initialize the dataset class. + + Parameters: + opt (Option class) -- stores all the experiment flags; needs to be a subclass of BaseOptions + """ + BaseDataset.__init__(self, opt) + self.dir_AB = opt.dataroot # Assuming data is organized in pairs in the same directory + self.AB_paths = sorted(make_dataset(self.dir_AB, opt.max_dataset_size)) + self.transform = get_transform(opt) + + def __getitem__(self, index): + """Return a data point and its metadata information. + + Parameters: + index (int) -- a random integer for data indexing + + Returns: + a dictionary containing A, B, A_paths, and B_paths + A (tensor) -- an image in the input domain + B (tensor) -- its corresponding image in the target domain + A_paths (str) -- path to the input image + B_paths (str) -- path to the target image + """ + AB_path = self.AB_paths[index] + AB = tiff.imread(AB_path) + w, h = AB.shape[-1] // 2, AB.shape[-2] + A = Image.fromarray(AB[:, :w]) + B = Image.fromarray(AB[:, w:]) + A = self.transform(A) + B = self.transform(B) + return {'A': A, 'B': B, 'A_paths': AB_path, 'B_paths': AB_path} + + def __len__(self): + """Return the total number of images in the dataset.""" + return len(self.AB_paths) From d1b417e6ab4da9ab07d85f56db578ca3cf56f5eb Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 29 Apr 2024 17:49:12 +0200 Subject: [PATCH 014/133] Rename myaligned_dataset to myaligned_dataset.py --- data/{myaligned_dataset => myaligned_dataset.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename data/{myaligned_dataset => myaligned_dataset.py} (100%) diff --git a/data/myaligned_dataset b/data/myaligned_dataset.py similarity index 100% rename from data/myaligned_dataset rename to data/myaligned_dataset.py From 4c49dee53ac820453a6ad6022df725184396cd8f Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 29 Apr 2024 18:09:38 +0200 Subject: [PATCH 015/133] Update myaligned_dataset.py Changes in file --- data/myaligned_dataset.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index 39af2dca401..68da0005990 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -16,7 +16,9 @@ def __init__(self, opt): BaseDataset.__init__(self, opt) self.dir_AB = opt.dataroot # Assuming data is organized in pairs in the same directory self.AB_paths = sorted(make_dataset(self.dir_AB, opt.max_dataset_size)) - self.transform = get_transform(opt) + self.input_nc = self.opt.output_nc if self.opt.direction == 'BtoA' else self.opt.input_nc + self.output_nc = self.opt.input_nc if self.opt.direction == 'BtoA' else self.opt.output_nc + self.transform = get_transform(opt, grayscale=(input_nc == 1)) def __getitem__(self, index): """Return a data point and its metadata information. @@ -33,11 +35,15 @@ def __getitem__(self, index): """ AB_path = self.AB_paths[index] AB = tiff.imread(AB_path) - w, h = AB.shape[-1] // 2, AB.shape[-2] + w, h = AB.size + w, h = AB.shape[-1] // 2, AB.shape[-2] A = Image.fromarray(AB[:, :w]) B = Image.fromarray(AB[:, w:]) + + # apply the same transform to both A and B A = self.transform(A) B = self.transform(B) + return {'A': A, 'B': B, 'A_paths': AB_path, 'B_paths': AB_path} def __len__(self): From cbc4db84eb639975d8de5918be5dbbb3b2b53b2f Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 29 Apr 2024 18:11:20 +0200 Subject: [PATCH 016/133] Update base_options.py Changes --- options/base_options.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/options/base_options.py b/options/base_options.py index 177f0128466..b7dc35f901b 100644 --- a/options/base_options.py +++ b/options/base_options.py @@ -38,7 +38,7 @@ def initialize(self, parser): parser.add_argument('--init_gain', type=float, default=0.02, help='scaling factor for normal, xavier and orthogonal.') parser.add_argument('--no_dropout', action='store_true', help='no dropout for the generator') # dataset parameters - parser.add_argument('--dataset_mode', type=str, default='mydataset', help='chooses how datasets are loaded. [unaligned | aligned | single | colorization | mydataset]') + parser.add_argument('--dataset_mode', type=str, default='myaligned', help='chooses how datasets are loaded. [unaligned | aligned | single | colorization | mydataset | myaligned]') parser.add_argument('--direction', type=str, default='AtoB', help='AtoB or BtoA') parser.add_argument('--serial_batches', action='store_true', help='if true, takes images in order to make batches, otherwise takes them randomly') parser.add_argument('--num_threads', default=4, type=int, help='# threads for loading data') From 9a219d09065ac89f43c214b8104ccb81cac4e090 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 29 Apr 2024 18:13:13 +0200 Subject: [PATCH 017/133] Update pix2pix_model.py Changes --- models/pix2pix_model.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/models/pix2pix_model.py b/models/pix2pix_model.py index 86a2b158264..4a2eee004ed 100644 --- a/models/pix2pix_model.py +++ b/models/pix2pix_model.py @@ -29,7 +29,8 @@ def modify_commandline_options(parser, is_train=True): By default, we use vanilla GAN loss, UNet with batchnorm, and aligned datasets. """ # changing the default values to match the pix2pix paper (https://phillipi.github.io/pix2pix/) - parser.set_defaults(norm='batch', netG='unet_256', dataset_mode='aligned') + #parser.set_defaults(norm='batch', netG='unet_256', dataset_mode='aligned') + parser.set_defaults(norm='batch', netG='unet_256', dataset_mode='myaligned') if is_train: parser.set_defaults(pool_size=0, gan_mode='vanilla') parser.add_argument('--lambda_L1', type=float, default=100.0, help='weight for L1 loss') From 0cb5690d56c595a72aed9ef1c25f12a1e92620d6 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 29 Apr 2024 18:31:12 +0200 Subject: [PATCH 018/133] Update myaligned_dataset.py Added debug prints --- data/myaligned_dataset.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index 68da0005990..d9b0c463403 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -16,8 +16,8 @@ def __init__(self, opt): BaseDataset.__init__(self, opt) self.dir_AB = opt.dataroot # Assuming data is organized in pairs in the same directory self.AB_paths = sorted(make_dataset(self.dir_AB, opt.max_dataset_size)) - self.input_nc = self.opt.output_nc if self.opt.direction == 'BtoA' else self.opt.input_nc - self.output_nc = self.opt.input_nc if self.opt.direction == 'BtoA' else self.opt.output_nc + input_nc = self.opt.output_nc if self.opt.direction == 'BtoA' else self.opt.input_nc + output_nc = self.opt.input_nc if self.opt.direction == 'BtoA' else self.opt.output_nc self.transform = get_transform(opt, grayscale=(input_nc == 1)) def __getitem__(self, index): @@ -39,7 +39,20 @@ def __getitem__(self, index): w, h = AB.shape[-1] // 2, AB.shape[-2] A = Image.fromarray(AB[:, :w]) B = Image.fromarray(AB[:, w:]) + + # Print information about the images + print("Image A:") + print("Shape:", A_array.shape) + print("Type:", A_array.dtype) + print("Min value:", A_array.min()) + print("Max value:", A_array.max()) + print("\nImage B:") + print("Shape:", B_array.shape) + print("Type:", B_array.dtype) + print("Min value:", B_array.min()) + print("Max value:", B_array.max()) + # apply the same transform to both A and B A = self.transform(A) B = self.transform(B) From 5118228b79e77b59cf052977d708d238b51265c6 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 29 Apr 2024 18:39:35 +0200 Subject: [PATCH 019/133] Update myaligned_dataset.py Issue solved --- data/myaligned_dataset.py | 1 - 1 file changed, 1 deletion(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index d9b0c463403..a878747839c 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -35,7 +35,6 @@ def __getitem__(self, index): """ AB_path = self.AB_paths[index] AB = tiff.imread(AB_path) - w, h = AB.size w, h = AB.shape[-1] // 2, AB.shape[-2] A = Image.fromarray(AB[:, :w]) B = Image.fromarray(AB[:, w:]) From 7bfc6621b8ff0e39c8feb68b6da15a5af97dd29e Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 29 Apr 2024 18:48:34 +0200 Subject: [PATCH 020/133] Update myaligned_dataset.py Error fixed --- data/myaligned_dataset.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index a878747839c..dfb0ab711e5 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -41,16 +41,15 @@ def __getitem__(self, index): # Print information about the images print("Image A:") - print("Shape:", A_array.shape) - print("Type:", A_array.dtype) - print("Min value:", A_array.min()) - print("Max value:", A_array.max()) - + print("Shape:", A.size) + print("Type:", A,mode) + #print("Min value:", np.min(AB)) + #print("Max value:", np.max(AB)) print("\nImage B:") - print("Shape:", B_array.shape) - print("Type:", B_array.dtype) - print("Min value:", B_array.min()) - print("Max value:", B_array.max()) + print("Shape:", B.size) + print("Type:", B.mode) + #print("Min value:", np.min(B)) + #print("Max value:", np.max(B)) # apply the same transform to both A and B A = self.transform(A) From 1bf9f22a8955a4abc304cd5a1368f2cad8b9d835 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 29 Apr 2024 18:49:08 +0200 Subject: [PATCH 021/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index dfb0ab711e5..705bf14fcad 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -42,7 +42,7 @@ def __getitem__(self, index): # Print information about the images print("Image A:") print("Shape:", A.size) - print("Type:", A,mode) + print("Type:", A.mode) #print("Min value:", np.min(AB)) #print("Max value:", np.max(AB)) print("\nImage B:") From 68394ebee53d30f7f4c6f02421382b4e778c20ed Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 29 Apr 2024 18:53:19 +0200 Subject: [PATCH 022/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index 705bf14fcad..f80d7a7715c 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -43,13 +43,13 @@ def __getitem__(self, index): print("Image A:") print("Shape:", A.size) print("Type:", A.mode) - #print("Min value:", np.min(AB)) - #print("Max value:", np.max(AB)) + print("Min value:", np.min(A)) + print("Max value:", np.max(A)) print("\nImage B:") print("Shape:", B.size) print("Type:", B.mode) - #print("Min value:", np.min(B)) - #print("Max value:", np.max(B)) + print("Min value:", np.min(B)) + print("Max value:", np.max(B)) # apply the same transform to both A and B A = self.transform(A) From 0359b58a05757dd0d4b65fc79d6c967537762960 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 29 Apr 2024 18:53:46 +0200 Subject: [PATCH 023/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 1 + 1 file changed, 1 insertion(+) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index f80d7a7715c..cc3013fc1e7 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -1,6 +1,7 @@ from data.base_dataset import BaseDataset, get_transform from data.image_folder import make_dataset import tifffile as tiff +import numpy as np from PIL import Image From c51ee70981ee5f463f31fac201e48249c5cd5d7c Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 29 Apr 2024 20:10:11 +0200 Subject: [PATCH 024/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index cc3013fc1e7..0ec11f094a5 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -40,13 +40,16 @@ def __getitem__(self, index): A = Image.fromarray(AB[:, :w]) B = Image.fromarray(AB[:, w:]) - # Print information about the images - print("Image A:") + # Convert tensor to numpy array and print all values + A_array = A.numpy() + print("All values of image A:", A_array) print("Shape:", A.size) print("Type:", A.mode) print("Min value:", np.min(A)) print("Max value:", np.max(A)) - print("\nImage B:") + # Convert tensor to numpy array and print all values + B_array = B.numpy() + print("\nAll values of image B:", B_array) print("Shape:", B.size) print("Type:", B.mode) print("Min value:", np.min(B)) From 3cdd11a4e1aadc85e54f463b7fd74f2c14f41fdc Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 29 Apr 2024 20:15:01 +0200 Subject: [PATCH 025/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 1 + 1 file changed, 1 insertion(+) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index 0ec11f094a5..c297a1ec0d5 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -2,6 +2,7 @@ from data.image_folder import make_dataset import tifffile as tiff import numpy as np +import torch from PIL import Image From eda641f871cda08ab112f9776821de0cd21698ac Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 29 Apr 2024 20:20:44 +0200 Subject: [PATCH 026/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index c297a1ec0d5..e5f4a287150 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -40,7 +40,8 @@ def __getitem__(self, index): w, h = AB.shape[-1] // 2, AB.shape[-2] A = Image.fromarray(AB[:, :w]) B = Image.fromarray(AB[:, w:]) - + + ''' # Convert tensor to numpy array and print all values A_array = A.numpy() print("All values of image A:", A_array) @@ -55,6 +56,21 @@ def __getitem__(self, index): print("Type:", B.mode) print("Min value:", np.min(B)) print("Max value:", np.max(B)) + ''' + # Convert image to NumPy array and print all values + A_array = np.array(A) + print("All values of image A:", A_array) + print("Shape:", A_array.shape) + print("Type:", A_array.dtype) + print("Min value:", np.min(A_array)) + print("Max value:", np.max(A_array)) + + B_array = np.array(B) + print("\nAll values of image B:", B_array) + print("Shape:", B_array.shape) + print("Type:", B_array.dtype) + print("Min value:", np.min(B_array)) + print("Max value:", np.max(B_array)) # apply the same transform to both A and B A = self.transform(A) From 9e2dcfc30d3302c9db6bd78a0ec53d0606efc396 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 29 Apr 2024 20:27:52 +0200 Subject: [PATCH 027/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index e5f4a287150..6638e0acfe8 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -44,7 +44,7 @@ def __getitem__(self, index): ''' # Convert tensor to numpy array and print all values A_array = A.numpy() - print("All values of image A:", A_array) + print("\nAll values of image A:\n", A_array) print("Shape:", A.size) print("Type:", A.mode) print("Min value:", np.min(A)) From 3883e79b7f74619de467c64565bff330278b2f2b Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 29 Apr 2024 20:32:50 +0200 Subject: [PATCH 028/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index 6638e0acfe8..c806efc05c0 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -59,14 +59,14 @@ def __getitem__(self, index): ''' # Convert image to NumPy array and print all values A_array = np.array(A) - print("All values of image A:", A_array) + print("\nAll values of image A:\n", A_array) print("Shape:", A_array.shape) print("Type:", A_array.dtype) print("Min value:", np.min(A_array)) print("Max value:", np.max(A_array)) B_array = np.array(B) - print("\nAll values of image B:", B_array) + print("\nAll values of image B:\n", B_array) print("Shape:", B_array.shape) print("Type:", B_array.dtype) print("Min value:", np.min(B_array)) From 1341e82e489068370b0c0e780f3f023301b702ae Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 29 Apr 2024 20:39:37 +0200 Subject: [PATCH 029/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index c806efc05c0..7ea36d3d79a 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -70,7 +70,7 @@ def __getitem__(self, index): print("Shape:", B_array.shape) print("Type:", B_array.dtype) print("Min value:", np.min(B_array)) - print("Max value:", np.max(B_array)) + print("Max value:", np.max(B_array)"\n") # apply the same transform to both A and B A = self.transform(A) From 64ca15ed9caaf9064e031f229da0e7aaebe4cb6d Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 29 Apr 2024 20:44:09 +0200 Subject: [PATCH 030/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index 7ea36d3d79a..fff0237c78b 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -70,7 +70,7 @@ def __getitem__(self, index): print("Shape:", B_array.shape) print("Type:", B_array.dtype) print("Min value:", np.min(B_array)) - print("Max value:", np.max(B_array)"\n") + print("Max value:", np.max(B_array),"\n") # apply the same transform to both A and B A = self.transform(A) From c1b5bb5f091c679e98bdc3ebb5373a774e358643 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Tue, 30 Apr 2024 12:20:55 +0200 Subject: [PATCH 031/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 40 ++++++++++++--------------------------- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index fff0237c78b..128ac64daee 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -41,36 +41,20 @@ def __getitem__(self, index): A = Image.fromarray(AB[:, :w]) B = Image.fromarray(AB[:, w:]) - ''' - # Convert tensor to numpy array and print all values - A_array = A.numpy() - print("\nAll values of image A:\n", A_array) - print("Shape:", A.size) - print("Type:", A.mode) - print("Min value:", np.min(A)) - print("Max value:", np.max(A)) - # Convert tensor to numpy array and print all values - B_array = B.numpy() - print("\nAll values of image B:", B_array) - print("Shape:", B.size) - print("Type:", B.mode) - print("Min value:", np.min(B)) - print("Max value:", np.max(B)) - ''' # Convert image to NumPy array and print all values - A_array = np.array(A) - print("\nAll values of image A:\n", A_array) - print("Shape:", A_array.shape) - print("Type:", A_array.dtype) - print("Min value:", np.min(A_array)) - print("Max value:", np.max(A_array)) + #A_array = np.array(A) + #print("\nAll values of image A:\n", A_array) + #print("Shape:", A_array.shape) + #print("Type:", A_array.dtype) + #print("Min value:", np.min(A_array)) + #print("Max value:", np.max(A_array)) - B_array = np.array(B) - print("\nAll values of image B:\n", B_array) - print("Shape:", B_array.shape) - print("Type:", B_array.dtype) - print("Min value:", np.min(B_array)) - print("Max value:", np.max(B_array),"\n") + #B_array = np.array(B) + #print("\nAll values of image B:\n", B_array) + #print("Shape:", B_array.shape) + #print("Type:", B_array.dtype) + #print("Min value:", np.min(B_array)) + #print("Max value:", np.max(B_array),"\n") # apply the same transform to both A and B A = self.transform(A) From df7194ae95af18b13bfc762570ea081464137f03 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Tue, 30 Apr 2024 13:08:00 +0200 Subject: [PATCH 032/133] Update aligned_dataset.py --- data/aligned_dataset.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/data/aligned_dataset.py b/data/aligned_dataset.py index 59a58108c22..25536a43eb9 100644 --- a/data/aligned_dataset.py +++ b/data/aligned_dataset.py @@ -1,4 +1,5 @@ import os +import numpy as np from data.base_dataset import BaseDataset, get_params, get_transform from data.image_folder import make_dataset from PIL import Image @@ -45,6 +46,20 @@ def __getitem__(self, index): A = AB.crop((0, 0, w2, h)) B = AB.crop((w2, 0, w, h)) + #Convert image to NumPy array and print all values + A_array = np.array(A) + print("\nAll values of image A:\n", A_array) + print("Shape:", A_array.shape) + print("Type:", A_array.dtype) + print("Min value:", np.min(A_array)) + print("Max value:", np.max(A_array)) + + B_array = np.array(B) + print("\nAll values of image B:\n", B_array) + print("Shape:", B_array.shape) + print("Type:", B_array.dtype) + print("Min value:", np.min(B_array)) + print("Max value:", np.max(B_array),"\n") # apply the same transform to both A and B transform_params = get_params(self.opt, A.size) A_transform = get_transform(self.opt, transform_params, grayscale=(self.input_nc == 1)) From 3f7564d44cc12de934eeea33cee89fcf4f4dd458 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Tue, 30 Apr 2024 13:10:38 +0200 Subject: [PATCH 033/133] Update pix2pix_model.py --- models/pix2pix_model.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/pix2pix_model.py b/models/pix2pix_model.py index 4a2eee004ed..7e9d1ffd6aa 100644 --- a/models/pix2pix_model.py +++ b/models/pix2pix_model.py @@ -30,7 +30,7 @@ def modify_commandline_options(parser, is_train=True): """ # changing the default values to match the pix2pix paper (https://phillipi.github.io/pix2pix/) #parser.set_defaults(norm='batch', netG='unet_256', dataset_mode='aligned') - parser.set_defaults(norm='batch', netG='unet_256', dataset_mode='myaligned') + parser.set_defaults(norm='batch', netG='unet_256', dataset_mode='aligned') if is_train: parser.set_defaults(pool_size=0, gan_mode='vanilla') parser.add_argument('--lambda_L1', type=float, default=100.0, help='weight for L1 loss') From cd9cd8b31b454831402acf5000df0d1a8d318a5b Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Tue, 30 Apr 2024 13:16:32 +0200 Subject: [PATCH 034/133] Update pix2pix_model.py --- models/pix2pix_model.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/pix2pix_model.py b/models/pix2pix_model.py index 7e9d1ffd6aa..4a2eee004ed 100644 --- a/models/pix2pix_model.py +++ b/models/pix2pix_model.py @@ -30,7 +30,7 @@ def modify_commandline_options(parser, is_train=True): """ # changing the default values to match the pix2pix paper (https://phillipi.github.io/pix2pix/) #parser.set_defaults(norm='batch', netG='unet_256', dataset_mode='aligned') - parser.set_defaults(norm='batch', netG='unet_256', dataset_mode='aligned') + parser.set_defaults(norm='batch', netG='unet_256', dataset_mode='myaligned') if is_train: parser.set_defaults(pool_size=0, gan_mode='vanilla') parser.add_argument('--lambda_L1', type=float, default=100.0, help='weight for L1 loss') From 1c928058fde96ceda2362a4aa7b8b8b39673bae5 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Tue, 30 Apr 2024 13:17:56 +0200 Subject: [PATCH 035/133] Update aligned_dataset.py --- data/aligned_dataset.py | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/data/aligned_dataset.py b/data/aligned_dataset.py index 25536a43eb9..5f7457a47d1 100644 --- a/data/aligned_dataset.py +++ b/data/aligned_dataset.py @@ -46,20 +46,6 @@ def __getitem__(self, index): A = AB.crop((0, 0, w2, h)) B = AB.crop((w2, 0, w, h)) - #Convert image to NumPy array and print all values - A_array = np.array(A) - print("\nAll values of image A:\n", A_array) - print("Shape:", A_array.shape) - print("Type:", A_array.dtype) - print("Min value:", np.min(A_array)) - print("Max value:", np.max(A_array)) - - B_array = np.array(B) - print("\nAll values of image B:\n", B_array) - print("Shape:", B_array.shape) - print("Type:", B_array.dtype) - print("Min value:", np.min(B_array)) - print("Max value:", np.max(B_array),"\n") # apply the same transform to both A and B transform_params = get_params(self.opt, A.size) A_transform = get_transform(self.opt, transform_params, grayscale=(self.input_nc == 1)) From 92e4c0174f63947b6cfa518e2d28b9ffe7aba830 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Tue, 30 Apr 2024 13:20:25 +0200 Subject: [PATCH 036/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index 128ac64daee..d804a2035ba 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -42,12 +42,12 @@ def __getitem__(self, index): B = Image.fromarray(AB[:, w:]) # Convert image to NumPy array and print all values - #A_array = np.array(A) - #print("\nAll values of image A:\n", A_array) - #print("Shape:", A_array.shape) - #print("Type:", A_array.dtype) - #print("Min value:", np.min(A_array)) - #print("Max value:", np.max(A_array)) + A_array = np.array(A) + print("\nAll values of image A:\n", A_array) + print("Shape:", A_array.shape) + print("Type:", A_array.dtype) + print("Min value:", np.min(A_array)) + print("Max value:", np.max(A_array)) #B_array = np.array(B) #print("\nAll values of image B:\n", B_array) @@ -59,7 +59,14 @@ def __getitem__(self, index): # apply the same transform to both A and B A = self.transform(A) B = self.transform(B) - + + A_array_after = np.array(A) + print("\nAll values of image A after transform:\n", A_array_after) + print("Shape:", A_array_after.shape) + print("Type:", A_array_after.dtype) + print("Min value:", np.min(A_array_after)) + print("Max value:", np.max(A_array_after)) + return {'A': A, 'B': B, 'A_paths': AB_path, 'B_paths': AB_path} def __len__(self): From 757699513e662643b8b5d5626b954ea92526cd9a Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Tue, 30 Apr 2024 13:22:29 +0200 Subject: [PATCH 037/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index d804a2035ba..89e6098a169 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -49,12 +49,12 @@ def __getitem__(self, index): print("Min value:", np.min(A_array)) print("Max value:", np.max(A_array)) - #B_array = np.array(B) - #print("\nAll values of image B:\n", B_array) - #print("Shape:", B_array.shape) - #print("Type:", B_array.dtype) - #print("Min value:", np.min(B_array)) - #print("Max value:", np.max(B_array),"\n") + B_array = np.array(B) + print("\nAll values of image B:\n", B_array) + print("Shape:", B_array.shape) + print("Type:", B_array.dtype) + print("Min value:", np.min(B_array)) + print("Max value:", np.max(B_array),"\n") # apply the same transform to both A and B A = self.transform(A) @@ -67,6 +67,14 @@ def __getitem__(self, index): print("Min value:", np.min(A_array_after)) print("Max value:", np.max(A_array_after)) + B_array_after = np.array(B) + print("\nAll values of image B:\n", B_array_after) + print("Shape:", B_array_after.shape) + print("Type:", B_array_after.dtype) + print("Min value:", np.min(B_array_after)) + print("Max value:", np.max(B_array_after),"\n") + + return {'A': A, 'B': B, 'A_paths': AB_path, 'B_paths': AB_path} def __len__(self): From ef35b49a41cde24d3d8c1db88b46ffed94f0b000 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Tue, 30 Apr 2024 13:28:47 +0200 Subject: [PATCH 038/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index 89e6098a169..f3274af8266 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -68,7 +68,7 @@ def __getitem__(self, index): print("Max value:", np.max(A_array_after)) B_array_after = np.array(B) - print("\nAll values of image B:\n", B_array_after) + print("\nAll values of image B after transform:\n", B_array_after) print("Shape:", B_array_after.shape) print("Type:", B_array_after.dtype) print("Min value:", np.min(B_array_after)) From ea29eef7c9c1b58c2c5f4557edad20fbd12c7a3b Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Tue, 30 Apr 2024 13:39:45 +0200 Subject: [PATCH 039/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index f3274af8266..5f2ad67905e 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -41,6 +41,9 @@ def __getitem__(self, index): A = Image.fromarray(AB[:, :w]) B = Image.fromarray(AB[:, w:]) + if np.array_equal(A, B): + print("Images A and B are equal.") + # Convert image to NumPy array and print all values A_array = np.array(A) print("\nAll values of image A:\n", A_array) From f12f69437af24823455764d3b23d9beaf9528a68 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Tue, 30 Apr 2024 13:40:50 +0200 Subject: [PATCH 040/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index 5f2ad67905e..3a25913fcc6 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -62,6 +62,10 @@ def __getitem__(self, index): # apply the same transform to both A and B A = self.transform(A) B = self.transform(B) + + if np.array_equal(A, B): + print("Images A and B are equal after trasnform.") + A_array_after = np.array(A) print("\nAll values of image A after transform:\n", A_array_after) From b11ea38b202d3b58e173602741de36f6e2e8b405 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Tue, 30 Apr 2024 13:49:10 +0200 Subject: [PATCH 041/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index 3a25913fcc6..6b194fc81f8 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -41,9 +41,10 @@ def __getitem__(self, index): A = Image.fromarray(AB[:, :w]) B = Image.fromarray(AB[:, w:]) + ''' if np.array_equal(A, B): print("Images A and B are equal.") - + # Convert image to NumPy array and print all values A_array = np.array(A) print("\nAll values of image A:\n", A_array) @@ -81,7 +82,7 @@ def __getitem__(self, index): print("Min value:", np.min(B_array_after)) print("Max value:", np.max(B_array_after),"\n") - + ''' return {'A': A, 'B': B, 'A_paths': AB_path, 'B_paths': AB_path} def __len__(self): From afd31f9a84111f1bf0e5788ee22f17be6a00986f Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Tue, 30 Apr 2024 16:22:40 +0200 Subject: [PATCH 042/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index 6b194fc81f8..c2f8f84952a 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -20,7 +20,10 @@ def __init__(self, opt): self.AB_paths = sorted(make_dataset(self.dir_AB, opt.max_dataset_size)) input_nc = self.opt.output_nc if self.opt.direction == 'BtoA' else self.opt.input_nc output_nc = self.opt.input_nc if self.opt.direction == 'BtoA' else self.opt.output_nc - self.transform = get_transform(opt, grayscale=(input_nc == 1)) + self.transform = transforms.Compose([ + transforms.ToTensor(), + ]) + #self.transform = get_transform(opt, grayscale=(input_nc == 1)) def __getitem__(self, index): """Return a data point and its metadata information. @@ -59,15 +62,14 @@ def __getitem__(self, index): print("Type:", B_array.dtype) print("Min value:", np.min(B_array)) print("Max value:", np.max(B_array),"\n") - + ''' # apply the same transform to both A and B A = self.transform(A) B = self.transform(B) - + ''' if np.array_equal(A, B): print("Images A and B are equal after trasnform.") - A_array_after = np.array(A) print("\nAll values of image A after transform:\n", A_array_after) print("Shape:", A_array_after.shape) From 7b427b3eb243e853756190e22942276db2b409e0 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Tue, 30 Apr 2024 16:29:39 +0200 Subject: [PATCH 043/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 1 + 1 file changed, 1 insertion(+) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index c2f8f84952a..3176c92c400 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -3,6 +3,7 @@ import tifffile as tiff import numpy as np import torch +from torchvision import transforms from PIL import Image From 97452ab495b934ac1a511262a7da03bdd404ceb2 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Tue, 30 Apr 2024 16:37:27 +0200 Subject: [PATCH 044/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index 3176c92c400..cd465dbc21e 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -21,10 +21,7 @@ def __init__(self, opt): self.AB_paths = sorted(make_dataset(self.dir_AB, opt.max_dataset_size)) input_nc = self.opt.output_nc if self.opt.direction == 'BtoA' else self.opt.input_nc output_nc = self.opt.input_nc if self.opt.direction == 'BtoA' else self.opt.output_nc - self.transform = transforms.Compose([ - transforms.ToTensor(), - ]) - #self.transform = get_transform(opt, grayscale=(input_nc == 1)) + self.transform = get_transform(opt, grayscale=(input_nc == 1)) def __getitem__(self, index): """Return a data point and its metadata information. @@ -44,7 +41,8 @@ def __getitem__(self, index): w, h = AB.shape[-1] // 2, AB.shape[-2] A = Image.fromarray(AB[:, :w]) B = Image.fromarray(AB[:, w:]) - + A_array = np.array(A) + B_array = np.array(B) ''' if np.array_equal(A, B): print("Images A and B are equal.") @@ -63,11 +61,11 @@ def __getitem__(self, index): print("Type:", B_array.dtype) print("Min value:", np.min(B_array)) print("Max value:", np.max(B_array),"\n") - ''' + # apply the same transform to both A and B A = self.transform(A) B = self.transform(B) - ''' + if np.array_equal(A, B): print("Images A and B are equal after trasnform.") @@ -86,7 +84,7 @@ def __getitem__(self, index): print("Max value:", np.max(B_array_after),"\n") ''' - return {'A': A, 'B': B, 'A_paths': AB_path, 'B_paths': AB_path} + return {'A': A_array, 'B': B_array, 'A_paths': AB_path, 'B_paths': AB_path} def __len__(self): """Return the total number of images in the dataset.""" From 910801702d5c632b08f2dd8594ab4e120c0055b8 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Tue, 30 Apr 2024 17:37:51 +0200 Subject: [PATCH 045/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index cd465dbc21e..ed815d3f6ea 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -41,8 +41,8 @@ def __getitem__(self, index): w, h = AB.shape[-1] // 2, AB.shape[-2] A = Image.fromarray(AB[:, :w]) B = Image.fromarray(AB[:, w:]) - A_array = np.array(A) - B_array = np.array(B) + A_array = np.array(A, dtype=np.int16) + B_array = np.array(B, dtype=np.int16) ''' if np.array_equal(A, B): print("Images A and B are equal.") From e4015cd41e6e7a3d0eee08e084c6b536d5e151d8 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Tue, 30 Apr 2024 17:45:12 +0200 Subject: [PATCH 046/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index ed815d3f6ea..5de8720052a 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -21,7 +21,10 @@ def __init__(self, opt): self.AB_paths = sorted(make_dataset(self.dir_AB, opt.max_dataset_size)) input_nc = self.opt.output_nc if self.opt.direction == 'BtoA' else self.opt.input_nc output_nc = self.opt.input_nc if self.opt.direction == 'BtoA' else self.opt.output_nc - self.transform = get_transform(opt, grayscale=(input_nc == 1)) + self.transform = transforms.Compose([ + transforms.ToTensor() + ]) + #self.transform = get_transform(opt, grayscale=(input_nc == 1)) def __getitem__(self, index): """Return a data point and its metadata information. @@ -41,9 +44,10 @@ def __getitem__(self, index): w, h = AB.shape[-1] // 2, AB.shape[-2] A = Image.fromarray(AB[:, :w]) B = Image.fromarray(AB[:, w:]) + ''' A_array = np.array(A, dtype=np.int16) B_array = np.array(B, dtype=np.int16) - ''' + if np.array_equal(A, B): print("Images A and B are equal.") @@ -61,11 +65,11 @@ def __getitem__(self, index): print("Type:", B_array.dtype) print("Min value:", np.min(B_array)) print("Max value:", np.max(B_array),"\n") - + ''' # apply the same transform to both A and B A = self.transform(A) B = self.transform(B) - + ''' if np.array_equal(A, B): print("Images A and B are equal after trasnform.") @@ -84,7 +88,7 @@ def __getitem__(self, index): print("Max value:", np.max(B_array_after),"\n") ''' - return {'A': A_array, 'B': B_array, 'A_paths': AB_path, 'B_paths': AB_path} + return {'A': A, 'B': B, 'A_paths': AB_path, 'B_paths': AB_path} def __len__(self): """Return the total number of images in the dataset.""" From 1a72cb015f0ab78044c29b731a85de5e28a60e01 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Wed, 1 May 2024 11:33:36 +0200 Subject: [PATCH 047/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index 5de8720052a..cebfa34a6ff 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -21,10 +21,10 @@ def __init__(self, opt): self.AB_paths = sorted(make_dataset(self.dir_AB, opt.max_dataset_size)) input_nc = self.opt.output_nc if self.opt.direction == 'BtoA' else self.opt.input_nc output_nc = self.opt.input_nc if self.opt.direction == 'BtoA' else self.opt.output_nc - self.transform = transforms.Compose([ - transforms.ToTensor() - ]) - #self.transform = get_transform(opt, grayscale=(input_nc == 1)) + #self.transform = transforms.Compose([ + #transforms.ToTensor() + #]) + self.transform = get_transform(opt, grayscale=(input_nc == 1)) def __getitem__(self, index): """Return a data point and its metadata information. From 575165615643ab17c8569a7685b2e2878a791b0f Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Thu, 2 May 2024 12:52:22 +0200 Subject: [PATCH 048/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index cebfa34a6ff..1c73f221e6a 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -44,9 +44,9 @@ def __getitem__(self, index): w, h = AB.shape[-1] // 2, AB.shape[-2] A = Image.fromarray(AB[:, :w]) B = Image.fromarray(AB[:, w:]) - ''' - A_array = np.array(A, dtype=np.int16) - B_array = np.array(B, dtype=np.int16) + + A_array = np.array(A) + B_array = np.array(B) if np.array_equal(A, B): print("Images A and B are equal.") @@ -65,11 +65,11 @@ def __getitem__(self, index): print("Type:", B_array.dtype) print("Min value:", np.min(B_array)) print("Max value:", np.max(B_array),"\n") - ''' + # apply the same transform to both A and B A = self.transform(A) B = self.transform(B) - ''' + if np.array_equal(A, B): print("Images A and B are equal after trasnform.") @@ -87,7 +87,7 @@ def __getitem__(self, index): print("Min value:", np.min(B_array_after)) print("Max value:", np.max(B_array_after),"\n") - ''' + return {'A': A, 'B': B, 'A_paths': AB_path, 'B_paths': AB_path} def __len__(self): From c79807e47a3baa11690cd753771e6caa0b05a19e Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Thu, 2 May 2024 13:13:04 +0200 Subject: [PATCH 049/133] Update test.py --- test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.py b/test.py index e197b0ac4fd..73fc9160f75 100644 --- a/test.py +++ b/test.py @@ -85,7 +85,7 @@ save_path = os.path.join(web_dir, f'{image_name}_{label}.tiff') image_numpy = image_numpy.cpu().numpy() # Salva l'immagine come tiff utilizzando tifffile - tifffile.imwrite(save_path, image_numpy.astype(np.uint16)) + tifffile.imwrite(save_path, image_numpy) #.astype(np.uint16)) if opt.use_wandb: wandb.save(save_path) From ed70cb175621d6cb8549e1928c5cdaf6d5a62ca7 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Thu, 2 May 2024 14:07:32 +0200 Subject: [PATCH 050/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index 1c73f221e6a..f182c37b61e 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -44,7 +44,8 @@ def __getitem__(self, index): w, h = AB.shape[-1] // 2, AB.shape[-2] A = Image.fromarray(AB[:, :w]) B = Image.fromarray(AB[:, w:]) - + + ''' A_array = np.array(A) B_array = np.array(B) @@ -65,11 +66,11 @@ def __getitem__(self, index): print("Type:", B_array.dtype) print("Min value:", np.min(B_array)) print("Max value:", np.max(B_array),"\n") - + ''' # apply the same transform to both A and B A = self.transform(A) B = self.transform(B) - + ''' if np.array_equal(A, B): print("Images A and B are equal after trasnform.") @@ -87,7 +88,7 @@ def __getitem__(self, index): print("Min value:", np.min(B_array_after)) print("Max value:", np.max(B_array_after),"\n") - + ''' return {'A': A, 'B': B, 'A_paths': AB_path, 'B_paths': AB_path} def __len__(self): From b20583e94639b1a4f21d7d7b375ccff125a06136 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Thu, 2 May 2024 20:30:44 +0200 Subject: [PATCH 051/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index f182c37b61e..e7ade81e819 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -45,7 +45,7 @@ def __getitem__(self, index): A = Image.fromarray(AB[:, :w]) B = Image.fromarray(AB[:, w:]) - ''' + A_array = np.array(A) B_array = np.array(B) @@ -66,11 +66,11 @@ def __getitem__(self, index): print("Type:", B_array.dtype) print("Min value:", np.min(B_array)) print("Max value:", np.max(B_array),"\n") - ''' + # apply the same transform to both A and B A = self.transform(A) B = self.transform(B) - ''' + if np.array_equal(A, B): print("Images A and B are equal after trasnform.") @@ -88,7 +88,7 @@ def __getitem__(self, index): print("Min value:", np.min(B_array_after)) print("Max value:", np.max(B_array_after),"\n") - ''' + return {'A': A, 'B': B, 'A_paths': AB_path, 'B_paths': AB_path} def __len__(self): From 632aa2a35981a7f8d155905cac5d864645028acf Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Thu, 2 May 2024 20:45:41 +0200 Subject: [PATCH 052/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index e7ade81e819..d32cb0208ae 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -21,10 +21,10 @@ def __init__(self, opt): self.AB_paths = sorted(make_dataset(self.dir_AB, opt.max_dataset_size)) input_nc = self.opt.output_nc if self.opt.direction == 'BtoA' else self.opt.input_nc output_nc = self.opt.input_nc if self.opt.direction == 'BtoA' else self.opt.output_nc - #self.transform = transforms.Compose([ - #transforms.ToTensor() - #]) - self.transform = get_transform(opt, grayscale=(input_nc == 1)) + self.transform = transforms.Compose([ + transforms.ToTensor() + ]) + #self.transform = get_transform(opt, grayscale=(input_nc == 1)) def __getitem__(self, index): """Return a data point and its metadata information. From ae0bb9bf4ca54e399ba3f58e4f668c153703cf0e Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Thu, 2 May 2024 20:50:01 +0200 Subject: [PATCH 053/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index d32cb0208ae..63e9b5a5afb 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -45,7 +45,7 @@ def __getitem__(self, index): A = Image.fromarray(AB[:, :w]) B = Image.fromarray(AB[:, w:]) - + ''' A_array = np.array(A) B_array = np.array(B) @@ -66,11 +66,11 @@ def __getitem__(self, index): print("Type:", B_array.dtype) print("Min value:", np.min(B_array)) print("Max value:", np.max(B_array),"\n") - + ''' # apply the same transform to both A and B A = self.transform(A) B = self.transform(B) - + ''' if np.array_equal(A, B): print("Images A and B are equal after trasnform.") @@ -88,7 +88,7 @@ def __getitem__(self, index): print("Min value:", np.min(B_array_after)) print("Max value:", np.max(B_array_after),"\n") - + ''' return {'A': A, 'B': B, 'A_paths': AB_path, 'B_paths': AB_path} def __len__(self): From 285a435a406ce2d2c8aabdaa2e79e34a74955fbf Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Thu, 2 May 2024 23:19:23 +0200 Subject: [PATCH 054/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 1 + 1 file changed, 1 insertion(+) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index 63e9b5a5afb..8d40dc7feab 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -22,6 +22,7 @@ def __init__(self, opt): input_nc = self.opt.output_nc if self.opt.direction == 'BtoA' else self.opt.input_nc output_nc = self.opt.input_nc if self.opt.direction == 'BtoA' else self.opt.output_nc self.transform = transforms.Compose([ + transforms.Grayscale(num_output_channels=1), transforms.ToTensor() ]) #self.transform = get_transform(opt, grayscale=(input_nc == 1)) From 23235400db5adc999f258d85e63da386a628a507 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Thu, 2 May 2024 23:26:47 +0200 Subject: [PATCH 055/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index 8d40dc7feab..31d547b33b5 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -22,7 +22,7 @@ def __init__(self, opt): input_nc = self.opt.output_nc if self.opt.direction == 'BtoA' else self.opt.input_nc output_nc = self.opt.input_nc if self.opt.direction == 'BtoA' else self.opt.output_nc self.transform = transforms.Compose([ - transforms.Grayscale(num_output_channels=1), + transforms.Grayscale(1), transforms.ToTensor() ]) #self.transform = get_transform(opt, grayscale=(input_nc == 1)) From 86a2c1d62408fa221a36a9270edf8138ee757f40 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Thu, 2 May 2024 23:35:01 +0200 Subject: [PATCH 056/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index 31d547b33b5..604d2e2e485 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -21,11 +21,11 @@ def __init__(self, opt): self.AB_paths = sorted(make_dataset(self.dir_AB, opt.max_dataset_size)) input_nc = self.opt.output_nc if self.opt.direction == 'BtoA' else self.opt.input_nc output_nc = self.opt.input_nc if self.opt.direction == 'BtoA' else self.opt.output_nc - self.transform = transforms.Compose([ - transforms.Grayscale(1), - transforms.ToTensor() - ]) - #self.transform = get_transform(opt, grayscale=(input_nc == 1)) + #self.transform = transforms.Compose([ + #transforms.Grayscale(1), + #transforms.ToTensor() + #]) + self.transform = get_transform(opt, grayscale=(input_nc == 1)) def __getitem__(self, index): """Return a data point and its metadata information. From 0043e10e97d078f322df269210eec605c677d3e4 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 6 May 2024 11:56:10 +0200 Subject: [PATCH 057/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index 604d2e2e485..63ccea7dace 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -46,7 +46,7 @@ def __getitem__(self, index): A = Image.fromarray(AB[:, :w]) B = Image.fromarray(AB[:, w:]) - ''' + A_array = np.array(A) B_array = np.array(B) @@ -67,11 +67,11 @@ def __getitem__(self, index): print("Type:", B_array.dtype) print("Min value:", np.min(B_array)) print("Max value:", np.max(B_array),"\n") - ''' + # apply the same transform to both A and B A = self.transform(A) B = self.transform(B) - ''' + if np.array_equal(A, B): print("Images A and B are equal after trasnform.") @@ -89,7 +89,7 @@ def __getitem__(self, index): print("Min value:", np.min(B_array_after)) print("Max value:", np.max(B_array_after),"\n") - ''' + return {'A': A, 'B': B, 'A_paths': AB_path, 'B_paths': AB_path} def __len__(self): From 5cecd204e3250247bbe02b331e8cc03ed7c14955 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 6 May 2024 12:37:23 +0200 Subject: [PATCH 058/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index 63ccea7dace..efc93ac3de7 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -53,16 +53,22 @@ def __getitem__(self, index): if np.array_equal(A, B): print("Images A and B are equal.") - # Convert image to NumPy array and print all values + # Convert image to NumPy array and print all values + print("Number of unique values in image A:", num_unique_values_A) A_array = np.array(A) + unique_values_A = np.unique(A_array) + num_unique_values_A = len(unique_values_A) print("\nAll values of image A:\n", A_array) print("Shape:", A_array.shape) print("Type:", A_array.dtype) print("Min value:", np.min(A_array)) print("Max value:", np.max(A_array)) - B_array = np.array(B) + B_array = np.array(B) print("\nAll values of image B:\n", B_array) + unique_values_B = np.unique(B_array) + num_unique_values_B = len(unique_values_B) + print("Number of unique values in image B:", num_unique_values_B) print("Shape:", B_array.shape) print("Type:", B_array.dtype) print("Min value:", np.min(B_array)) @@ -76,7 +82,10 @@ def __getitem__(self, index): print("Images A and B are equal after trasnform.") A_array_after = np.array(A) - print("\nAll values of image A after transform:\n", A_array_after) + print("\nAll values of image A after transform:\n", A_array_after) + unique_values_A_after = np.unique(A_array_after) + num_unique_values_A_after = len(unique_values_A_after) + print("Number of unique values in image A after transform:", num_unique_values_A_after) print("Shape:", A_array_after.shape) print("Type:", A_array_after.dtype) print("Min value:", np.min(A_array_after)) @@ -84,6 +93,9 @@ def __getitem__(self, index): B_array_after = np.array(B) print("\nAll values of image B after transform:\n", B_array_after) + unique_values_B_after = np.unique(B_array_after) + num_unique_values_B_after = len(unique_values_B_after) + print("Number of unique values in image B after trasnform:", num_unique_values_B_after) print("Shape:", B_array_after.shape) print("Type:", B_array_after.dtype) print("Min value:", np.min(B_array_after)) From 533fb2979ce7fc1cb92c8a0f9ba87392d90fbeb1 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 6 May 2024 12:46:52 +0200 Subject: [PATCH 059/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index efc93ac3de7..2fba8569951 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -54,11 +54,11 @@ def __getitem__(self, index): print("Images A and B are equal.") # Convert image to NumPy array and print all values - print("Number of unique values in image A:", num_unique_values_A) A_array = np.array(A) + print("\nAll values of image A:\n", A_array) unique_values_A = np.unique(A_array) num_unique_values_A = len(unique_values_A) - print("\nAll values of image A:\n", A_array) + print("Number of unique values in image A:", num_unique_values_A) print("Shape:", A_array.shape) print("Type:", A_array.dtype) print("Min value:", np.min(A_array)) From d09f93a772ce370d90e6bf90655c5813585a7c17 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 6 May 2024 12:58:34 +0200 Subject: [PATCH 060/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index 2fba8569951..23e0ff2a72d 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -45,8 +45,7 @@ def __getitem__(self, index): w, h = AB.shape[-1] // 2, AB.shape[-2] A = Image.fromarray(AB[:, :w]) B = Image.fromarray(AB[:, w:]) - - + ''' A_array = np.array(A) B_array = np.array(B) @@ -73,11 +72,12 @@ def __getitem__(self, index): print("Type:", B_array.dtype) print("Min value:", np.min(B_array)) print("Max value:", np.max(B_array),"\n") - + ''' # apply the same transform to both A and B A = self.transform(A) B = self.transform(B) - + + ''' if np.array_equal(A, B): print("Images A and B are equal after trasnform.") @@ -100,7 +100,7 @@ def __getitem__(self, index): print("Type:", B_array_after.dtype) print("Min value:", np.min(B_array_after)) print("Max value:", np.max(B_array_after),"\n") - + ''' return {'A': A, 'B': B, 'A_paths': AB_path, 'B_paths': AB_path} From 78865c6b5ad68c57b484b87a72d3910586edeeba Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Tue, 7 May 2024 18:33:55 +0200 Subject: [PATCH 061/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index 23e0ff2a72d..bceb70f2700 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -25,7 +25,7 @@ def __init__(self, opt): #transforms.Grayscale(1), #transforms.ToTensor() #]) - self.transform = get_transform(opt, grayscale=(input_nc == 1)) + self.transform = get_transform(opt) #, grayscale=(input_nc == 1)) def __getitem__(self, index): """Return a data point and its metadata information. From 5b58ad5fb35bec2f87b68a7819befa95f9481bad Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Tue, 7 May 2024 18:36:15 +0200 Subject: [PATCH 062/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index bceb70f2700..23e0ff2a72d 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -25,7 +25,7 @@ def __init__(self, opt): #transforms.Grayscale(1), #transforms.ToTensor() #]) - self.transform = get_transform(opt) #, grayscale=(input_nc == 1)) + self.transform = get_transform(opt, grayscale=(input_nc == 1)) def __getitem__(self, index): """Return a data point and its metadata information. From f83c364eea91b420dde92fd672651c8e7fda0f1a Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Tue, 7 May 2024 19:14:35 +0200 Subject: [PATCH 063/133] Update base_options.py --- options/base_options.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/options/base_options.py b/options/base_options.py index b7dc35f901b..93645629824 100644 --- a/options/base_options.py +++ b/options/base_options.py @@ -26,8 +26,8 @@ def initialize(self, parser): parser.add_argument('--checkpoints_dir', type=str, default='./checkpoints', help='models are saved here') # model parameters parser.add_argument('--model', type=str, default='cycle_gan', help='chooses which model to use. [cycle_gan | pix2pix | test | colorization]') - parser.add_argument('--input_nc', type=int, default=1, help='# of input image channels: 3 for RGB and 1 for grayscale') - parser.add_argument('--output_nc', type=int, default=1, help='# of output image channels: 3 for RGB and 1 for grayscale') + parser.add_argument('--input_nc', type=int, default=3, help='# of input image channels: 3 for RGB and 1 for grayscale') + parser.add_argument('--output_nc', type=int, default=3, help='# of output image channels: 3 for RGB and 1 for grayscale') parser.add_argument('--ngf', type=int, default=64, help='# of gen filters in the last conv layer') parser.add_argument('--ndf', type=int, default=64, help='# of discrim filters in the first conv layer') parser.add_argument('--netD', type=str, default='basic', help='specify discriminator architecture [basic | n_layers | pixel]. The basic model is a 70x70 PatchGAN. n_layers allows you to specify the layers in the discriminator') From bef711226a7c833c8419dc091f94c22bbcf150fb Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Tue, 7 May 2024 19:17:27 +0200 Subject: [PATCH 064/133] Update base_options.py --- options/base_options.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/options/base_options.py b/options/base_options.py index 93645629824..b7dc35f901b 100644 --- a/options/base_options.py +++ b/options/base_options.py @@ -26,8 +26,8 @@ def initialize(self, parser): parser.add_argument('--checkpoints_dir', type=str, default='./checkpoints', help='models are saved here') # model parameters parser.add_argument('--model', type=str, default='cycle_gan', help='chooses which model to use. [cycle_gan | pix2pix | test | colorization]') - parser.add_argument('--input_nc', type=int, default=3, help='# of input image channels: 3 for RGB and 1 for grayscale') - parser.add_argument('--output_nc', type=int, default=3, help='# of output image channels: 3 for RGB and 1 for grayscale') + parser.add_argument('--input_nc', type=int, default=1, help='# of input image channels: 3 for RGB and 1 for grayscale') + parser.add_argument('--output_nc', type=int, default=1, help='# of output image channels: 3 for RGB and 1 for grayscale') parser.add_argument('--ngf', type=int, default=64, help='# of gen filters in the last conv layer') parser.add_argument('--ndf', type=int, default=64, help='# of discrim filters in the first conv layer') parser.add_argument('--netD', type=str, default='basic', help='specify discriminator architecture [basic | n_layers | pixel]. The basic model is a 70x70 PatchGAN. n_layers allows you to specify the layers in the discriminator') From e83c50c3cb52521ca2666674761184f746b61009 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Tue, 7 May 2024 19:50:58 +0200 Subject: [PATCH 065/133] Update base_options.py --- options/base_options.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/options/base_options.py b/options/base_options.py index b7dc35f901b..e71cdf819af 100644 --- a/options/base_options.py +++ b/options/base_options.py @@ -27,7 +27,7 @@ def initialize(self, parser): # model parameters parser.add_argument('--model', type=str, default='cycle_gan', help='chooses which model to use. [cycle_gan | pix2pix | test | colorization]') parser.add_argument('--input_nc', type=int, default=1, help='# of input image channels: 3 for RGB and 1 for grayscale') - parser.add_argument('--output_nc', type=int, default=1, help='# of output image channels: 3 for RGB and 1 for grayscale') + parser.add_argument('--output_nc', type=int, default=3, help='# of output image channels: 3 for RGB and 1 for grayscale') parser.add_argument('--ngf', type=int, default=64, help='# of gen filters in the last conv layer') parser.add_argument('--ndf', type=int, default=64, help='# of discrim filters in the first conv layer') parser.add_argument('--netD', type=str, default='basic', help='specify discriminator architecture [basic | n_layers | pixel]. The basic model is a 70x70 PatchGAN. n_layers allows you to specify the layers in the discriminator') From 45f0626d8556eed3653fb96194e1f2da648ac36b Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Tue, 7 May 2024 19:53:53 +0200 Subject: [PATCH 066/133] Update base_options.py --- options/base_options.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/options/base_options.py b/options/base_options.py index e71cdf819af..b7dc35f901b 100644 --- a/options/base_options.py +++ b/options/base_options.py @@ -27,7 +27,7 @@ def initialize(self, parser): # model parameters parser.add_argument('--model', type=str, default='cycle_gan', help='chooses which model to use. [cycle_gan | pix2pix | test | colorization]') parser.add_argument('--input_nc', type=int, default=1, help='# of input image channels: 3 for RGB and 1 for grayscale') - parser.add_argument('--output_nc', type=int, default=3, help='# of output image channels: 3 for RGB and 1 for grayscale') + parser.add_argument('--output_nc', type=int, default=1, help='# of output image channels: 3 for RGB and 1 for grayscale') parser.add_argument('--ngf', type=int, default=64, help='# of gen filters in the last conv layer') parser.add_argument('--ndf', type=int, default=64, help='# of discrim filters in the first conv layer') parser.add_argument('--netD', type=str, default='basic', help='specify discriminator architecture [basic | n_layers | pixel]. The basic model is a 70x70 PatchGAN. n_layers allows you to specify the layers in the discriminator') From 85379829ab539e14fd65c4d9b5412dcfb095d57e Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Tue, 7 May 2024 20:08:59 +0200 Subject: [PATCH 067/133] Update base_dataset.py --- data/base_dataset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index b8eb78ed51a..5c121a24032 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -81,7 +81,7 @@ def get_params(opt, size): def get_transform(opt, params=None, grayscale=False, method=transforms.InterpolationMode.BICUBIC, convert=True): transform_list = [] if grayscale: - transform_list.append(transforms.Grayscale(1)) + #transform_list.append(transforms.Grayscale(1)) if 'resize' in opt.preprocess: osize = [opt.load_size, opt.load_size] transform_list.append(transforms.Resize(osize, method)) From 03fb2b8d142111faca46fb75a875467ab9bfa5c6 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Tue, 7 May 2024 20:11:08 +0200 Subject: [PATCH 068/133] Update base_dataset.py --- data/base_dataset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index 5c121a24032..8c97b2caf0d 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -80,7 +80,7 @@ def get_params(opt, size): def get_transform(opt, params=None, grayscale=False, method=transforms.InterpolationMode.BICUBIC, convert=True): transform_list = [] - if grayscale: + #if grayscale: #transform_list.append(transforms.Grayscale(1)) if 'resize' in opt.preprocess: osize = [opt.load_size, opt.load_size] From 0a0e7676b35a51447eaa35ca96114d2a068997d7 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Tue, 7 May 2024 20:16:37 +0200 Subject: [PATCH 069/133] Update base_dataset.py --- data/base_dataset.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index 8c97b2caf0d..02e3ffb8ae4 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -80,8 +80,8 @@ def get_params(opt, size): def get_transform(opt, params=None, grayscale=False, method=transforms.InterpolationMode.BICUBIC, convert=True): transform_list = [] - #if grayscale: - #transform_list.append(transforms.Grayscale(1)) + if grayscale: + transform_list.append(transforms.Grayscale(3)) if 'resize' in opt.preprocess: osize = [opt.load_size, opt.load_size] transform_list.append(transforms.Resize(osize, method)) From 7714ef2be8a90df842bc6cad27f4e85d5fda28d4 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Tue, 7 May 2024 20:25:13 +0200 Subject: [PATCH 070/133] Update base_dataset.py --- data/base_dataset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index 02e3ffb8ae4..b8eb78ed51a 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -81,7 +81,7 @@ def get_params(opt, size): def get_transform(opt, params=None, grayscale=False, method=transforms.InterpolationMode.BICUBIC, convert=True): transform_list = [] if grayscale: - transform_list.append(transforms.Grayscale(3)) + transform_list.append(transforms.Grayscale(1)) if 'resize' in opt.preprocess: osize = [opt.load_size, opt.load_size] transform_list.append(transforms.Resize(osize, method)) From c6fe79746ccfd89b5de9589e3a2f6983dc514391 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Tue, 7 May 2024 20:53:08 +0200 Subject: [PATCH 071/133] Update base_dataset.py --- data/base_dataset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index b8eb78ed51a..02e3ffb8ae4 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -81,7 +81,7 @@ def get_params(opt, size): def get_transform(opt, params=None, grayscale=False, method=transforms.InterpolationMode.BICUBIC, convert=True): transform_list = [] if grayscale: - transform_list.append(transforms.Grayscale(1)) + transform_list.append(transforms.Grayscale(3)) if 'resize' in opt.preprocess: osize = [opt.load_size, opt.load_size] transform_list.append(transforms.Resize(osize, method)) From 28e3adb9015fb5ec4e0684855423a4a1a037b352 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Tue, 7 May 2024 20:53:42 +0200 Subject: [PATCH 072/133] Update base_options.py --- options/base_options.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/options/base_options.py b/options/base_options.py index b7dc35f901b..93645629824 100644 --- a/options/base_options.py +++ b/options/base_options.py @@ -26,8 +26,8 @@ def initialize(self, parser): parser.add_argument('--checkpoints_dir', type=str, default='./checkpoints', help='models are saved here') # model parameters parser.add_argument('--model', type=str, default='cycle_gan', help='chooses which model to use. [cycle_gan | pix2pix | test | colorization]') - parser.add_argument('--input_nc', type=int, default=1, help='# of input image channels: 3 for RGB and 1 for grayscale') - parser.add_argument('--output_nc', type=int, default=1, help='# of output image channels: 3 for RGB and 1 for grayscale') + parser.add_argument('--input_nc', type=int, default=3, help='# of input image channels: 3 for RGB and 1 for grayscale') + parser.add_argument('--output_nc', type=int, default=3, help='# of output image channels: 3 for RGB and 1 for grayscale') parser.add_argument('--ngf', type=int, default=64, help='# of gen filters in the last conv layer') parser.add_argument('--ndf', type=int, default=64, help='# of discrim filters in the first conv layer') parser.add_argument('--netD', type=str, default='basic', help='specify discriminator architecture [basic | n_layers | pixel]. The basic model is a 70x70 PatchGAN. n_layers allows you to specify the layers in the discriminator') From 1fd07a9168f8620354e2f25d5ca4ef80d7927e6f Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Wed, 8 May 2024 00:01:00 +0200 Subject: [PATCH 073/133] Update base_dataset.py --- data/base_dataset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index 02e3ffb8ae4..b8eb78ed51a 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -81,7 +81,7 @@ def get_params(opt, size): def get_transform(opt, params=None, grayscale=False, method=transforms.InterpolationMode.BICUBIC, convert=True): transform_list = [] if grayscale: - transform_list.append(transforms.Grayscale(3)) + transform_list.append(transforms.Grayscale(1)) if 'resize' in opt.preprocess: osize = [opt.load_size, opt.load_size] transform_list.append(transforms.Resize(osize, method)) From 02b46a6bf6158f976c8337e5c3f8b015e5e56cb4 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Wed, 8 May 2024 00:01:32 +0200 Subject: [PATCH 074/133] Update base_options.py --- options/base_options.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/options/base_options.py b/options/base_options.py index 93645629824..b7dc35f901b 100644 --- a/options/base_options.py +++ b/options/base_options.py @@ -26,8 +26,8 @@ def initialize(self, parser): parser.add_argument('--checkpoints_dir', type=str, default='./checkpoints', help='models are saved here') # model parameters parser.add_argument('--model', type=str, default='cycle_gan', help='chooses which model to use. [cycle_gan | pix2pix | test | colorization]') - parser.add_argument('--input_nc', type=int, default=3, help='# of input image channels: 3 for RGB and 1 for grayscale') - parser.add_argument('--output_nc', type=int, default=3, help='# of output image channels: 3 for RGB and 1 for grayscale') + parser.add_argument('--input_nc', type=int, default=1, help='# of input image channels: 3 for RGB and 1 for grayscale') + parser.add_argument('--output_nc', type=int, default=1, help='# of output image channels: 3 for RGB and 1 for grayscale') parser.add_argument('--ngf', type=int, default=64, help='# of gen filters in the last conv layer') parser.add_argument('--ndf', type=int, default=64, help='# of discrim filters in the first conv layer') parser.add_argument('--netD', type=str, default='basic', help='specify discriminator architecture [basic | n_layers | pixel]. The basic model is a 70x70 PatchGAN. n_layers allows you to specify the layers in the discriminator') From e5b95554ebd79d5e8bcb01477f58ccbeaa423e24 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Wed, 8 May 2024 14:24:00 +0200 Subject: [PATCH 075/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index 23e0ff2a72d..ca226bcdb12 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -45,7 +45,7 @@ def __getitem__(self, index): w, h = AB.shape[-1] // 2, AB.shape[-2] A = Image.fromarray(AB[:, :w]) B = Image.fromarray(AB[:, w:]) - ''' + A_array = np.array(A) B_array = np.array(B) @@ -72,12 +72,12 @@ def __getitem__(self, index): print("Type:", B_array.dtype) print("Min value:", np.min(B_array)) print("Max value:", np.max(B_array),"\n") - ''' + # apply the same transform to both A and B A = self.transform(A) B = self.transform(B) - ''' + if np.array_equal(A, B): print("Images A and B are equal after trasnform.") @@ -100,7 +100,7 @@ def __getitem__(self, index): print("Type:", B_array_after.dtype) print("Min value:", np.min(B_array_after)) print("Max value:", np.max(B_array_after),"\n") - ''' + return {'A': A, 'B': B, 'A_paths': AB_path, 'B_paths': AB_path} From 42f45f81a1e12e1c0278acfcdcbbea89e7f850c1 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Wed, 8 May 2024 16:23:27 +0200 Subject: [PATCH 076/133] Update base_dataset.py --- data/base_dataset.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index b8eb78ed51a..13972cb505a 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -105,10 +105,10 @@ def get_transform(opt, params=None, grayscale=False, method=transforms.Interpola if convert: transform_list += [transforms.ToTensor()] - if grayscale: - transform_list += [transforms.Normalize((0.5,), (0.5,))] - else: - transform_list += [transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))] + #if grayscale: + #transform_list += [transforms.Normalize((0.5,), (0.5,))] + #else: + #transform_list += [transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))] return transforms.Compose(transform_list) From 515ae53272fd30c767398cbe6228588dedc9550f Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Wed, 8 May 2024 16:33:00 +0200 Subject: [PATCH 077/133] Update base_dataset.py --- data/base_dataset.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index 13972cb505a..1c8a5d8b00f 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -94,8 +94,8 @@ def get_transform(opt, params=None, grayscale=False, method=transforms.Interpola else: transform_list.append(transforms.Lambda(lambda img: __crop(img, params['crop_pos'], opt.crop_size))) - if opt.preprocess == 'none': - transform_list.append(transforms.Lambda(lambda img: __make_power_2(img, base=4, method=method))) + #if opt.preprocess == 'none': + #transform_list.append(transforms.Lambda(lambda img: __make_power_2(img, base=4, method=method))) if not opt.no_flip: if params is None: From 1caf1521d5dfd99b944409e9c556b8d8208c2040 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Wed, 8 May 2024 16:48:37 +0200 Subject: [PATCH 078/133] Update base_dataset.py --- data/base_dataset.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index 1c8a5d8b00f..47abd5cfbae 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -88,20 +88,20 @@ def get_transform(opt, params=None, grayscale=False, method=transforms.Interpola elif 'scale_width' in opt.preprocess: transform_list.append(transforms.Lambda(lambda img: __scale_width(img, opt.load_size, opt.crop_size, method))) - if 'crop' in opt.preprocess: - if params is None: - transform_list.append(transforms.RandomCrop(opt.crop_size)) - else: - transform_list.append(transforms.Lambda(lambda img: __crop(img, params['crop_pos'], opt.crop_size))) + #if 'crop' in opt.preprocess: + #if params is None: + #transform_list.append(transforms.RandomCrop(opt.crop_size)) + #else: + #transform_list.append(transforms.Lambda(lambda img: __crop(img, params['crop_pos'], opt.crop_size))) #if opt.preprocess == 'none': #transform_list.append(transforms.Lambda(lambda img: __make_power_2(img, base=4, method=method))) - if not opt.no_flip: - if params is None: - transform_list.append(transforms.RandomHorizontalFlip()) - elif params['flip']: - transform_list.append(transforms.Lambda(lambda img: __flip(img, params['flip']))) + #if not opt.no_flip: + #if params is None: + #transform_list.append(transforms.RandomHorizontalFlip()) + #elif params['flip']: + #transform_list.append(transforms.Lambda(lambda img: __flip(img, params['flip']))) if convert: transform_list += [transforms.ToTensor()] From 17a87a78d4ff1c7b5138d1799cc08e7f7bd229e5 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Wed, 8 May 2024 17:05:08 +0200 Subject: [PATCH 079/133] Update base_dataset.py --- data/base_dataset.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index 47abd5cfbae..4c87e1b3edd 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -82,11 +82,11 @@ def get_transform(opt, params=None, grayscale=False, method=transforms.Interpola transform_list = [] if grayscale: transform_list.append(transforms.Grayscale(1)) - if 'resize' in opt.preprocess: - osize = [opt.load_size, opt.load_size] - transform_list.append(transforms.Resize(osize, method)) - elif 'scale_width' in opt.preprocess: - transform_list.append(transforms.Lambda(lambda img: __scale_width(img, opt.load_size, opt.crop_size, method))) + #if 'resize' in opt.preprocess: + #osize = [opt.load_size, opt.load_size] + #transform_list.append(transforms.Resize(osize, method)) + #elif 'scale_width' in opt.preprocess: + #transform_list.append(transforms.Lambda(lambda img: __scale_width(img, opt.load_size, opt.crop_size, method))) #if 'crop' in opt.preprocess: #if params is None: From 65e6e5cc68121048db6e8f45cee9ce01b2517731 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Wed, 8 May 2024 17:52:25 +0200 Subject: [PATCH 080/133] Update base_dataset.py --- data/base_dataset.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index 4c87e1b3edd..d096ab3fb90 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -103,8 +103,8 @@ def get_transform(opt, params=None, grayscale=False, method=transforms.Interpola #elif params['flip']: #transform_list.append(transforms.Lambda(lambda img: __flip(img, params['flip']))) - if convert: - transform_list += [transforms.ToTensor()] + #if convert: + #transform_list += [transforms.ToTensor()] #if grayscale: #transform_list += [transforms.Normalize((0.5,), (0.5,))] #else: From c5f369e49ee477eccedb691e0173e0325d289646 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Wed, 8 May 2024 18:04:00 +0200 Subject: [PATCH 081/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index ca226bcdb12..e5e40029710 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -48,7 +48,7 @@ def __getitem__(self, index): A_array = np.array(A) B_array = np.array(B) - + ''' if np.array_equal(A, B): print("Images A and B are equal.") @@ -72,7 +72,7 @@ def __getitem__(self, index): print("Type:", B_array.dtype) print("Min value:", np.min(B_array)) print("Max value:", np.max(B_array),"\n") - + ''' # apply the same transform to both A and B A = self.transform(A) B = self.transform(B) From e373d3f80ede675bfeb7a9902f819a45e453abcb Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Wed, 8 May 2024 18:08:00 +0200 Subject: [PATCH 082/133] Update base_dataset.py --- data/base_dataset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index d096ab3fb90..48832dc9795 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -78,7 +78,7 @@ def get_params(opt, size): return {'crop_pos': (x, y), 'flip': flip} -def get_transform(opt, params=None, grayscale=False, method=transforms.InterpolationMode.BICUBIC, convert=True): +def get_transform(opt, params=None, grayscale=False, method=transforms.InterpolationMode.BILINEAR, convert=True): #method=transforms.InterpolationMode.BICUBIC, convert=True): transform_list = [] if grayscale: transform_list.append(transforms.Grayscale(1)) From a3006f26127d3f19d8f9f22ec53c4f331a24c0d9 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Wed, 8 May 2024 18:12:00 +0200 Subject: [PATCH 083/133] Update base_dataset.py --- data/base_dataset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index 48832dc9795..fc2875fee08 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -78,7 +78,7 @@ def get_params(opt, size): return {'crop_pos': (x, y), 'flip': flip} -def get_transform(opt, params=None, grayscale=False, method=transforms.InterpolationMode.BILINEAR, convert=True): #method=transforms.InterpolationMode.BICUBIC, convert=True): +def get_transform(opt, params=None, grayscale=False) #method=transforms.InterpolationMode.BILINEAR, convert=True): #method=transforms.InterpolationMode.BICUBIC, convert=True): transform_list = [] if grayscale: transform_list.append(transforms.Grayscale(1)) From 75c1a2f4f3d06904b8a3fb672eb8023099ad3f08 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Wed, 8 May 2024 18:13:17 +0200 Subject: [PATCH 084/133] Update base_dataset.py --- data/base_dataset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index fc2875fee08..5043e113434 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -78,7 +78,7 @@ def get_params(opt, size): return {'crop_pos': (x, y), 'flip': flip} -def get_transform(opt, params=None, grayscale=False) #method=transforms.InterpolationMode.BILINEAR, convert=True): #method=transforms.InterpolationMode.BICUBIC, convert=True): +def get_transform(opt, params=None, grayscale=False): #method=transforms.InterpolationMode.BILINEAR, convert=True): #method=transforms.InterpolationMode.BICUBIC, convert=True): transform_list = [] if grayscale: transform_list.append(transforms.Grayscale(1)) From 1e3da6c141c0da18a39521cedc21b4601933cfef Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Wed, 8 May 2024 18:49:14 +0200 Subject: [PATCH 085/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index e5e40029710..95838b886ad 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -48,7 +48,7 @@ def __getitem__(self, index): A_array = np.array(A) B_array = np.array(B) - ''' + if np.array_equal(A, B): print("Images A and B are equal.") @@ -72,7 +72,7 @@ def __getitem__(self, index): print("Type:", B_array.dtype) print("Min value:", np.min(B_array)) print("Max value:", np.max(B_array),"\n") - ''' + # apply the same transform to both A and B A = self.transform(A) B = self.transform(B) @@ -80,7 +80,7 @@ def __getitem__(self, index): if np.array_equal(A, B): print("Images A and B are equal after trasnform.") - + ''' A_array_after = np.array(A) print("\nAll values of image A after transform:\n", A_array_after) unique_values_A_after = np.unique(A_array_after) @@ -100,7 +100,7 @@ def __getitem__(self, index): print("Type:", B_array_after.dtype) print("Min value:", np.min(B_array_after)) print("Max value:", np.max(B_array_after),"\n") - + ''' return {'A': A, 'B': B, 'A_paths': AB_path, 'B_paths': AB_path} From 4e323200ac2b8412fa013a7a331b97881bfe535a Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Wed, 8 May 2024 18:53:19 +0200 Subject: [PATCH 086/133] Update base_dataset.py --- data/base_dataset.py | 50 ++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index 5043e113434..495b18b739b 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -80,31 +80,31 @@ def get_params(opt, size): def get_transform(opt, params=None, grayscale=False): #method=transforms.InterpolationMode.BILINEAR, convert=True): #method=transforms.InterpolationMode.BICUBIC, convert=True): transform_list = [] - if grayscale: - transform_list.append(transforms.Grayscale(1)) - #if 'resize' in opt.preprocess: - #osize = [opt.load_size, opt.load_size] - #transform_list.append(transforms.Resize(osize, method)) - #elif 'scale_width' in opt.preprocess: - #transform_list.append(transforms.Lambda(lambda img: __scale_width(img, opt.load_size, opt.crop_size, method))) - - #if 'crop' in opt.preprocess: - #if params is None: - #transform_list.append(transforms.RandomCrop(opt.crop_size)) - #else: - #transform_list.append(transforms.Lambda(lambda img: __crop(img, params['crop_pos'], opt.crop_size))) - - #if opt.preprocess == 'none': - #transform_list.append(transforms.Lambda(lambda img: __make_power_2(img, base=4, method=method))) - - #if not opt.no_flip: - #if params is None: - #transform_list.append(transforms.RandomHorizontalFlip()) - #elif params['flip']: - #transform_list.append(transforms.Lambda(lambda img: __flip(img, params['flip']))) - - #if convert: - #transform_list += [transforms.ToTensor()] + #if grayscale: + #transform_list.append(transforms.Grayscale(1)) + if 'resize' in opt.preprocess: + osize = [opt.load_size, opt.load_size] + transform_list.append(transforms.Resize(osize, method)) + elif 'scale_width' in opt.preprocess: + transform_list.append(transforms.Lambda(lambda img: __scale_width(img, opt.load_size, opt.crop_size, method))) + + if 'crop' in opt.preprocess: + if params is None: + transform_list.append(transforms.RandomCrop(opt.crop_size)) + else: + transform_list.append(transforms.Lambda(lambda img: __crop(img, params['crop_pos'], opt.crop_size))) + + if opt.preprocess == 'none': + transform_list.append(transforms.Lambda(lambda img: __make_power_2(img, base=4, method=method))) + + if not opt.no_flip: + if params is None: + transform_list.append(transforms.RandomHorizontalFlip()) + elif params['flip']: + transform_list.append(transforms.Lambda(lambda img: __flip(img, params['flip']))) + + if convert: + transform_list += [transforms.ToTensor()] #if grayscale: #transform_list += [transforms.Normalize((0.5,), (0.5,))] #else: From 6ce2f83c6d575916a28a193432c7595df82d2972 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Wed, 8 May 2024 18:54:07 +0200 Subject: [PATCH 087/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index 95838b886ad..1260db117cf 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -48,7 +48,7 @@ def __getitem__(self, index): A_array = np.array(A) B_array = np.array(B) - + ''' if np.array_equal(A, B): print("Images A and B are equal.") @@ -100,7 +100,7 @@ def __getitem__(self, index): print("Type:", B_array_after.dtype) print("Min value:", np.min(B_array_after)) print("Max value:", np.max(B_array_after),"\n") - ''' + return {'A': A, 'B': B, 'A_paths': AB_path, 'B_paths': AB_path} From e2c884353025899bf148af50da10cbd04a442388 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Wed, 8 May 2024 18:55:33 +0200 Subject: [PATCH 088/133] Update base_dataset.py --- data/base_dataset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index 495b18b739b..3cd26953598 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -78,7 +78,7 @@ def get_params(opt, size): return {'crop_pos': (x, y), 'flip': flip} -def get_transform(opt, params=None, grayscale=False): #method=transforms.InterpolationMode.BILINEAR, convert=True): #method=transforms.InterpolationMode.BICUBIC, convert=True): +def get_transform(opt, params=None, grayscale=False, method=transforms.InterpolationMode.BICUBIC, convert=True): transform_list = [] #if grayscale: #transform_list.append(transforms.Grayscale(1)) From 9f6f717c6486c75cabe59087c6a9b7631f4676a6 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Wed, 8 May 2024 18:58:50 +0200 Subject: [PATCH 089/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index 1260db117cf..b2808e0b24c 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -80,7 +80,7 @@ def __getitem__(self, index): if np.array_equal(A, B): print("Images A and B are equal after trasnform.") - ''' + A_array_after = np.array(A) print("\nAll values of image A after transform:\n", A_array_after) unique_values_A_after = np.unique(A_array_after) @@ -100,7 +100,7 @@ def __getitem__(self, index): print("Type:", B_array_after.dtype) print("Min value:", np.min(B_array_after)) print("Max value:", np.max(B_array_after),"\n") - + ''' return {'A': A, 'B': B, 'A_paths': AB_path, 'B_paths': AB_path} From dd02d329accf2322bef2072e54e427332ffc2ebc Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Wed, 8 May 2024 19:09:10 +0200 Subject: [PATCH 090/133] Update base_dataset.py --- data/base_dataset.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index 3cd26953598..7de0f7e9963 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -80,7 +80,8 @@ def get_params(opt, size): def get_transform(opt, params=None, grayscale=False, method=transforms.InterpolationMode.BICUBIC, convert=True): transform_list = [] - #if grayscale: + if grayscale: + transform_list += [transforms.ToTensor()] #transform_list.append(transforms.Grayscale(1)) if 'resize' in opt.preprocess: osize = [opt.load_size, opt.load_size] From aeb3cb89bd387dde347065ae4fe3169cf27aa99b Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Wed, 8 May 2024 19:14:37 +0200 Subject: [PATCH 091/133] Update base_dataset.py --- data/base_dataset.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index 7de0f7e9963..ec9bbe219c2 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -81,8 +81,8 @@ def get_params(opt, size): def get_transform(opt, params=None, grayscale=False, method=transforms.InterpolationMode.BICUBIC, convert=True): transform_list = [] if grayscale: - transform_list += [transforms.ToTensor()] - #transform_list.append(transforms.Grayscale(1)) + #transform_list += [transforms.ToTensor()] + transform_list.append(transforms.Grayscale(1)) if 'resize' in opt.preprocess: osize = [opt.load_size, opt.load_size] transform_list.append(transforms.Resize(osize, method)) From 2f5145d83a138f6727e1c37399efdc7d3319a670 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Wed, 8 May 2024 19:17:15 +0200 Subject: [PATCH 092/133] Update base_dataset.py --- data/base_dataset.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index ec9bbe219c2..96102593996 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -106,10 +106,10 @@ def get_transform(opt, params=None, grayscale=False, method=transforms.Interpola if convert: transform_list += [transforms.ToTensor()] - #if grayscale: - #transform_list += [transforms.Normalize((0.5,), (0.5,))] - #else: - #transform_list += [transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))] + if grayscale: + transform_list += [transforms.Normalize((0.5,), (0.5,))] + else: + transform_list += [transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))] return transforms.Compose(transform_list) From b113c71702f362f93149fa67cb0cd461faa82e12 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Wed, 8 May 2024 19:20:14 +0200 Subject: [PATCH 093/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index b2808e0b24c..7edc6380b99 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -45,10 +45,10 @@ def __getitem__(self, index): w, h = AB.shape[-1] // 2, AB.shape[-2] A = Image.fromarray(AB[:, :w]) B = Image.fromarray(AB[:, w:]) - + ''' A_array = np.array(A) B_array = np.array(B) - ''' + if np.array_equal(A, B): print("Images A and B are equal.") @@ -72,12 +72,12 @@ def __getitem__(self, index): print("Type:", B_array.dtype) print("Min value:", np.min(B_array)) print("Max value:", np.max(B_array),"\n") - + ''' # apply the same transform to both A and B A = self.transform(A) B = self.transform(B) - + ''' if np.array_equal(A, B): print("Images A and B are equal after trasnform.") From c0e0e566e57b8a83b73fa6ce854a2c58ca04f3a8 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Wed, 8 May 2024 19:22:23 +0200 Subject: [PATCH 094/133] Update base_dataset.py --- data/base_dataset.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index 96102593996..679017fd16b 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -80,9 +80,9 @@ def get_params(opt, size): def get_transform(opt, params=None, grayscale=False, method=transforms.InterpolationMode.BICUBIC, convert=True): transform_list = [] - if grayscale: + #if grayscale: #transform_list += [transforms.ToTensor()] - transform_list.append(transforms.Grayscale(1)) + #transform_list.append(transforms.Grayscale(1)) if 'resize' in opt.preprocess: osize = [opt.load_size, opt.load_size] transform_list.append(transforms.Resize(osize, method)) From 4cc5452e5acbff3ab35ba2e8df89466339970b38 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Wed, 8 May 2024 19:37:26 +0200 Subject: [PATCH 095/133] Update base_dataset.py --- data/base_dataset.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index 679017fd16b..b977c99c0e5 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -95,9 +95,9 @@ def get_transform(opt, params=None, grayscale=False, method=transforms.Interpola else: transform_list.append(transforms.Lambda(lambda img: __crop(img, params['crop_pos'], opt.crop_size))) - if opt.preprocess == 'none': - transform_list.append(transforms.Lambda(lambda img: __make_power_2(img, base=4, method=method))) - + #if opt.preprocess == 'none': + #transform_list.append(transforms.Lambda(lambda img: __make_power_2(img, base=4, method=method))) + if not opt.no_flip: if params is None: transform_list.append(transforms.RandomHorizontalFlip()) @@ -106,10 +106,10 @@ def get_transform(opt, params=None, grayscale=False, method=transforms.Interpola if convert: transform_list += [transforms.ToTensor()] - if grayscale: - transform_list += [transforms.Normalize((0.5,), (0.5,))] - else: - transform_list += [transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))] + #if grayscale: + #transform_list += [transforms.Normalize((0.5,), (0.5,))] + #else: + #transform_list += [transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))] return transforms.Compose(transform_list) From d6f2408c86a7feee53958be55717298f2105fb59 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Wed, 8 May 2024 19:43:24 +0200 Subject: [PATCH 096/133] Update base_dataset.py --- data/base_dataset.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index b977c99c0e5..6966dfdc765 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -106,10 +106,10 @@ def get_transform(opt, params=None, grayscale=False, method=transforms.Interpola if convert: transform_list += [transforms.ToTensor()] - #if grayscale: - #transform_list += [transforms.Normalize((0.5,), (0.5,))] - #else: - #transform_list += [transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))] + if grayscale: + transform_list += [transforms.Normalize((0.5,), (0.5,))] + else: + transform_list += [transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))] return transforms.Compose(transform_list) From 66528549713955866fd182542c39edaf4d39ad8e Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Wed, 8 May 2024 20:29:48 +0200 Subject: [PATCH 097/133] Update base_dataset.py --- data/base_dataset.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index 6966dfdc765..7659b1e6ff5 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -98,11 +98,11 @@ def get_transform(opt, params=None, grayscale=False, method=transforms.Interpola #if opt.preprocess == 'none': #transform_list.append(transforms.Lambda(lambda img: __make_power_2(img, base=4, method=method))) - if not opt.no_flip: - if params is None: - transform_list.append(transforms.RandomHorizontalFlip()) - elif params['flip']: - transform_list.append(transforms.Lambda(lambda img: __flip(img, params['flip']))) + #if not opt.no_flip: + #if params is None: + #transform_list.append(transforms.RandomHorizontalFlip()) + #elif params['flip']: + #transform_list.append(transforms.Lambda(lambda img: __flip(img, params['flip']))) if convert: transform_list += [transforms.ToTensor()] From 624b5f67fb93b251268eccfd0c3ce31be364a2fd Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Thu, 9 May 2024 18:49:40 +0200 Subject: [PATCH 098/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index 7edc6380b99..5edc6256f86 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -45,6 +45,8 @@ def __getitem__(self, index): w, h = AB.shape[-1] // 2, AB.shape[-2] A = Image.fromarray(AB[:, :w]) B = Image.fromarray(AB[:, w:]) + A = A.convert('L') + B = B.convert('L') ''' A_array = np.array(A) B_array = np.array(B) From fdb12bf5d378257ddfdbad2ac7a7bc9fc66fcccb Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Thu, 9 May 2024 18:58:58 +0200 Subject: [PATCH 099/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index 5edc6256f86..be3968ddd72 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -45,9 +45,9 @@ def __getitem__(self, index): w, h = AB.shape[-1] // 2, AB.shape[-2] A = Image.fromarray(AB[:, :w]) B = Image.fromarray(AB[:, w:]) - A = A.convert('L') - B = B.convert('L') - ''' + #A = A.convert('L') + #B = B.convert('L') + A_array = np.array(A) B_array = np.array(B) @@ -74,12 +74,12 @@ def __getitem__(self, index): print("Type:", B_array.dtype) print("Min value:", np.min(B_array)) print("Max value:", np.max(B_array),"\n") - ''' + # apply the same transform to both A and B A = self.transform(A) B = self.transform(B) - ''' + if np.array_equal(A, B): print("Images A and B are equal after trasnform.") @@ -102,7 +102,7 @@ def __getitem__(self, index): print("Type:", B_array_after.dtype) print("Min value:", np.min(B_array_after)) print("Max value:", np.max(B_array_after),"\n") - ''' + return {'A': A, 'B': B, 'A_paths': AB_path, 'B_paths': AB_path} From 3c67b94a71ae9a903a42e7583cc8d537a1881195 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Thu, 9 May 2024 19:07:55 +0200 Subject: [PATCH 100/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index be3968ddd72..b68da9980e9 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -47,7 +47,7 @@ def __getitem__(self, index): B = Image.fromarray(AB[:, w:]) #A = A.convert('L') #B = B.convert('L') - + ''' A_array = np.array(A) B_array = np.array(B) @@ -74,12 +74,12 @@ def __getitem__(self, index): print("Type:", B_array.dtype) print("Min value:", np.min(B_array)) print("Max value:", np.max(B_array),"\n") - + ''' # apply the same transform to both A and B A = self.transform(A) B = self.transform(B) - + ''' if np.array_equal(A, B): print("Images A and B are equal after trasnform.") @@ -102,7 +102,7 @@ def __getitem__(self, index): print("Type:", B_array_after.dtype) print("Min value:", np.min(B_array_after)) print("Max value:", np.max(B_array_after),"\n") - + ''' return {'A': A, 'B': B, 'A_paths': AB_path, 'B_paths': AB_path} From 668c07bff270052e46ed131752e8ccc185a09941 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Thu, 9 May 2024 19:18:37 +0200 Subject: [PATCH 101/133] Update base_dataset.py --- data/base_dataset.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index 7659b1e6ff5..d0835a1460c 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -106,10 +106,10 @@ def get_transform(opt, params=None, grayscale=False, method=transforms.Interpola if convert: transform_list += [transforms.ToTensor()] - if grayscale: - transform_list += [transforms.Normalize((0.5,), (0.5,))] - else: - transform_list += [transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))] + #if grayscale: + #transform_list += [transforms.Normalize((0.5,), (0.5,))] + #else: + #transform_list += [transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))] return transforms.Compose(transform_list) From ed66ae1b9377680cb4df3580a830d76f33330481 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Fri, 10 May 2024 00:57:43 +0200 Subject: [PATCH 102/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index b68da9980e9..08a66526677 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -47,7 +47,7 @@ def __getitem__(self, index): B = Image.fromarray(AB[:, w:]) #A = A.convert('L') #B = B.convert('L') - ''' + A_array = np.array(A) B_array = np.array(B) @@ -74,12 +74,12 @@ def __getitem__(self, index): print("Type:", B_array.dtype) print("Min value:", np.min(B_array)) print("Max value:", np.max(B_array),"\n") - ''' + # apply the same transform to both A and B A = self.transform(A) B = self.transform(B) - ''' + if np.array_equal(A, B): print("Images A and B are equal after trasnform.") @@ -102,7 +102,7 @@ def __getitem__(self, index): print("Type:", B_array_after.dtype) print("Min value:", np.min(B_array_after)) print("Max value:", np.max(B_array_after),"\n") - ''' + return {'A': A, 'B': B, 'A_paths': AB_path, 'B_paths': AB_path} From 66730a3b16bc8cfa6bb52c171b575e7d0a623bcb Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Fri, 10 May 2024 01:03:30 +0200 Subject: [PATCH 103/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index 08a66526677..1accf758b92 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -47,7 +47,7 @@ def __getitem__(self, index): B = Image.fromarray(AB[:, w:]) #A = A.convert('L') #B = B.convert('L') - + ''' A_array = np.array(A) B_array = np.array(B) @@ -74,11 +74,11 @@ def __getitem__(self, index): print("Type:", B_array.dtype) print("Min value:", np.min(B_array)) print("Max value:", np.max(B_array),"\n") - + ''' # apply the same transform to both A and B A = self.transform(A) B = self.transform(B) - + ''' if np.array_equal(A, B): print("Images A and B are equal after trasnform.") @@ -103,7 +103,7 @@ def __getitem__(self, index): print("Min value:", np.min(B_array_after)) print("Max value:", np.max(B_array_after),"\n") - + ''' return {'A': A, 'B': B, 'A_paths': AB_path, 'B_paths': AB_path} def __len__(self): From f03fa1a2e9526d639a59dc3f86210a26e081621c Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 13 May 2024 11:55:39 +0200 Subject: [PATCH 104/133] Update base_dataset.py --- data/base_dataset.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index d0835a1460c..7659b1e6ff5 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -106,10 +106,10 @@ def get_transform(opt, params=None, grayscale=False, method=transforms.Interpola if convert: transform_list += [transforms.ToTensor()] - #if grayscale: - #transform_list += [transforms.Normalize((0.5,), (0.5,))] - #else: - #transform_list += [transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))] + if grayscale: + transform_list += [transforms.Normalize((0.5,), (0.5,))] + else: + transform_list += [transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))] return transforms.Compose(transform_list) From 987f0d22a13b3ddf052fbf5fd4047502cf95ae56 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 13 May 2024 14:25:10 +0200 Subject: [PATCH 105/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index 1accf758b92..56c91603fe5 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -64,7 +64,7 @@ def __getitem__(self, index): print("Type:", A_array.dtype) print("Min value:", np.min(A_array)) print("Max value:", np.max(A_array)) - + ''' B_array = np.array(B) print("\nAll values of image B:\n", B_array) unique_values_B = np.unique(B_array) @@ -74,12 +74,12 @@ def __getitem__(self, index): print("Type:", B_array.dtype) print("Min value:", np.min(B_array)) print("Max value:", np.max(B_array),"\n") - ''' + # apply the same transform to both A and B A = self.transform(A) B = self.transform(B) - ''' + ''' if np.array_equal(A, B): print("Images A and B are equal after trasnform.") @@ -92,7 +92,7 @@ def __getitem__(self, index): print("Type:", A_array_after.dtype) print("Min value:", np.min(A_array_after)) print("Max value:", np.max(A_array_after)) - + ''' B_array_after = np.array(B) print("\nAll values of image B after transform:\n", B_array_after) unique_values_B_after = np.unique(B_array_after) @@ -103,7 +103,7 @@ def __getitem__(self, index): print("Min value:", np.min(B_array_after)) print("Max value:", np.max(B_array_after),"\n") - ''' + return {'A': A, 'B': B, 'A_paths': AB_path, 'B_paths': AB_path} def __len__(self): From ea5b10ad21425832f31ee6371a866bc92ea7e5f6 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 13 May 2024 17:33:03 +0200 Subject: [PATCH 106/133] Update base_dataset.py --- data/base_dataset.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index 7659b1e6ff5..d0835a1460c 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -106,10 +106,10 @@ def get_transform(opt, params=None, grayscale=False, method=transforms.Interpola if convert: transform_list += [transforms.ToTensor()] - if grayscale: - transform_list += [transforms.Normalize((0.5,), (0.5,))] - else: - transform_list += [transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))] + #if grayscale: + #transform_list += [transforms.Normalize((0.5,), (0.5,))] + #else: + #transform_list += [transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))] return transforms.Compose(transform_list) From 2ff26a36565e6d7ac6348b94adf5fa9b85822dc6 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 13 May 2024 17:41:19 +0200 Subject: [PATCH 107/133] Update base_dataset.py --- data/base_dataset.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index d0835a1460c..8e81144000b 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -83,17 +83,17 @@ def get_transform(opt, params=None, grayscale=False, method=transforms.Interpola #if grayscale: #transform_list += [transforms.ToTensor()] #transform_list.append(transforms.Grayscale(1)) - if 'resize' in opt.preprocess: - osize = [opt.load_size, opt.load_size] - transform_list.append(transforms.Resize(osize, method)) - elif 'scale_width' in opt.preprocess: - transform_list.append(transforms.Lambda(lambda img: __scale_width(img, opt.load_size, opt.crop_size, method))) - - if 'crop' in opt.preprocess: - if params is None: - transform_list.append(transforms.RandomCrop(opt.crop_size)) - else: - transform_list.append(transforms.Lambda(lambda img: __crop(img, params['crop_pos'], opt.crop_size))) + #if 'resize' in opt.preprocess: + #osize = [opt.load_size, opt.load_size] + #transform_list.append(transforms.Resize(osize, method)) + #elif 'scale_width' in opt.preprocess: + #transform_list.append(transforms.Lambda(lambda img: __scale_width(img, opt.load_size, opt.crop_size, method))) + + #if 'crop' in opt.preprocess: + #if params is None: + #transform_list.append(transforms.RandomCrop(opt.crop_size)) + #else: + #transform_list.append(transforms.Lambda(lambda img: __crop(img, params['crop_pos'], opt.crop_size))) #if opt.preprocess == 'none': #transform_list.append(transforms.Lambda(lambda img: __make_power_2(img, base=4, method=method))) From 1bb687a717b5a1539488c4bfef7c3de06c24ce21 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 13 May 2024 17:44:11 +0200 Subject: [PATCH 108/133] Update base_dataset.py --- data/base_dataset.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index 8e81144000b..93f79eed47f 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -83,9 +83,9 @@ def get_transform(opt, params=None, grayscale=False, method=transforms.Interpola #if grayscale: #transform_list += [transforms.ToTensor()] #transform_list.append(transforms.Grayscale(1)) - #if 'resize' in opt.preprocess: - #osize = [opt.load_size, opt.load_size] - #transform_list.append(transforms.Resize(osize, method)) + if 'resize' in opt.preprocess: + osize = [opt.load_size, opt.load_size] + transform_list.append(transforms.Resize(osize, method)) #elif 'scale_width' in opt.preprocess: #transform_list.append(transforms.Lambda(lambda img: __scale_width(img, opt.load_size, opt.crop_size, method))) From 45a5c101981eefdcac0d91ef082101795ec35f3f Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 13 May 2024 17:50:31 +0200 Subject: [PATCH 109/133] Update base_dataset.py --- data/base_dataset.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index 93f79eed47f..b34e360420a 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -84,16 +84,16 @@ def get_transform(opt, params=None, grayscale=False, method=transforms.Interpola #transform_list += [transforms.ToTensor()] #transform_list.append(transforms.Grayscale(1)) if 'resize' in opt.preprocess: - osize = [opt.load_size, opt.load_size] - transform_list.append(transforms.Resize(osize, method)) - #elif 'scale_width' in opt.preprocess: - #transform_list.append(transforms.Lambda(lambda img: __scale_width(img, opt.load_size, opt.crop_size, method))) - - #if 'crop' in opt.preprocess: - #if params is None: - #transform_list.append(transforms.RandomCrop(opt.crop_size)) - #else: - #transform_list.append(transforms.Lambda(lambda img: __crop(img, params['crop_pos'], opt.crop_size))) + #osize = [opt.load_size, opt.load_size] + #transform_list.append(transforms.Resize(osize, method)) + elif 'scale_width' in opt.preprocess: + transform_list.append(transforms.Lambda(lambda img: __scale_width(img, opt.load_size, opt.crop_size, method))) + + if 'crop' in opt.preprocess: + if params is None: + transform_list.append(transforms.RandomCrop(opt.crop_size)) + else: + transform_list.append(transforms.Lambda(lambda img: __crop(img, params['crop_pos'], opt.crop_size))) #if opt.preprocess == 'none': #transform_list.append(transforms.Lambda(lambda img: __make_power_2(img, base=4, method=method))) From a6b5f03bf0729a8a72975724ba50241bebb600e7 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 13 May 2024 17:53:46 +0200 Subject: [PATCH 110/133] Update base_dataset.py --- data/base_dataset.py | 1 + 1 file changed, 1 insertion(+) diff --git a/data/base_dataset.py b/data/base_dataset.py index b34e360420a..dd6b01c8ee3 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -84,6 +84,7 @@ def get_transform(opt, params=None, grayscale=False, method=transforms.Interpola #transform_list += [transforms.ToTensor()] #transform_list.append(transforms.Grayscale(1)) if 'resize' in opt.preprocess: + print("Vado qua") #osize = [opt.load_size, opt.load_size] #transform_list.append(transforms.Resize(osize, method)) elif 'scale_width' in opt.preprocess: From 8288b69c78a8fb31f771ef3a209a712b06c2202d Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 13 May 2024 18:08:41 +0200 Subject: [PATCH 111/133] Update base_dataset.py --- data/base_dataset.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index dd6b01c8ee3..f41705af6f6 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -78,17 +78,16 @@ def get_params(opt, size): return {'crop_pos': (x, y), 'flip': flip} -def get_transform(opt, params=None, grayscale=False, method=transforms.InterpolationMode.BICUBIC, convert=True): +def get_transform(opt, params=None, grayscale=False, method=transforms.InterpolationMode.NEAREST, convert=True): transform_list = [] #if grayscale: #transform_list += [transforms.ToTensor()] #transform_list.append(transforms.Grayscale(1)) if 'resize' in opt.preprocess: - print("Vado qua") - #osize = [opt.load_size, opt.load_size] - #transform_list.append(transforms.Resize(osize, method)) - elif 'scale_width' in opt.preprocess: - transform_list.append(transforms.Lambda(lambda img: __scale_width(img, opt.load_size, opt.crop_size, method))) + osize = [opt.load_size, opt.load_size] + transform_list.append(transforms.Resize(osize, method)) + #elif 'scale_width' in opt.preprocess: + #transform_list.append(transforms.Lambda(lambda img: __scale_width(img, opt.load_size, opt.crop_size, method))) if 'crop' in opt.preprocess: if params is None: From dab221d426cef7da56b68a957d7991c3bf19dc4d Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 13 May 2024 18:15:53 +0200 Subject: [PATCH 112/133] Update base_dataset.py --- data/base_dataset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index f41705af6f6..37541cf6ffb 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -78,7 +78,7 @@ def get_params(opt, size): return {'crop_pos': (x, y), 'flip': flip} -def get_transform(opt, params=None, grayscale=False, method=transforms.InterpolationMode.NEAREST, convert=True): +def get_transform(opt, params=None, grayscale=False, method=transforms.InterpolationMode.BICUBIC, convert=True): transform_list = [] #if grayscale: #transform_list += [transforms.ToTensor()] From 1385e3d19398974a34dd847e0cbd2d16920e8e3b Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 13 May 2024 18:41:38 +0200 Subject: [PATCH 113/133] Update base_dataset.py --- data/base_dataset.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index 37541cf6ffb..93f79eed47f 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -89,11 +89,11 @@ def get_transform(opt, params=None, grayscale=False, method=transforms.Interpola #elif 'scale_width' in opt.preprocess: #transform_list.append(transforms.Lambda(lambda img: __scale_width(img, opt.load_size, opt.crop_size, method))) - if 'crop' in opt.preprocess: - if params is None: - transform_list.append(transforms.RandomCrop(opt.crop_size)) - else: - transform_list.append(transforms.Lambda(lambda img: __crop(img, params['crop_pos'], opt.crop_size))) + #if 'crop' in opt.preprocess: + #if params is None: + #transform_list.append(transforms.RandomCrop(opt.crop_size)) + #else: + #transform_list.append(transforms.Lambda(lambda img: __crop(img, params['crop_pos'], opt.crop_size))) #if opt.preprocess == 'none': #transform_list.append(transforms.Lambda(lambda img: __make_power_2(img, base=4, method=method))) From a09cc768b7c017d4c2e7a14a738ed0f360b5a851 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 13 May 2024 18:46:46 +0200 Subject: [PATCH 114/133] Update base_dataset.py --- data/base_dataset.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index 93f79eed47f..727e963db10 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -89,9 +89,9 @@ def get_transform(opt, params=None, grayscale=False, method=transforms.Interpola #elif 'scale_width' in opt.preprocess: #transform_list.append(transforms.Lambda(lambda img: __scale_width(img, opt.load_size, opt.crop_size, method))) - #if 'crop' in opt.preprocess: - #if params is None: - #transform_list.append(transforms.RandomCrop(opt.crop_size)) + if 'crop' in opt.preprocess: + if params is None: + transform_list.append(transforms.CenterCrop(opt.crop_size)) #else: #transform_list.append(transforms.Lambda(lambda img: __crop(img, params['crop_pos'], opt.crop_size))) From 956a88e3c969fb4613e3ae94b222b34d6ee8f7c1 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 13 May 2024 18:52:52 +0200 Subject: [PATCH 115/133] Update base_dataset.py --- data/base_dataset.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index 727e963db10..37541cf6ffb 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -91,9 +91,9 @@ def get_transform(opt, params=None, grayscale=False, method=transforms.Interpola if 'crop' in opt.preprocess: if params is None: - transform_list.append(transforms.CenterCrop(opt.crop_size)) - #else: - #transform_list.append(transforms.Lambda(lambda img: __crop(img, params['crop_pos'], opt.crop_size))) + transform_list.append(transforms.RandomCrop(opt.crop_size)) + else: + transform_list.append(transforms.Lambda(lambda img: __crop(img, params['crop_pos'], opt.crop_size))) #if opt.preprocess == 'none': #transform_list.append(transforms.Lambda(lambda img: __make_power_2(img, base=4, method=method))) From bc610c45dbb57b001b8876fa64a5a2bf0aef1205 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 13 May 2024 18:58:21 +0200 Subject: [PATCH 116/133] Update base_dataset.py --- data/base_dataset.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index 37541cf6ffb..ab3ad0a2fa0 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -78,7 +78,7 @@ def get_params(opt, size): return {'crop_pos': (x, y), 'flip': flip} -def get_transform(opt, params=None, grayscale=False, method=transforms.InterpolationMode.BICUBIC, convert=True): +def get_transform(opt, params=None, grayscale=False, method=transforms.InterpolationMode.NEAREST, convert=True): transform_list = [] #if grayscale: #transform_list += [transforms.ToTensor()] @@ -91,7 +91,7 @@ def get_transform(opt, params=None, grayscale=False, method=transforms.Interpola if 'crop' in opt.preprocess: if params is None: - transform_list.append(transforms.RandomCrop(opt.crop_size)) + transform_list.append(transforms.CenterCrop(opt.crop_size)) else: transform_list.append(transforms.Lambda(lambda img: __crop(img, params['crop_pos'], opt.crop_size))) From 2fc8feae5e6d3249e17f5b2bccfdfda01ad58a88 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 13 May 2024 19:12:15 +0200 Subject: [PATCH 117/133] Update base_dataset.py --- data/base_dataset.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index ab3ad0a2fa0..a05ea1c0be5 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -86,8 +86,8 @@ def get_transform(opt, params=None, grayscale=False, method=transforms.Interpola if 'resize' in opt.preprocess: osize = [opt.load_size, opt.load_size] transform_list.append(transforms.Resize(osize, method)) - #elif 'scale_width' in opt.preprocess: - #transform_list.append(transforms.Lambda(lambda img: __scale_width(img, opt.load_size, opt.crop_size, method))) + elif 'scale_width' in opt.preprocess: + transform_list.append(transforms.Lambda(lambda img: __scale_width(img, opt.load_size, opt.crop_size, method))) if 'crop' in opt.preprocess: if params is None: From 95f5fac689095f15b6beb70e5ee92d3fc4bc7eb3 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 13 May 2024 19:17:01 +0200 Subject: [PATCH 118/133] Update base_dataset.py --- data/base_dataset.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index a05ea1c0be5..a5082454c10 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -106,8 +106,8 @@ def get_transform(opt, params=None, grayscale=False, method=transforms.Interpola if convert: transform_list += [transforms.ToTensor()] - #if grayscale: - #transform_list += [transforms.Normalize((0.5,), (0.5,))] + if grayscale: + transform_list += [transforms.Normalize((0.5,), (0.5,))] #else: #transform_list += [transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))] return transforms.Compose(transform_list) From c52b80484619b2196343ac59cf3bae56be5c459d Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 13 May 2024 19:22:11 +0200 Subject: [PATCH 119/133] Update base_dataset.py --- data/base_dataset.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index a5082454c10..57ae06d6f02 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -78,7 +78,7 @@ def get_params(opt, size): return {'crop_pos': (x, y), 'flip': flip} -def get_transform(opt, params=None, grayscale=False, method=transforms.InterpolationMode.NEAREST, convert=True): +def get_transform(opt, params=None, grayscale=False, method=transforms.InterpolationMode.BICUBIC, convert=True): transform_list = [] #if grayscale: #transform_list += [transforms.ToTensor()] @@ -108,8 +108,8 @@ def get_transform(opt, params=None, grayscale=False, method=transforms.Interpola transform_list += [transforms.ToTensor()] if grayscale: transform_list += [transforms.Normalize((0.5,), (0.5,))] - #else: - #transform_list += [transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))] + else: + transform_list += [transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))] return transforms.Compose(transform_list) From 353b24fd5e9ace51be407e770e5b43d1e2c9ad26 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 13 May 2024 19:27:34 +0200 Subject: [PATCH 120/133] Update base_dataset.py --- data/base_dataset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index 57ae06d6f02..488d55f5440 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -78,7 +78,7 @@ def get_params(opt, size): return {'crop_pos': (x, y), 'flip': flip} -def get_transform(opt, params=None, grayscale=False, method=transforms.InterpolationMode.BICUBIC, convert=True): +def get_transform(opt, params=None, grayscale=False, method=transforms.InterpolationMode.NEAREST, convert=True): transform_list = [] #if grayscale: #transform_list += [transforms.ToTensor()] From 005d36ed5d28e13f82846edfcf9229445630069c Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Mon, 13 May 2024 19:31:27 +0200 Subject: [PATCH 121/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index 56c91603fe5..290e691e1ca 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -64,7 +64,7 @@ def __getitem__(self, index): print("Type:", A_array.dtype) print("Min value:", np.min(A_array)) print("Max value:", np.max(A_array)) - ''' + B_array = np.array(B) print("\nAll values of image B:\n", B_array) unique_values_B = np.unique(B_array) @@ -74,7 +74,7 @@ def __getitem__(self, index): print("Type:", B_array.dtype) print("Min value:", np.min(B_array)) print("Max value:", np.max(B_array),"\n") - + ''' # apply the same transform to both A and B A = self.transform(A) B = self.transform(B) @@ -92,7 +92,7 @@ def __getitem__(self, index): print("Type:", A_array_after.dtype) print("Min value:", np.min(A_array_after)) print("Max value:", np.max(A_array_after)) - ''' + B_array_after = np.array(B) print("\nAll values of image B after transform:\n", B_array_after) unique_values_B_after = np.unique(B_array_after) @@ -102,7 +102,7 @@ def __getitem__(self, index): print("Type:", B_array_after.dtype) print("Min value:", np.min(B_array_after)) print("Max value:", np.max(B_array_after),"\n") - + ''' return {'A': A, 'B': B, 'A_paths': AB_path, 'B_paths': AB_path} From 981c55951492e0a9435cf4f9523acdbcc03a7b7f Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Tue, 14 May 2024 00:51:31 +0200 Subject: [PATCH 122/133] Update base_dataset.py --- data/base_dataset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index 488d55f5440..57ae06d6f02 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -78,7 +78,7 @@ def get_params(opt, size): return {'crop_pos': (x, y), 'flip': flip} -def get_transform(opt, params=None, grayscale=False, method=transforms.InterpolationMode.NEAREST, convert=True): +def get_transform(opt, params=None, grayscale=False, method=transforms.InterpolationMode.BICUBIC, convert=True): transform_list = [] #if grayscale: #transform_list += [transforms.ToTensor()] From 50792a5149f993399f4604a9f03eb268b8aec51d Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Tue, 14 May 2024 00:57:51 +0200 Subject: [PATCH 123/133] Update test.py --- test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.py b/test.py index 73fc9160f75..fdf8cdb0917 100644 --- a/test.py +++ b/test.py @@ -85,7 +85,7 @@ save_path = os.path.join(web_dir, f'{image_name}_{label}.tiff') image_numpy = image_numpy.cpu().numpy() # Salva l'immagine come tiff utilizzando tifffile - tifffile.imwrite(save_path, image_numpy) #.astype(np.uint16)) + tifffile.imwrite(save_path, image_numpy, dtype='float32',) #.astype(np.uint16)) if opt.use_wandb: wandb.save(save_path) From 98be9a04439a3ce9f6ca11e71b25ad2711e5caf9 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Tue, 14 May 2024 00:58:34 +0200 Subject: [PATCH 124/133] Update base_dataset.py --- data/base_dataset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index 57ae06d6f02..488d55f5440 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -78,7 +78,7 @@ def get_params(opt, size): return {'crop_pos': (x, y), 'flip': flip} -def get_transform(opt, params=None, grayscale=False, method=transforms.InterpolationMode.BICUBIC, convert=True): +def get_transform(opt, params=None, grayscale=False, method=transforms.InterpolationMode.NEAREST, convert=True): transform_list = [] #if grayscale: #transform_list += [transforms.ToTensor()] From 2b497ccd9cd2d0bc6fb3a63ea3b64a895ae3176d Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Tue, 14 May 2024 00:59:46 +0200 Subject: [PATCH 125/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index 290e691e1ca..56c91603fe5 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -64,7 +64,7 @@ def __getitem__(self, index): print("Type:", A_array.dtype) print("Min value:", np.min(A_array)) print("Max value:", np.max(A_array)) - + ''' B_array = np.array(B) print("\nAll values of image B:\n", B_array) unique_values_B = np.unique(B_array) @@ -74,7 +74,7 @@ def __getitem__(self, index): print("Type:", B_array.dtype) print("Min value:", np.min(B_array)) print("Max value:", np.max(B_array),"\n") - ''' + # apply the same transform to both A and B A = self.transform(A) B = self.transform(B) @@ -92,7 +92,7 @@ def __getitem__(self, index): print("Type:", A_array_after.dtype) print("Min value:", np.min(A_array_after)) print("Max value:", np.max(A_array_after)) - + ''' B_array_after = np.array(B) print("\nAll values of image B after transform:\n", B_array_after) unique_values_B_after = np.unique(B_array_after) @@ -102,7 +102,7 @@ def __getitem__(self, index): print("Type:", B_array_after.dtype) print("Min value:", np.min(B_array_after)) print("Max value:", np.max(B_array_after),"\n") - ''' + return {'A': A, 'B': B, 'A_paths': AB_path, 'B_paths': AB_path} From e389e2ba9f4fa0c1c341cfa9ee02cbd9bea31352 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Tue, 14 May 2024 11:45:31 +0200 Subject: [PATCH 126/133] Update test.py --- test.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test.py b/test.py index fdf8cdb0917..80d6ae85660 100644 --- a/test.py +++ b/test.py @@ -79,6 +79,9 @@ if i % 5 == 0: # save images to an HTML file print('processing (%04d)-th image... %s' % (i, img_path)) # Save images as TIFF + save_images(webpage, visuals, img_path, aspect_ratio=opt.aspect_ratio, width=opt.display_winsize, use_wandb=opt.use_wandb) + webpage.save() # save the HTML + ''' for label, image_numpy in visuals.items(): image_path = img_path[0] if len(img_path) == 1 else img_path[i] image_name, ext = os.path.splitext(os.path.basename(image_path)) @@ -91,3 +94,4 @@ #save_images(webpage, visuals, img_path, aspect_ratio=opt.aspect_ratio, width=opt.display_winsize, use_wandb=opt.use_wandb) webpage.save() # save the HTML + ''' From 5aec6772b96d6764d2bf7991ab57a11ab60ccc81 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Tue, 14 May 2024 11:52:12 +0200 Subject: [PATCH 127/133] Update test.py --- test.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/test.py b/test.py index 80d6ae85660..5377bce3985 100644 --- a/test.py +++ b/test.py @@ -81,17 +81,17 @@ # Save images as TIFF save_images(webpage, visuals, img_path, aspect_ratio=opt.aspect_ratio, width=opt.display_winsize, use_wandb=opt.use_wandb) webpage.save() # save the HTML - ''' - for label, image_numpy in visuals.items(): - image_path = img_path[0] if len(img_path) == 1 else img_path[i] - image_name, ext = os.path.splitext(os.path.basename(image_path)) - save_path = os.path.join(web_dir, f'{image_name}_{label}.tiff') - image_numpy = image_numpy.cpu().numpy() + + #for label, image_numpy in visuals.items(): + #image_path = img_path[0] if len(img_path) == 1 else img_path[i] + #image_name, ext = os.path.splitext(os.path.basename(image_path)) + #save_path = os.path.join(web_dir, f'{image_name}_{label}.tiff') + #image_numpy = image_numpy.cpu().numpy() # Salva l'immagine come tiff utilizzando tifffile - tifffile.imwrite(save_path, image_numpy, dtype='float32',) #.astype(np.uint16)) - if opt.use_wandb: - wandb.save(save_path) + #tifffile.imwrite(save_path, image_numpy, dtype='float32',) #.astype(np.uint16)) + #if opt.use_wandb: + #wandb.save(save_path) #save_images(webpage, visuals, img_path, aspect_ratio=opt.aspect_ratio, width=opt.display_winsize, use_wandb=opt.use_wandb) - webpage.save() # save the HTML - ''' + #webpage.save() # save the HTML + From 7fba170b3cd03fe6762ca8c6f2da0da2117265b4 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Tue, 14 May 2024 14:05:25 +0200 Subject: [PATCH 128/133] Update test.py --- test.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/test.py b/test.py index 5377bce3985..3ac4f7ac3d4 100644 --- a/test.py +++ b/test.py @@ -78,19 +78,16 @@ img_path = model.get_image_paths() # get image paths if i % 5 == 0: # save images to an HTML file print('processing (%04d)-th image... %s' % (i, img_path)) - # Save images as TIFF - save_images(webpage, visuals, img_path, aspect_ratio=opt.aspect_ratio, width=opt.display_winsize, use_wandb=opt.use_wandb) - webpage.save() # save the HTML - - #for label, image_numpy in visuals.items(): - #image_path = img_path[0] if len(img_path) == 1 else img_path[i] - #image_name, ext = os.path.splitext(os.path.basename(image_path)) - #save_path = os.path.join(web_dir, f'{image_name}_{label}.tiff') - #image_numpy = image_numpy.cpu().numpy() + for label, image_numpy in visuals.items(): + image_path = img_path[0] if len(img_path) == 1 else img_path[i] + image_name, ext = os.path.splitext(os.path.basename(image_path)) + save_path = os.path.join(web_dir, f'{image_name}_{label}.tiff') + image_numpy = image_numpy.cpu().numpy() # Salva l'immagine come tiff utilizzando tifffile - #tifffile.imwrite(save_path, image_numpy, dtype='float32',) #.astype(np.uint16)) - #if opt.use_wandb: - #wandb.save(save_path) + image_numpy = (image_numpy + 1) / 2 + tifffile.imwrite(save_path, image_numpy, dtype='float32',) #.astype(np.uint16)) + if opt.use_wandb: + wandb.save(save_path) #save_images(webpage, visuals, img_path, aspect_ratio=opt.aspect_ratio, width=opt.display_winsize, use_wandb=opt.use_wandb) #webpage.save() # save the HTML From 7eb025bec5c35f711ba2e709b5893f528d3c95fa Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Tue, 14 May 2024 17:56:38 +0200 Subject: [PATCH 129/133] Update base_dataset.py --- data/base_dataset.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index 488d55f5440..a05ea1c0be5 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -106,10 +106,10 @@ def get_transform(opt, params=None, grayscale=False, method=transforms.Interpola if convert: transform_list += [transforms.ToTensor()] - if grayscale: - transform_list += [transforms.Normalize((0.5,), (0.5,))] - else: - transform_list += [transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))] + #if grayscale: + #transform_list += [transforms.Normalize((0.5,), (0.5,))] + #else: + #transform_list += [transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))] return transforms.Compose(transform_list) From dc862a3578e784ac7d05060927af803f099c3ed6 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Tue, 14 May 2024 17:57:24 +0200 Subject: [PATCH 130/133] Update test.py --- test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.py b/test.py index 3ac4f7ac3d4..547217a4387 100644 --- a/test.py +++ b/test.py @@ -84,7 +84,7 @@ save_path = os.path.join(web_dir, f'{image_name}_{label}.tiff') image_numpy = image_numpy.cpu().numpy() # Salva l'immagine come tiff utilizzando tifffile - image_numpy = (image_numpy + 1) / 2 + #image_numpy = (image_numpy + 1) / 2 tifffile.imwrite(save_path, image_numpy, dtype='float32',) #.astype(np.uint16)) if opt.use_wandb: wandb.save(save_path) From b239f8574969578970acc6f00ff80c4797570c6b Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Tue, 14 May 2024 17:59:42 +0200 Subject: [PATCH 131/133] Update myaligned_dataset.py --- data/myaligned_dataset.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/data/myaligned_dataset.py b/data/myaligned_dataset.py index 56c91603fe5..c3e281f518a 100644 --- a/data/myaligned_dataset.py +++ b/data/myaligned_dataset.py @@ -64,7 +64,7 @@ def __getitem__(self, index): print("Type:", A_array.dtype) print("Min value:", np.min(A_array)) print("Max value:", np.max(A_array)) - ''' + B_array = np.array(B) print("\nAll values of image B:\n", B_array) unique_values_B = np.unique(B_array) @@ -74,7 +74,7 @@ def __getitem__(self, index): print("Type:", B_array.dtype) print("Min value:", np.min(B_array)) print("Max value:", np.max(B_array),"\n") - + ''' # apply the same transform to both A and B A = self.transform(A) B = self.transform(B) @@ -92,7 +92,7 @@ def __getitem__(self, index): print("Type:", A_array_after.dtype) print("Min value:", np.min(A_array_after)) print("Max value:", np.max(A_array_after)) - ''' + B_array_after = np.array(B) print("\nAll values of image B after transform:\n", B_array_after) unique_values_B_after = np.unique(B_array_after) @@ -103,7 +103,7 @@ def __getitem__(self, index): print("Min value:", np.min(B_array_after)) print("Max value:", np.max(B_array_after),"\n") - + ''' return {'A': A, 'B': B, 'A_paths': AB_path, 'B_paths': AB_path} def __len__(self): From 0a31f48bfc754eb3797e77e4503e0549df82d82d Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Tue, 14 May 2024 23:55:58 +0200 Subject: [PATCH 132/133] Update test.py --- test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.py b/test.py index 547217a4387..3ac4f7ac3d4 100644 --- a/test.py +++ b/test.py @@ -84,7 +84,7 @@ save_path = os.path.join(web_dir, f'{image_name}_{label}.tiff') image_numpy = image_numpy.cpu().numpy() # Salva l'immagine come tiff utilizzando tifffile - #image_numpy = (image_numpy + 1) / 2 + image_numpy = (image_numpy + 1) / 2 tifffile.imwrite(save_path, image_numpy, dtype='float32',) #.astype(np.uint16)) if opt.use_wandb: wandb.save(save_path) From ffb38b00e8312b1c58d7a96ed30912810b635f84 Mon Sep 17 00:00:00 2001 From: andrea2399 <92758544+andrea2399@users.noreply.github.com> Date: Tue, 14 May 2024 23:56:56 +0200 Subject: [PATCH 133/133] Update base_dataset.py --- data/base_dataset.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/data/base_dataset.py b/data/base_dataset.py index a05ea1c0be5..488d55f5440 100755 --- a/data/base_dataset.py +++ b/data/base_dataset.py @@ -106,10 +106,10 @@ def get_transform(opt, params=None, grayscale=False, method=transforms.Interpola if convert: transform_list += [transforms.ToTensor()] - #if grayscale: - #transform_list += [transforms.Normalize((0.5,), (0.5,))] - #else: - #transform_list += [transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))] + if grayscale: + transform_list += [transforms.Normalize((0.5,), (0.5,))] + else: + transform_list += [transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))] return transforms.Compose(transform_list)