yiranran / APDrawingGAN

Code for APDrawingGAN: Generating Artistic Portrait Drawings from Face Photos with Hierarchical GANs (CVPR 2019 Oral)
Apache License 2.0
785 stars 145 forks source link

RuntimeError: The size of tensor a (3) must match the size of tensor b (9) at non-singleton dimension 0 #13

Closed wenyunqian closed 2 years ago

wenyunqian commented 4 years ago

Firstly, thanks for your excellent work! Now I am trying to train your model on my own dataset, but when I run the code, a RuntimeError appear. I am new to this area so have no idea why, the dataset I have already organized as the authors. As this: ''' /data -- the aligned data /train -- aligned train images (augmented) /test -- aligned test images /landmark -- 5 facial landmarks of train and test images /ALL -- contains all landmark files /mask -- background masks of train and test images /ALL -- contains all background masks ''' Looking forward to some help, thanks!

[Network GLMouth] Total number of parameters : 1.448 M [Network GLHair] Total number of parameters : 1.710 M [Network GLBG] Total number of parameters : 1.710 M [Network GCombine] Total number of parameters : 0.158 M

create web directory ./checkpoints/first_try/web... Traceback (most recent call last): File "/home/wen/study/destyle-transfer/APDrawingGAN/train.py", line 25, in for i, data in enumerate(dataset): File "/home/wen/study/destyle-transfer/APDrawingGAN/data/init.py", line 72, in iter for i, data in enumerate(self.dataloader): File "/home/wen/.virtualenvs/APD2/local/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 336, in next return self._process_next_batch(batch) File "/home/wen/.virtualenvs/APD2/local/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 357, in _process_next_batch raise batch.exc_type(batch.exc_msg) RuntimeError: Traceback (most recent call last): File "/home/wen/.virtualenvs/APD2/local/lib/python2.7/site-packages/torch/utils/data/dataloader.py", line 106, in _worker_loop samples = collate_fn([dataset[i] for i in batch_indices]) File "/home/wen/study/destyle-transfer/APDrawingGAN/data/aligned_dataset.py", line 188, in getitem hair_A = (A/2+0.5) mask.repeat(input_nc/output_nc,1,1) mask2.repeat(input_nc/output_nc,1,1) * 2 - 1 RuntimeError: The size of tensor a (3) must match the size of tensor b (9) at non-singleton dimension 0

yiranran commented 4 years ago

You may check the shapes of A, mask and mask2.. sorry I can't reproduce this error.