learn-optimizer-rgdn
learn-optimizer-rgdn copied to clipboard
I want to test on Levin, However, the results seem to be failed.
Can you give me some suggestions? `
for im_index in range(4): gt_name = r'data/levin_data/img_%d.png' % (im_index + 1) gt = cv2.imread(gt_name,0) gt = gt / 255 # gt= gty[..., np.newaxis] # gt = np.concatenate([gt,gt,gt],axis=2) for ker_index in range(8): im_name = r'data/levin_data/im_%d_ker_%d.png' % (im_index + 1, ker_index + 1) ker_name = r'data/levin_data/kernel_%d.dlm' % (ker_index + 1) ker = np.loadtxt(ker_name).astype(np.float) ker = np.clip(ker, 0, 1) ker = ker / np.sum(ker) y =cv2.imread(im_name)/255.0 # y = ndimage.convolve(gt, ker, mode='wrap') np.random.seed(1512818945) y = y y = np.clip(y, 0, 1.0) y = ((y * 255.0).astype(np.uint8) / 255.0).astype(np.float32)
# y = np.concatenate([y,y,y],axis=2)
# y = y+ test_sigma * np.random.standard_normal(size=y.shape)
y = to_tensor(y,device)
x = to_tensor(gt,device)
k = to_tensor(ker,device)
kt =torch.flip(k, [1, 2])
y, kt, k = y.to(device), kt.to(device), k.to(device)
k_size = k.size()[2]
padding_size = int((k_size / 2) * 1.5)
y = conv2d_same_padding(x, k).to(device)
# nl = np.random.uniform(0.003, 0.015)
y = y + 0.01 * torch.randn_like(y).to(device)
y = torch.clamp(y * 255.0, 0, 255)
y = y.type(torch.ByteTensor)
y = y.float() / 255.0
y = y.to(device)
y = torch.nn.functional.pad(y, [padding_size, padding_size, padding_size, padding_size], mode='replicate')
start = time.time()
y = torch.cat([y,y,y],dim=1)
output_seq = trained_model(y, k, kt)
# output_len = len(output_seq)
x_final = output_seq[-1]
# print('Time {}'.format(time.time() - start))
##
# if (opt.ImgPad):
y = utils.truncate_image(y, padding_size)
x_final = utils.truncate_image(x_final, padding_size)
x_est_np = x_final.cpu()
print(np.shape(x_est_np))
x_est_np = utils.tensor_to_np_img(x_est_np)
#
x_est_np = utils.box_proj(x_est_np)
# sample_name_full = sample_name[0]
# sample_name = sample_name_full[0:len(sample_name_full) - 4]
x_est_np = np.array(x_est_np).astype(np.float)
PSNR_list.append(psnr(gt,x_est_np[:,:,0]))
SSIM_list.append(compute_ssim(gt,x_est_np[:,:,0],L=1.0))
# sio.savemat(outpath + sample_name + '_estx.mat', {'x_est': x_est_np})
scipy.misc.imsave('./data/levin_test/' + str(im_index+1)+'_'+str(ker_index+1) + '_estx.png', x_est_np * 255)
torch.cuda.empty_cache()
`
@donggong1 Thanks
On the gray scale of levin, the test results are 10.92dB and 0.085 SSIM