huawei-noah / Pretrained-IPT

Apache License 2.0
424 stars 63 forks source link

Model Error when change the args.test_batch_size #29

Closed leeynnnn closed 1 year ago

leeynnnn commented 2 years ago

Hi,

when i try to change the args.test_batch_size to 2 or other settings (16, 32, ...) , the model doesn't work. Does the model have to evaluate with fixed test batch size=1 ?

Traceback (most recent call last): File "main.py", line 37, in main() File "main.py", line 33, in main t.test() File "/Pretrained-IPT-main/trainer.py", line 77, in test sr = self.model(nois_hr, idx_scale) File "/anaconda3/envs/pytorch1.4/lib/python3.6/site-packages/torch/nn/modules/module.py", line 532, in call result = self.forward(*input, kwargs) File "/Pretrained-IPT-main/model/init.py", line 59, in forward return forward_function(x) File "/Pretrained-IPT-main/model/init.py", line 176, in forward_chop y_h_cut = self.cut_h(x_h_cut, h, w, h_cut, w_cut, padsize, shave, scale, batchsize) File "/Pretrained-IPT-main/model/init.py", line 236, in cut_h y_h_cut_unfold.append(P.data_parallel(self.model, x_h_cut_unfold[ibatchsize:(i+1)batchsize,...], range(self.n_GPUs)).cpu()) File "/anaconda3/envs/pytorch1.4/lib/python3.6/site-packages/torch/nn/parallel/data_parallel.py", line 204, in data_parallel return module(*inputs[0], *module_kwargs[0]) File "/anaconda3/envs/pytorch1.4/lib/python3.6/site-packages/torch/nn/modules/module.py", line 532, in call result = self.forward(input, kwargs) File "/Pretrained-IPT-main/model/ipt.py", line 52, in forward x = self.sub_mean(x) File "/anaconda3/envs/pytorch1.4/lib/python3.6/site-packages/torch/nn/modules/module.py", line 532, in call result = self.forward(*input, **kwargs) File "/anaconda3/envs/pytorch1.4/lib/python3.6/site-packages/torch/nn/modules/conv.py", line 345, in forward return self.conv2d_forward(input, self.weight) File "/anaconda3/envs/pytorch1.4/lib/python3.6/site-packages/torch/nn/modules/conv.py", line 342, in conv2d_forward self.padding, self.dilation, self.groups) RuntimeError: Given groups=1, weight of size 3 3 1 1, expected input[18, 6, 48, 48] to have 3 channels, but got 6 channels instead

HantingChen commented 2 years ago

The code only support evaluation with fixed test batch size=1.