NVIDIA / pix2pixHD

Synthesizing and manipulating 2048x1024 images with conditional GANs
https://tcwang0509.github.io/pix2pixHD/
Other
6.67k stars 1.39k forks source link

Training 4 channel images #172

Closed vnyk-dgrid closed 4 years ago

vnyk-dgrid commented 4 years ago

I want to train 4 channel images bellow is my train command

python train.py --name train_w_orient_alpha --dataroot ../pix2pixHD/train_data_new/ --label_nc 0 --loadSize 512 --fineSize 512 --no_instance --gpu_ids 0,1,2,3 --input_nc 4 --output_nc 4 --batchSize 12

I am getting the following error


File "train.py", line 71, in <module>
    Variable(data['image']), Variable(data['feat']), infer=save_fake)
  File "/opt/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in __call__
    result = self.forward(*input, **kwargs)
  File "/opt/anaconda3/lib/python3.6/site-packages/torch/nn/parallel/data_parallel.py", line 123, in forward
    outputs = self.parallel_apply(replicas, inputs, kwargs)
  File "/opt/anaconda3/lib/python3.6/site-packages/torch/nn/parallel/data_parallel.py", line 133, in parallel_apply
    return parallel_apply(replicas, inputs, kwargs, self.device_ids[:len(replicas)])
  File "/opt/anaconda3/lib/python3.6/site-packages/torch/nn/parallel/parallel_apply.py", line 77, in parallel_apply
    raise output
  File "/opt/anaconda3/lib/python3.6/site-packages/torch/nn/parallel/parallel_apply.py", line 53, in _worker
    output = module(*input, **kwargs)
  File "/opt/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/hairgen/hairgen/pix2pixHDnew/models/pix2pixHD_model.py", line 221, in forward
    loss_G_VGG = self.criterionVGG(fake_image, real_image) * self.opt.lambda_feat
  File "/opt/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/hairgen/hairgen/pix2pixHDnew/models/networks.py", line 120, in forward
    x_vgg, y_vgg = self.vgg(x), self.vgg(y)
  File "/opt/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/hairgen/hairgen/pix2pixHDnew/models/networks.py", line 410, in forward
    h_relu1 = self.slice1(X)
  File "/opt/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in __call__
    result = self.forward(*input, **kwargs)
  File "/opt/anaconda3/lib/python3.6/site-packages/torch/nn/modules/container.py", line 91, in forward
    input = module(input)
  File "/opt/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in __call__
    result = self.forward(*input, **kwargs)
  File "/opt/anaconda3/lib/python3.6/site-packages/torch/nn/modules/conv.py", line 301, in forward
    self.padding, self.dilation, self.groups)
RuntimeError: Given groups=1, weight of size [64, 3, 3, 3], expected input[3, 4, 512, 512] to have 3 channels, but got 4 channels instead

I have also tried using the solution in #119 https://github.com/NVIDIA/pix2pixHD/issues/119#issuecomment-485658463 But it doesnt worked

vishwas1234567 commented 4 years ago

just go to the kernel and check for the version and also it would be the error from the malfunctioning of the drivers.

On Fri, 10 Jan 2020 at 16:17, vnyk-dgrid notifications@github.com wrote:

I want to train 4 channel images bellow is my train command

python train.py --name train_w_orient_alpha --dataroot ../pix2pixHD/train_data_new/ --label_nc 0 --loadSize 512 --fineSize 512 --no_instance --gpu_ids 0,1,2,3 --input_nc 4 --output_nc 4 --batchSize 12

I am getting the following error

File "train.py", line 71, in Variable(data['image']), Variable(data['feat']), infer=save_fake) File "/opt/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call result = self.forward(*input, kwargs) File "/opt/anaconda3/lib/python3.6/site-packages/torch/nn/parallel/data_parallel.py", line 123, in forward outputs = self.parallel_apply(replicas, inputs, kwargs) File "/opt/anaconda3/lib/python3.6/site-packages/torch/nn/parallel/data_parallel.py", line 133, in parallel_apply return parallel_apply(replicas, inputs, kwargs, self.device_ids[:len(replicas)]) File "/opt/anaconda3/lib/python3.6/site-packages/torch/nn/parallel/parallel_apply.py", line 77, in parallel_apply raise output File "/opt/anaconda3/lib/python3.6/site-packages/torch/nn/parallel/parallel_apply.py", line 53, in _worker output = module(*input, *kwargs) File "/opt/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call result = self.forward(input, kwargs) File "/home/hairgen/hairgen/pix2pixHDnew/models/pix2pixHD_model.py", line 221, in forward loss_G_VGG = self.criterionVGG(fake_image, real_image) self.opt.lambda_feat File "/opt/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call result = self.forward(input, kwargs) File "/home/hairgen/hairgen/pix2pixHDnew/models/networks.py", line 120, in forward x_vgg, y_vgg = self.vgg(x), self.vgg(y) File "/opt/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call result = self.forward(*input, *kwargs) File "/home/hairgen/hairgen/pix2pixHDnew/models/networks.py", line 410, in forward h_relu1 = self.slice1(X) File "/opt/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call result = self.forward(input, kwargs) File "/opt/anaconda3/lib/python3.6/site-packages/torch/nn/modules/container.py", line 91, in forward input = module(input) File "/opt/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call result = self.forward(*input, **kwargs) File "/opt/anaconda3/lib/python3.6/site-packages/torch/nn/modules/conv.py", line 301, in forward self.padding, self.dilation, self.groups) RuntimeError: Given groups=1, weight of size [64, 3, 3, 3], expected input[3, 4, 512, 512] to have 3 channels, but got 4 channels instead

I have also tried using the solution in #119 https://github.com/NVIDIA/pix2pixHD/issues/119

119 (comment)

https://github.com/NVIDIA/pix2pixHD/issues/119#issuecomment-485658463 But it doesnt worked

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/NVIDIA/pix2pixHD/issues/172?email_source=notifications&email_token=ALSXLORTHYBS66M7MYYFVJ3Q5BG3HA5CNFSM4KFF4KNKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IFJ5NWQ, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALSXLOVEQE36RZIUQPWFXZDQ5BG3HANCNFSM4KFF4KNA .

vnyk-dgrid commented 4 years ago

@vishwas1234567 No , the problem is not with the drivers or dependencies

WayneCho commented 4 years ago

I think this error is raise because the VGG loss can only compute among three-channel images, in my application I can convert the four channel image to three channel. If cannot convert, can also simply set the option '--no_vgg_loss' as True.

AndyRylynn commented 1 month ago

Could I ask how do you solve this problem that using this code to train 4channel DNG? It really confuses me when I want to train my datasets.

zhangxiaojuan66 commented 1 month ago

你好,邮件已收到,祝你万事如意,生活愉快!