I am getting an error in "real_esrgan_notebook.ipynb" file
the code is :
import cv2
from tqdm import tqdm
from skimage.metrics import structural_similarity as ssim
from skimage.metrics import peak_signal_noise_ratio as psnr
from skimage.transform import rescale
import matplotlib
array_psnr.append(val_psnr)
array_ssim.append(val_ssim)
array_nrm.append(val_nrm)
array_mae.append(val_mae)
array_vif.append(val_vif)
.
.
.
The error I am getting is:
.
0%| | 0/1006 [00:00<?, ?it/s]
IndexError Traceback (most recent call last)
in
32
33 data_orig = ground_truth[i][:,:,0]
---> 34 data_lr = lq_image[i][:,:,0]
35 #The order of interpolation. The order has to be in the range 0-5:
36 # - 0: Nearest-neighbor
IndexError: too many indices for array: array is 2-dimensional, but 3 were indexed
I am getting an error in "real_esrgan_notebook.ipynb" file
the code is :
import cv2 from tqdm import tqdm
from skimage.metrics import structural_similarity as ssim from skimage.metrics import peak_signal_noise_ratio as psnr from skimage.transform import rescale import matplotlib
slce_ds = rescale(slce, scale=(0.25, 0.25)) #skimage rescale
dim = (256, 256)
array_psnr = [] array_ssim = [] array_nrm = [] array_mae = [] array_vif = []
array_psnr_linear = [] array_ssim_linear = [] array_nrm_linear = [] array_mae_linear = [] array_vif_linear = []
array_psnr_cubic = [] array_ssim_cubic = [] array_nrm_cubic = [] array_mae_cubic = [] array_vif_cubic = [] k = 0
for i in tqdm(range(len(ground_truth))):
data_orig = ground_truth[i][:,:,0] data_lr = lq_image[i][:,:,0]
The order of interpolation. The order has to be in the range 0-5:
- 0: Nearest-neighbor
- 1: Bi-linear (default)
- 2: Bi-quadratic
- 3: Bi-cubic
- 4: Bi-quartic
- 5: Bi-quintic
x_temp_linear = rescale(data_lr, scale=(4, 4), order = 1) x_temp_linear = x_temp_linear.astype(np.float32) x_temp_linear = (x_temp_linear-np.min(x_temp_linear))/(np.max(x_temp_linear)-np.min(x_temp_linear))
val_psnr_linear = psnr(data_orig, x_temp_linear, data_range = x_temp_linear.max() - x_temp_linear.min()) val_ssim_linear = ssim(data_orig, x_temp_linear, data_range = x_temp_linear.max() - x_temp_linear.min())
val_mae_linear = mean_abs_err(data_orig, x_temp_linear) val_nrm_linear = nrmdiff(data_orig, x_temp_linear) val_vif_linear = vifp(data_orig, x_temp_linear)
x_temp_cubic = rescale(data_lr, scale=(4, 4), order = 3) x_temp_cubic = x_temp_cubic.astype(np.float32) x_temp_cubic = (x_temp_cubic-np.min(x_temp_cubic))/(np.max(x_temp_cubic)-np.min(x_temp_cubic))
val_psnr_cubic = psnr(data_orig, x_temp_cubic, data_range = x_temp_cubic.max() - x_temp_cubic.min()) val_ssim_cubic = ssim(data_orig, x_temp_cubic, data_range = x_temp_cubic.max() - x_temp_cubic.min()) val_mae_cubic = mean_abs_err(data_orig, x_temp_cubic) val_nrm_cubic = nrmdiff(data_orig, x_temp_cubic) val_vif_cubic = vifp(data_orig, x_temp_cubic)
data_gen = generated_realesrgan[i,:,:] data_gen = data_gen.astype(np.float32) data_gen = (data_gen-np.min(data_gen))/(np.max(data_gen)-np.min(data_gen))
val_psnr = psnr(data_orig, data_gen, data_range = data_gen.max() - data_gen.min()) val_ssim = ssim(data_orig, data_gen, data_range = data_gen.max() - data_gen.min()) val_mae = mean_abs_err(data_orig, data_gen) val_nrm = nrmdiff(data_orig, data_gen) val_vif = vifp(data_orig, data_gen)
array_psnr_linear.append(val_psnr_linear) array_ssim_linear.append(val_ssim_linear) array_nrm_linear.append(val_nrm_linear) array_mae_linear.append(val_mae_linear) array_vif_linear.append(val_vif_linear)
array_psnr_cubic.append(val_psnr_cubic) array_ssim_cubic.append(val_ssim_cubic) array_nrm_cubic.append(val_nrm_cubic) array_mae_cubic.append(val_mae_cubic) array_vif_cubic.append(val_vif_cubic)
array_psnr.append(val_psnr) array_ssim.append(val_ssim) array_nrm.append(val_nrm) array_mae.append(val_mae) array_vif.append(val_vif) . . . The error I am getting is:
.
0%| | 0/1006 [00:00<?, ?it/s]
IndexError Traceback (most recent call last) in
32
33 data_orig = ground_truth[i][:,:,0]
---> 34 data_lr = lq_image[i][:,:,0]
35 #The order of interpolation. The order has to be in the range 0-5:
36 # - 0: Nearest-neighbor
IndexError: too many indices for array: array is 2-dimensional, but 3 were indexed