aalmah / augmented_cyclegan

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Modifying input size

doantientai opened this issue · comments

Hi @aalmah

Thank you for the useful implementation. From what I see, all input images are resized to 64x64. So I change the input size up to 128, or 256 by modifying the line 235 in the file edges2shoes_exp/edges2shoes_data.py from
transform_list = [transforms.Scale([64, 64], Image.BICUBIC)]
to
transform_list = [transforms.Scale([128, 128], Image.BICUBIC)]
However, the program complained like below:

Traceback (most recent call last):
File "/media/tai/6TB/Projects/augmented_cyclegan/edges2shoes_exp/train.py", line 315, in
train_model()
File "/media/tai/6TB/Projects/augmented_cyclegan/edges2shoes_exp/train.py", line 204, in train_model
losses, visuals, gnorms = model.train_instance(real_A, real_B, prior_z_B)
File "/media/tai/6TB/Projects/augmented_cyclegan/edges2shoes_exp/model.py", line 430, in train_instance
discriminate(self.netD_z_B, self.criterionGAN, post_z_realB.detach(), prior_z_B)
File "/media/tai/6TB/Projects/augmented_cyclegan/edges2shoes_exp/model.py", line 328, in discriminate
pred_fake = net(fake)
File "/home/tai/anaconda3/envs/pytorch_p2/lib/python2.7/site-packages/torch/nn/modules/module.py", line 491, in call
result = self.forward(*input, **kwargs)
File "/media/tai/6TB/Projects/augmented_cyclegan/edges2shoes_exp/networks.py", line 428, in forward
input = input.view(input.size(0), self.nlatent)
RuntimeError: invalid argument 2: size '[2 x 16]' is invalid for input with 800 elements at /opt/conda/conda-bld/pytorch_1525812548180/work/aten/src/TH/THStorage.c:41

Process finished with exit code 1

I guess there is computation making the latent size to be related to image size. That's why when I change the input image's size, it affect the latent vector.

Please help!

This is because the network settings are set to a 64x64 image size.
In the discriminator and encoder, the size of the feature map is reduced by half using the conv layer. (with stride 2)
What if you increase the size of the image? Naturally, the end result will be different from the desired size.
Add a conv layer to the encoder and discriminator.

Thank you @MakeDirtyCode. I also found out that. I fix it by applying a max_pooling layer.