AAnoosheh / ToDayGAN

http://arxiv.org/abs/1809.09767
BSD 2-Clause "Simplified" License
172 stars 32 forks source link

About the training problem #12

Closed VPRzhou closed 5 years ago

VPRzhou commented 5 years ago

Hello,there is something wrong when I do train.py. I do not know the problem where it is from. I'm looking forward your reply,thank you. python train.py --name nighttoday --dataroot ./datasets/test1 --n_domains 2 --niter 150 --niter_decay 150

Traceback (most recent call last): File "train.py", line 10, in print('# training images = %d' % len(dataset)) File "/home/zhoul/ToDayGAN/data/data_loader.py", line 18, in len return min(len(self.dataset), self.opt.max_dataset_size) File "/home/zhoul/ToDayGAN/data/unaligned_dataset.py", line 54, in len return max(self.sizes) ValueError: max() arg is an empty sequence

AAnoosheh commented 5 years ago

Hi, does your dataroot contain two directories named beginning with the name "train" ?

The script looks inside the given dataroot argument for all folders starting with "train" and this number of folders must match n_domains.

VPRzhou commented 5 years ago

oh,I got it. I have set two subfolders named"train0、train1"in the dataset directory, it works. But there is a new wrong happened. The error is as follows:

**Created 2 Discriminators

Number of parameters per Discriminator: 16698201

create web directory ./checkpoints/nighttoday/web... Traceback (most recent call last): File "train.py", line 22, in for i, data in enumerate(dataset): File "/home/zhoul/ToDayGAN/data/data_loader.py", line 21, in iter for i, data in enumerate(self.dataloader): File "/home/zhoul/anaconda3/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 582, in next return self._process_next_batch(batch) File "/home/zhoul/anaconda3/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 608, in _process_next_batch raise batch.exc_type(batch.exc_msg) ValueError: Traceback (most recent call last): File "/home/zhoul/anaconda3/lib/python3.6/site-packages/torch/utils/data/_utils/worker.py", line 99, in _worker_loop samples = collate_fn([dataset[i] for i in batch_indices]) File "/home/zhoul/anaconda3/lib/python3.6/site-packages/torch/utils/data/_utils/worker.py", line 99, in samples = collate_fn([dataset[i] for i in batch_indices]) File "/home/zhoul/ToDayGAN/data/unaligned_dataset.py", line 40, in getitem index_A = random.randint(0, self.sizes[DA] - 1) File "/home/zhoul/anaconda3/lib/python3.6/random.py", line 220, in randint return self.randrange(a, b+1) File "/home/zhoul/anaconda3/lib/python3.6/random.py", line 198, in randrange raise ValueError("empty range for randrange() (%d,%d, %d)" % (istart, istop, width)) ValueError: empty range for randrange() (0,0, 0)**

AAnoosheh commented 5 years ago

Sorry for the delay. Um, it looks like one of your train directories is empty.

VPRzhou commented 5 years ago

thanks for your reply. The training process is working now.

VPRzhou commented 5 years ago

Hi,I have encountered a problem I have consulted you before. I have set up two folders"train0,train1"(test0,test1) under the dataroot ,and the two folders also contains photos . When I run the train.py( test.py) file,they can not work properly.I am sorry for bothering you again.The train.py's error is as follows: python train.py --name 2day --dataroot ./datasets/train1 --n_domains 2 --niter 150 --niter_decay 150 ------------ Options ------------- batchSize: 1 beta1: 0.5 checkpoints_dir: ./checkpoints continue_train: False dataroot: ./datasets/train1 display_freq: 100 display_id: 0 display_port: 8097 display_single_pane_ncols: 0 display_winsize: 256 fineSize: 256 gpu_ids: [0] input_nc: 3 isTrain: True lambda_cycle: 10.0 lambda_forward: 0.0 lambda_identity: 0.0 lambda_latent: 0.0 loadSize: 286 lr: 0.0002 max_dataset_size: inf nThreads: 2 n_domains: 2 name: 2day ndf: 64 netD_n_layers: 4 netG_n_blocks: 9 netG_n_shared: 0 ngf: 64 niter: 150 niter_decay: 150 no_flip: False no_html: False norm: instance output_nc: 3 phase: train pool_size: 50 print_freq: 100 resize_or_crop: resize_and_crop save_epoch_freq: 5 use_dropout: False which_epoch: 0 -------------- End ---------------- Traceback (most recent call last): File "train.py", line 10, in print('# training images = %d' % len(dataset)) File "/home/zhoul/ToDayGAN/data/data_loader.py", line 18, in len return min(len(self.dataset), self.opt.max_dataset_size) File "/home/zhoul/ToDayGAN/data/unaligned_dataset.py", line 54, in len return max(self.sizes) ValueError: max() arg is an empty sequence

The test.py's error is as shown below: python test.py --phase test --serial_test --name robotcar_2day --dataroot ./datasets/test1 --n_domains 2 --which_epoch 150 ------------ Options ------------- aspect_ratio: 1.0 autoencode: False batchSize: 1 checkpoints_dir: ./checkpoints dataroot: ./datasets/test1 display_id: 0 display_port: 8097 display_single_pane_ncols: 0 display_winsize: 256 fineSize: 256 gpu_ids: [0] how_many: 50 input_nc: 3 isTrain: False loadSize: 286 max_dataset_size: inf nThreads: 2 n_domains: 2 name: robotcar_2day ndf: 64 netD_n_layers: 4 netG_n_blocks: 9 netG_n_shared: 0 ngf: 64 no_flip: False norm: instance output_nc: 3 phase: test reconstruct: False resize_or_crop: resize_and_crop results_dir: ./results/ serial_test: True show_matrix: False use_dropout: False which_epoch: 150 -------------- End ---------------- ---------- Networks initialized ------------- ResnetGenEncoder( (model): Sequential( (0): ReflectionPad2d((3, 3, 3, 3)) (1): Conv2d(3, 64, kernel_size=(7, 7), stride=(1, 1)) (2): InstanceNorm2d(64, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) (3): PReLU(num_parameters=1) (4): Conv2d(64, 128, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1)) (5): InstanceNorm2d(128, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) (6): PReLU(num_parameters=1) (7): Conv2d(128, 256, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1)) (8): InstanceNorm2d(256, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) (9): PReLU(num_parameters=1) (10): ResnetBlock( (conv_block): SequentialContext( (0): ReflectionPad2d((1, 1, 1, 1)) (1): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1)) (2): InstanceNorm2d(256, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) (3): PReLU(num_parameters=1) (4): ReflectionPad2d((1, 1, 1, 1)) (5): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1)) (6): InstanceNorm2d(256, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) ) ) (11): ResnetBlock( (conv_block): SequentialContext( (0): ReflectionPad2d((1, 1, 1, 1)) (1): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1)) (2): InstanceNorm2d(256, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) (3): PReLU(num_parameters=1) (4): ReflectionPad2d((1, 1, 1, 1)) (5): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1)) (6): InstanceNorm2d(256, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) ) ) (12): ResnetBlock( (conv_block): SequentialContext( (0): ReflectionPad2d((1, 1, 1, 1)) (1): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1)) (2): InstanceNorm2d(256, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) (3): PReLU(num_parameters=1) (4): ReflectionPad2d((1, 1, 1, 1)) (5): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1)) (6): InstanceNorm2d(256, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) ) ) (13): ResnetBlock( (conv_block): SequentialContext( (0): ReflectionPad2d((1, 1, 1, 1)) (1): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1)) (2): InstanceNorm2d(256, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) (3): PReLU(num_parameters=1) (4): ReflectionPad2d((1, 1, 1, 1)) (5): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1)) (6): InstanceNorm2d(256, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) ) ) ) ) ResnetGenDecoder( (model): Sequential( (0): ResnetBlock( (conv_block): SequentialContext( (0): ReflectionPad2d((1, 1, 1, 1)) (1): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1)) (2): InstanceNorm2d(256, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) (3): PReLU(num_parameters=1) (4): ReflectionPad2d((1, 1, 1, 1)) (5): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1)) (6): InstanceNorm2d(256, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) ) ) (1): ResnetBlock( (conv_block): SequentialContext( (0): ReflectionPad2d((1, 1, 1, 1)) (1): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1)) (2): InstanceNorm2d(256, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) (3): PReLU(num_parameters=1) (4): ReflectionPad2d((1, 1, 1, 1)) (5): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1)) (6): InstanceNorm2d(256, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) ) ) (2): ResnetBlock( (conv_block): SequentialContext( (0): ReflectionPad2d((1, 1, 1, 1)) (1): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1)) (2): InstanceNorm2d(256, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) (3): PReLU(num_parameters=1) (4): ReflectionPad2d((1, 1, 1, 1)) (5): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1)) (6): InstanceNorm2d(256, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) ) ) (3): ResnetBlock( (conv_block): SequentialContext( (0): ReflectionPad2d((1, 1, 1, 1)) (1): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1)) (2): InstanceNorm2d(256, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) (3): PReLU(num_parameters=1) (4): ReflectionPad2d((1, 1, 1, 1)) (5): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1)) (6): InstanceNorm2d(256, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) ) ) (4): ResnetBlock( (conv_block): SequentialContext( (0): ReflectionPad2d((1, 1, 1, 1)) (1): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1)) (2): InstanceNorm2d(256, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) (3): PReLU(num_parameters=1) (4): ReflectionPad2d((1, 1, 1, 1)) (5): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1)) (6): InstanceNorm2d(256, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) ) ) (5): ConvTranspose2d(256, 128, kernel_size=(4, 4), stride=(2, 2), padding=(1, 1)) (6): InstanceNorm2d(128, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) (7): PReLU(num_parameters=1) (8): ConvTranspose2d(128, 64, kernel_size=(4, 4), stride=(2, 2), padding=(1, 1)) (9): InstanceNorm2d(64, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) (10): PReLU(num_parameters=1) (11): ReflectionPad2d((3, 3, 3, 3)) (12): Conv2d(64, 3, kernel_size=(7, 7), stride=(1, 1)) (13): Tanh() ) ) Created 2 Encoder-Decoder pairs Number of parameters per Encoder: 5099143 Number of parameters per Deocder: 6565770

AAnoosheh commented 5 years ago

You gave argument --dataroot ./datasets/train1

Your dataroot is actually ./datasets

:)

VPRzhou commented 5 years ago

Thank you your reply.But I am not clear what you say. Do you mean I should make a change to the dataroot? I totally run the code as you said,but I do not know the reason why it doesn't work.

AAnoosheh commented 5 years ago

Data root is the root of all data folders. The code looks in the data root for folders named train and test

The code errors because it probably found zero folders under test1 that starts with "train" or "test"

VPRzhou commented 5 years ago

oh,the dataroot structure should be:datasets/train/train0&train1,is it right?

AAnoosheh commented 5 years ago

When training, train0 & train1 should be in the data root. (Any folder can be the data root)

When testing, test0 and test1 should be in the data root.

The data root can be the same for both. So all trains and tests can be together inside the dataroot, i.e. DATAROOT/train0+train1+test0+test1

VPRzhou commented 5 years ago

Thank you very much,I got it. It works now!

VPRzhou commented 5 years ago

Hi,I have to bother you again.As TABLE I shown,how can I get the night training dataset(6666 triplets).

AAnoosheh commented 5 years ago

Hi, the link to the curated dataset I used is in the README