1)在运行esrgcnn代码的过程中遇到了些许的坑,最难解决的、也是最后一个困难终于算是解决了。
2)在运行代码测试自己的图片时候,一直报错:
Output 1 of SplitWithSizesBackward0 is a view and is being modified inplace. This view is the output of a function that returns multiple views. Such functions do not allow the output views to be modified inplace. You should replace the inplace operation by an out-of-place one.
复制粘贴到百度后,仔细研读各位大佬的代码后,解决了这个问题。
!!!我严格按照代码里的readme文档重新安装了软件
!!!我分析了tcw_sample_b.py中的代码。发现了确实有一个变量有些许问题,就做了稍许修改。
for step, (hr, lr, name) in enumerate(dataset):
if "DIV2K" in dataset.name:
t1 = time.time()
h, w = lr.size()[1:]
h_half, w_half = int(h/2), int(w/2)
h_chop, w_chop = h_half + cfg.shave, w_half + cfg.shave
%%%%%%%%%%%%%%%%%%%%%%%%%%
lr=lr_patch
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
lr_patch = torch.tensor((4, 3, h_chop, w_chop), dtype=torch.float)
lr_patch[0].copy_(lr[:, 0:h_chop, 0:w_chop])
lr_patch[1].copy_(lr[:, 0:h_chop, w-w_chop:w])
lr_patch[2].copy_(lr[:, h-h_chop:h, 0:w_chop])
lr_patch[3].copy_(lr[:, h-h_chop:h, w-w_chop:w])
lr_patch = lr_patch.to(device)
添加了一行lr=lr_patch,加上新版本的代码,就可以正常运行啦。输出结果如下:
python tcw_sample_b.py --model esrgcnn --test_data_dir dataset/Set5 --scale 2 --ckpt_path checkpoint/esrgcnn.pth --sample_dir samples_singlemodel_urban100_x2
{
"ckpt_path": "checkpoint/esrgcnn.pth",
"cuda": false,
"group": 1,
"model": "esrgcnn",
"sample_dir": "samples_singlemodel_urban100_x2",
"scale": 2,
"shave": 20,
"test_data_dir": "dataset/Set5"
}
('img_001_SRF_2_HR.png', 38.75975078879017, 0.9661591341475728)
('img_002_SRF_2_HR.png', 42.86924067767056, 0.9891173914544316)
('img_003_SRF_2_HR.png', 35.15641205205168, 0.9767552401292521)
('img_004_SRF_2_HR.png', 35.94780702489556, 0.8894667598159965)
('img_005_SRF_2_HR.png', 36.23858183086506, 0.9730289258091539)
(37.794358474854604, 0.9589054902712815)