PD-Denoising-pytorch
PD-Denoising-pytorch copied to clipboard
Validation in training loop - dimensionality problems
Hi! I uncommented the "eval" part in the training loop, and want to use it for validation during training (with color images). However, I get one of two errors:
Because of the line: noise_map_val = np.zeros((1, 2*c, img_w, img_h))
In the code
The marked line causes a dimension error, as it tries to input a 3 channel image into a 6 channel tensor (as defined above with 2*c).
Otherwise, if I change the above line to noise_map_val = np.zeros((1, 1*c, img_w, img_h))
The line out_val_nb = torch.clamp( imgn_val - model(imgn_val, NM_tensor_val), 0., 1.) Fails, because NM_tensor val has 3 channels and not 6.
What is the right way to input 6 channels into the generated noise map from 3 channels?
Thanks, Tom
Hi Tom, the codes are very old so I am not sure whether my answer will address your problem. Basically, in the paper we used two noise types: AWGN and RVIN, so the noise map contains 6 channels (RGB for AWGN and RGB for RVIN).
I guess the commented validation codes are deprecated and it only generates one single type AWGN noise levels. It's better to refer https://github.com/yzhouas/PD-Denoising-pytorch/blob/master/train.py#L111-L133 to generate the validation noise level maps.
The codes are not clean enough and sorry for causing so many troubles.
Hi Yuqian,
first of all thanks for the quick reply!
I replaced the deprecated commands with newer versions. In the meantime I just replicated the 3 channel generated noise map twice so it fits the 6 channels, and the code runs now. I'll review the lines you pointed to and try to adjust.
BTW, I see that "parepare_data" can create a validation data loader as well. I guess that if I want to use it for validation instead of just running on files in the val folder I'll have to write the validation loop myself, right?
Thanks again, Tom