Real-ESRGAN
Real-ESRGAN copied to clipboard
ValueError: ('Scale mismatches. GT (3078, 5472) is not 4x ', 'multiplication of LQ (1080, 1624).')
Thanks for the great projects!
i have a problem with training finetune paired data using finetune_realesrgan_x4plus_pairdata.yml.
and i don't know how to solve this problem.
Note that in the config file ( finetune_realesrgan_x4plus_pairdata.yml) that is present under the options folder, the scale is set as 4 by default. In your case, the dimensions of GT are not 4 times the dimensions of LQ. Dimensions of GT should be (1080 x 4 = 4320, 1624 x 4 = 6496) i.e. (4320,6496). Try using the below code to modify the dimensions of GT: -
import os from PIL import Image
GT_folder = 'Path/to/GT' output_folder = 'Path/to/GT_resized' target_width = 4320 target_height = 6496
Create the output folder if it doesn't exist
os.makedirs(output_folder, exist_ok=True)
Iterate over the images in the LR folder
for filename in os.listdir(lr_folder): # Open the image image_path = os.path.join(lr_folder, filename) image = Image.open(image_path)
# Resize the image
resized_image = image.resize((target_width, target_height), Image.BICUBIC)
# Save the resized image to the output folder
output_path = os.path.join(output_folder, filename)
resized_image.save(output_path)
print(f"Resized image saved: {output_path}")
Hope this helps!
Note that in the config file ( finetune_realesrgan_x4plus_pairdata.yml) that is present under the options folder, the scale is set as 4 by default. In your case, the dimensions of GT are not 4 times the dimensions of LQ. Dimensions of GT should be (1080 x 4 = 4320, 1624 x 4 = 6496) i.e. (4320,6496). Try using the below code to modify the dimensions of GT: -
import os from PIL import Image
GT_folder = 'Path/to/GT' output_folder = 'Path/to/GT_resized' target_width = 4320 target_height = 6496
Create the output folder if it doesn't exist
os.makedirs(output_folder, exist_ok=True)
Iterate over the images in the LR folder
for filename in os.listdir(lr_folder): # Open the image image_path = os.path.join(lr_folder, filename) image = Image.open(image_path)
# Resize the image resized_image = image.resize((target_width, target_height), Image.BICUBIC) # Save the resized image to the output folder output_path = os.path.join(output_folder, filename) resized_image.save(output_path) print(f"Resized image saved: {output_path}")
Hope this helps!
thanks! I already solved this problem.
Note that in the config file ( finetune_realesrgan_x4plus_pairdata.yml) that is present under the options folder, the scale is set as 4 by default. In your case, the dimensions of GT are not 4 times the dimensions of LQ. Dimensions of GT should be (1080 x 4 = 4320, 1624 x 4 = 6496) i.e. (4320,6496). Try using the below code to modify the dimensions of GT: - import os from PIL import Image GT_folder = 'Path/to/GT' output_folder = 'Path/to/GT_resized' target_width = 4320 target_height = 6496
Create the output folder if it doesn't exist
os.makedirs(output_folder, exist_ok=True)
Iterate over the images in the LR folder
for filename in os.listdir(lr_folder): # Open the image image_path = os.path.join(lr_folder, filename) image = Image.open(image_path)
# Resize the image resized_image = image.resize((target_width, target_height), Image.BICUBIC) # Save the resized image to the output folder output_path = os.path.join(output_folder, filename) resized_image.save(output_path) print(f"Resized image saved: {output_path}")
Hope this helps!
thanks! I already solved this problem.
can i ask how?