DiffIR icon indicating copy to clipboard operation
DiffIR copied to clipboard

inference_diffir.py 参数model_path问题

Open zhaolitc opened this issue 10 months ago • 2 comments

您好,请问对于SRGAN 的inference_diffir --model_path 参数,我下载了三个权重文件:SISR-DiffIRS1.pth,SISR-DiffIRS2.pth,SISR-DiffIRS2-GAN.pth,无论选择哪个都会报错: anaconda3/envs/dfrsc/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1667, in load_state_dict raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format( RuntimeError: Error(s) in loading state_dict for DiffIRS2: size mismatch for G.patch_embed.proj.weight: copying a param with shape torch.Size([64, 3, 3, 3]) from checkpoint, the shape in current model is torch.Size([64, 12, 3, 3]). size mismatch for condition.E.0.weight: copying a param with shape torch.Size([64, 3, 3, 3]) from checkpoint, the shape in current model is torch.Size([64, 12, 3, 3]). size mismatch for diffusion.condition.E.0.weight: copying a param with shape torch.Size([64, 3, 3, 3]) from checkpoint, the shape in current model is torch.Size([64, 12, 3, 3]). 请问除了使用test.sh外,进行无gt的测试时,如何选择权重文件作为--model_path的参数。谢谢!

zhaolitc avatar Feb 27 '25 12:02 zhaolitc

you should set args.scale to 2

Zj-BinXia avatar Feb 27 '25 12:02 Zj-BinXia

Yes, I check the scale arguments is 2, : CUDA_VISIBLE_DEVICES=1 python inference_diffir.py --scale 2 --model_path ./experiments/SISR-DiffIRS2-GAN.pth, but still not works: Traceback (most recent call last): File "/home/ps/PycharmProjects/DiffIR/DiffIR-SRGAN/inference_diffir.py", line 46, in <module> model.load_state_dict(loadnet['params_ema'], strict=True) File "/home/ps/anaconda3/envs/dfrsc/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1667, in load_state_dict raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format( RuntimeError: Error(s) in loading state_dict for DiffIRS2: size mismatch for G.patch_embed.proj.weight: copying a param with shape torch.Size([64, 3, 3, 3]) from checkpoint, the shape in current model is torch.Size([64, 12, 3, 3]). size mismatch for condition.E.0.weight: copying a param with shape torch.Size([64, 3, 3, 3]) from checkpoint, the shape in current model is torch.Size([64, 12, 3, 3]). size mismatch for diffusion.condition.E.0.weight: copying a param with shape torch.Size([64, 3, 3, 3]) from checkpoint, the shape in current model is torch.Size([64, 12, 3, 3])..

But I try to set scale to 4, it works. Thank you for your kindly reply!

zhaolitc avatar Feb 27 '25 12:02 zhaolitc