python main.py --data_test Demo --scale 2 --pre_train …/experiment/model/EDSR_x2.pt --test_only --save_results
RuntimeError: While copying the parameter named head.0.weight, whose dimensions in the model are torch.Size([64, 3, 3, 3]) and whose dimensions in the checkpoint are torch.Size([256, 3, 3, 3]).
这是因为PyTorch在设置检查点时不保存模型结构。
这意味着预先训练的模型只包含参数,而不包含结构。
因此,我们必须首先构建模型来加载这些参数。
默认设置是EDSR_baseline_x4,每个层有16个resblock和64个通道。
如果您没有指定这些参数,就会发生错误,因为您试图从具有32个resblock和每个层256个通道的模型加载参数。
You have to put additional arguments(–n_resblocks, --n_feats, and --res_scale) to test that model.
Please refer to this line!
Also, I recommend you to use --chop argument if there is any trouble with GPU memory.
Thank you.
所以要
python main.py --data_test DIV2K --ext img --n_val 100 --scale 4 --n_resblocks 32 --n_feats 256 --res_scale 0.1 --pre_train ../experiment/model/EDSR_x4.pt --test_only --self_ensemble