NVIDIA / pix2pixHD

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

Instance map shape #188

Open Rubiel1 opened 4 years ago

Rubiel1 commented 4 years ago

Hi I have this error on my custom dataset:

RuntimeError: Caught RuntimeError in DataLoader worker process 0. Original Traceback (most recent call last): File "/home/ericd/anaconda3/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py", line 178, in _worker_loop data = fetcher.fetch(index) File "/home/ericd/anaconda3/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "/home/ericd/anaconda3/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp> data = [self.dataset[idx] for idx in possibly_batched_index] File "/home/ericd/test/pix2pixHD/data/aligned_dataset.py", line 59, in __getitem__ inst_tensor = transform_A(inst) File "/home/ericd/anaconda3/lib/python3.8/site-packages/torchvision/transforms/transforms.py", line 70, in __call__ img = t(img) File "/home/ericd/anaconda3/lib/python3.8/site-packages/torchvision/transforms/transforms.py", line 175, in __call__ return F.normalize(tensor, self.mean, self.std, self.inplace) File "/home/ericd/anaconda3/lib/python3.8/site-packages/torchvision/transforms/functional.py", line 218, in normalize tensor.sub_(mean[:, None, None]).div_(std[:, None, None]) RuntimeError: output with shape [1, 352, 304] doesn't match the broadcast shape [3, 352, 304]

The instance data has one channel, but the A and B dataset have 3 channels. Is the instance suppose to have 3 channels as well? to test I added the no instance flat and it is working. But since I have the instance information I want to use it.

1999kevin commented 3 years ago

Same question! Have you fixed it?

1999kevin commented 3 years ago

I have tried to make a 3-channel instance data by simply converting the gray map to its RGB map. But it doesn't work.

1999kevin commented 3 years ago

Solved it by generating 3-channel instance and setting input_nc to 5

caffecoffee commented 2 years ago

Solved it by generating 3-channel instance and setting input_nc to 5

@1999kevin 3-channel input +3-channel instanse,why setting input_nc to5 is ok?

zhangxiaojuan66 commented 2 years ago

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

1999kevin commented 2 years ago

Solved it by generating 3-channel instance and setting input_nc to 5

@1999kevin 3-channel input +3-channel instanse,why setting input_nc to5 is ok?

No clear idea about this since it is such a long time... I guess the model would add one more channel automatically somewhere.

caffecoffee commented 2 years ago

@1999kevin Absolutely! if not opt.no_instance: netD_input_nc += 1. Thanks!