<jupyter_start><jupyter_text>Generate whole super resolution image<jupyter_code>f= h5py.File('/scratch/gilbreth/li3120/RDB/Test_Result/B100_18.h5', "r")
rec=f['rec']
gt=f['gt']
np.shape(gt[9])
len(rec)
np.shape(gt)
#B100 x4 593-616
img=np.squeeze(rec[10,:,:,:])
imgg=np.squeeze(gt[10,:,:,:])
limage=np.zeros((64*5,64*7,3))
limagg=np.zeros((64*5,64*7,3))
ave_ssim=np.zeros((24,1))
ave_psnr=np.zeros((24,1))
for i in range(593,617):
    limage[(i-593)//6*64:(i-593)//6*64+64,(i-593)%6*64:(i-593)%6*64+64,:]=np.squeeze(rec[i,:64,:64,:])
    limagg[(i-593)//6*64:(i-593)//6*64+64,(i-593)%6*64:(i-593)%6*64+64,:]=np.squeeze(gt[i,:64,:64,:])
    #ave_ssim[i-593]=compare_ssim(rgb2ycbcr(np.clip(img,a_min=0,a_max=1)),rgb2ycbcr(imgg))
    #ave_psnr[i-593]=compare_ssim(rgb2ycbcr(np.clip(img,a_min=0,a_max=1)),rgb2ycbcr(imgg))
limage[0:128,5*64:,:]=np.squeeze(rec[598,:,:,:])
limage[64:64+128,5*64:,:]=np.squeeze(rec[604,:,:,:])
limage[128:128+128,5*64:,:]=np.squeeze(rec[610,:,:,:])
limage[192:192+128,5*64:,:]=np.squeeze(rec[616,:,:,:])
limage[192:192+128,:128,:]=np.squeeze(rec[611,:,:,:])
limage[192:192+128,64:64+128,:]=np.squeeze(rec[612,:,:,:])
limage[192:192+128,128:128+128,:]=np.squeeze(rec[613,:,:,:])
limage[192:192+128,192:192+128,:]=np.squeeze(rec[614,:,:,:])
limagg[0:128,5*64:,:]=np.squeeze(gt[598,:,:,:])
limagg[64:64+128,5*64:,:]=np.squeeze(gt[604,:,:,:])
limagg[128:128+128,5*64:,:]=np.squeeze(gt[610,:,:,:])
limagg[192:192+128,5*64:,:]=np.squeeze(gt[616,:,:,:])
limagg[192:192+128,:128,:]=np.squeeze(gt[611,:,:,:])
limagg[192:192+128,64:64+128,:]=np.squeeze(gt[612,:,:,:])
limagg[192:192+128,128:128+128,:]=np.squeeze(gt[613,:,:,:])
limagg[192:192+128,192:192+128,:]=np.squeeze(gt[614,:,:,:])
plt.imshow(np.clip(limage,0,1))
scipy.misc.imsave('13.jpg', np.clip(limage,0,1))
plt.imshow(np.clip(limagg,0,1))
scipy.misc.imsave('gt.jpg', np.clip(limagg,0,1))
ltl=rescale(limagg, 1.0/4, order=3,preserve_range=True)
ltt=rescale(ltl, 4, order=3,preserve_range=True)
plt.imshow(np.clip(ltt,0,1))
scipy.misc.imsave('bicubic.jpg', np.clip(ltt,0,1))<jupyter_output>/apps/cent7/anaconda/5.1.0-py36-new/lib/python3.6/site-packages/ipykernel_launcher.py:2: DeprecationWarning: `imsave` is deprecated!
`imsave` is deprecated in SciPy 1.0.0, and will be removed in 1.2.0.
Use ``imageio.imwrite`` instead.<jupyter_text>Test<jupyter_code>img1=rgb2ycbcr(np.clip(limage,a_min=0,a_max=1))
imgg1=rgb2ycbcr(limagg)
compare_psnr(img1,imgg1)
img1=rgb2ycbcr(np.clip(img,a_min=0,a_max=1))
imgg1=rgb2ycbcr(imgg)
compare_psnr(img1,imgg1)
np.shape(img)
plt.imshow(np.clip(img,a_min=0,a_max=1))
compare_ssim(np.clip(img,a_min=0,a_max=1),imgg,multichannel=True)
compare_psnr(img[3:-3],imgg[3:-3])
img1=rgb2ycbcr(np.clip(img,a_min=0,a_max=1))
imgg1=rgb2ycbcr(imgg)
diff=img1-imgg1
diff=diff[3:-3,3:-3]
-10 * np.log10( np.mean(diff**2))
compare_psnr(img1,imgg1)
f= h5py.File('/scratch/gilbreth/li3120/dataset/DIV2K_train_HR/Train/train_x3_DN.h5', "r")
label5=f['label']
imgl=np.squeeze(label5[11,:,:,:])
plt.imshow(imgl)
input5=f['input']
img2=np.squeeze(input5[11,:,:,:])
plt.imshow(img2)
f.close()
f= h5py.File('/scratch/gilbreth/li3120/RDB/Test_Result/Set5_11_1.h5', "r")
rec=f['rec']
gt=f['gt']
Ave_ssim=np.zeros((len(gt),1))
Ave_psnr=np.zeros((len(gt),1))
def rgb2ycbcr (img):
    y = 16 + (65.481 * img[:, :, 0]) + (128.553 * img[:, :, 1]) + (24.966 * img[:, :, 2])
    return y / 255
for i in range(len(gt)):
    img=np.squeeze(rec[i,:,:,:])
    imgg=np.squeeze(gt[i,:,:,:])
    img=np.clip(img,a_min=0,a_max=1)
    img=rgb2ycbcr(img)
    imgg=rgb2ycbcr(imgg)
    Ave_ssim[i]=compare_ssim(img,imgg)
    Ave_psnr[i]=compare_psnr(img,imgg)
print('average ssim:%f'%(np.mean(Ave_ssim)))
print('average psnr:%f'%(np.mean(Ave_psnr)))
f.close()<jupyter_output>average ssim:0.942170
average psnr:32.360419
{'fraction_non_alphanumeric': 0.26916975145425703, 'fraction_numerical': 0.1427815970386039, 'mean_word_length': 9.479224376731302, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '544758', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 2337, 'n_tokens_neox': 2049, 'n_words': 149, 'path': 'Utils_test.ipynb', 'repo_name': 'DamonLee5/RDN-SR-Keras', 'size': '3782'}