pix2pixHD icon indicating copy to clipboard operation
pix2pixHD copied to clipboard

Instance map shape

Open Rubiel1 opened this issue 4 years ago • 7 comments

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.

Rubiel1 avatar Mar 21 '20 14:03 Rubiel1

Same question! Have you fixed it?

1999kevin avatar Mar 30 '21 11:03 1999kevin

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 avatar Mar 30 '21 11:03 1999kevin

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

1999kevin avatar Mar 31 '21 08:03 1999kevin

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?

caffecoffee avatar May 20 '22 03:05 caffecoffee

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

zhangxiaojuan66 avatar May 20 '22 03:05 zhangxiaojuan66

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.

1999kevin avatar May 24 '22 01:05 1999kevin

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

caffecoffee avatar May 24 '22 03:05 caffecoffee