Traceback (most recent call last): File "run_nerf.py", line 653, in <module> train() File "run_nerf.py", line 623, in train test_ssim = compute_img_metric(rgbs, target_rgb_ldr, 'ssim')
File "/root/autodl-tmp/Deblur-NeRF/metrics.py", line 81, in compute_img_metric value, ssimmap = photometric["ssim"]( File "/root/miniconda3/lib/python3.8/site-packages/skimage/metrics/_structural_similarity.py", line 178, in structural_similarity raise ValueError( ValueError: win_size exceeds image extent. Either ensure that your images are at least 7x7; or pass win_size explicitly in the function call, with an odd value less than or equal to the smaller side of your images. If your images are multichannel (with color channels), set channel_axis to the axis number corresponding to the channels.
修改metrics.py 66行后的代码为:
for i in range(batchsz):
if metric in ["mse", "psnr"]:
if mask is not None:
im1 = im1 * mask[i]
im2 = im2 * mask[i]
value = photometric[metric](
im1[i], im2[i]
)
if mask is not None:
hei, wid, _ = im1[i].shape
pixelnum = mask[i, ..., 0].sum()
value = value - 10 * np.log10(hei * wid / pixelnum)
elif metric in ["ssim"]:
value, ssimmap = photometric["ssim"](
im1[i], im2[i], multichannel=True, full=True, channel_axis=-1, data_range=im1[i].max()-im1[i].min()
)
# Ensure win_size does not exceed image dimensions
# min_dim = min(im1[i].shape[0], im1[i].shape[1])
# win_size = min(11, min_dim) if min_dim >= 7 else 3
# value, ssimmap = photometric["ssim"](
# im1[i], im2[i], multichannel=True, full=True, win_size=win_size
# )
if mask is not None:
value = (ssimmap * mask[i]).sum() / mask[i].sum()
elif metric in ["lpips"]:
value = photometric[metric](
im1t[i:i + 1], im2t[i:i + 1]
)
else:
raise NotImplementedError
values.append(value)