|
|
|
import os |
|
|
|
|
|
opt = {} |
|
|
|
opt['description'] = "4x_GRL_paper" |
|
|
|
opt['architecture'] = "GRL" |
|
|
|
|
|
|
|
opt['scale'] = 4 |
|
opt["full_patch_source"] = "../datasets_anime/APISR_dataset" |
|
opt["degrade_hr_dataset_path"] = "datasets/train_hr" |
|
opt["train_hr_dataset_path"] = "datasets/train_hr_enhanced" |
|
|
|
|
|
|
|
opt['CUDA_VISIBLE_DEVICES'] = '0' |
|
os.environ['CUDA_VISIBLE_DEVICES'] = opt['CUDA_VISIBLE_DEVICES'] |
|
|
|
|
|
|
|
|
|
|
|
opt["lr_dataset_path"] = "datasets/train_lr" |
|
opt['hr_size'] = 256 |
|
|
|
|
|
|
|
opt['pixel_loss'] = "L1" |
|
|
|
|
|
|
|
opt["adam_beta1"] = 0.9 |
|
opt["adam_beta2"] = 0.99 |
|
opt['decay_gamma'] = 0.5 |
|
|
|
|
|
|
|
opt['degradate_generation_freq'] = 1 |
|
opt['train_dataloader_workers'] = 5 |
|
opt['checkpoints_freq'] = 50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
if opt['architecture'] == "ESRNET": |
|
|
|
|
|
opt['ESR_blocks_num'] = 6 |
|
opt['train_iterations'] = 500000 |
|
opt['train_batch_size'] = 32 |
|
|
|
|
|
opt["start_learning_rate"] = 0.0002 |
|
opt['decay_iteration'] = 100000 |
|
opt['double_milestones'] = [] |
|
|
|
|
|
elif opt['architecture'] == "ESRGAN": |
|
|
|
|
|
opt['ESR_blocks_num'] = 6 |
|
opt['train_iterations'] = 200000 |
|
opt['train_batch_size'] = 32 |
|
|
|
|
|
opt["start_learning_rate"] = 0.0001 |
|
opt['decay_iteration'] = 100000 |
|
opt['double_milestones'] = [] |
|
|
|
|
|
opt["danbooru_perceptual_loss_weight"] = 0.5 |
|
opt["vgg_perceptual_loss_weight"] = 0.5 |
|
opt['train_perceptual_vgg_type'] = 'vgg19' |
|
opt['train_perceptual_layer_weights'] = {'conv1_2': 0.1, 'conv2_2': 0.1, 'conv3_4': 1, 'conv4_4': 1, 'conv5_4': 1} |
|
opt['Danbooru_layer_weights'] = {"0": 0.1, "4_2_conv3": 20, "5_3_conv3": 25, "6_5_conv3": 1, "7_2_conv3": 1} |
|
|
|
|
|
opt["discriminator_type"] = "PatchDiscriminator" |
|
opt["gan_loss_weight"] = 0.2 |
|
|
|
|
|
|
|
elif opt['architecture'] == "CUNET": |
|
|
|
opt['train_iterations'] = 500000 |
|
opt['train_batch_size'] = 16 |
|
|
|
opt["start_learning_rate"] = 0.0002 |
|
opt['decay_iteration'] = 100000 |
|
opt['double_milestones'] = [] |
|
|
|
|
|
elif opt['architecture'] == "CUGAN": |
|
|
|
opt['ESR_blocks_num'] = 6 |
|
opt['train_iterations'] = 200000 |
|
opt['train_batch_size'] = 16 |
|
opt["start_learning_rate"] = 0.0001 |
|
|
|
opt["perceptual_loss_weight"] = 1.0 |
|
opt['train_perceptual_vgg_type'] = 'vgg19' |
|
opt['train_perceptual_layer_weights'] = {'conv1_2': 0.1, 'conv2_2': 0.1, 'conv3_4': 1, 'conv4_4': 1, 'conv5_4': 1} |
|
opt['Danbooru_layer_weights'] = {"0": 0.1, "4_2_conv3": 20, "5_3_conv3": 25, "6_5_conv3": 1, "7_2_conv3": 1} |
|
opt["gan_loss_weight"] = 0.2 |
|
|
|
opt['decay_iteration'] = 100000 |
|
opt['double_milestones'] = [] |
|
|
|
|
|
elif opt['architecture'] == "GRL": |
|
|
|
opt['model_size'] = "tiny2" |
|
|
|
opt['train_iterations'] = 300000 |
|
opt['train_batch_size'] = 32 |
|
|
|
|
|
opt["start_learning_rate"] = 0.0002 |
|
opt['decay_iteration'] = 100000 |
|
opt['double_milestones'] = [] |
|
|
|
|
|
elif opt['architecture'] == "GRLGAN": |
|
|
|
opt['model_size'] = "tiny2" |
|
|
|
|
|
opt['train_iterations'] = 300000 |
|
opt['train_batch_size'] = 32 |
|
|
|
|
|
opt["start_learning_rate"] = 0.0001 |
|
opt['decay_iteration'] = 100000 |
|
opt['double_milestones'] = [] |
|
|
|
|
|
opt["danbooru_perceptual_loss_weight"] = 0.5 |
|
opt["vgg_perceptual_loss_weight"] = 0.5 |
|
opt['train_perceptual_vgg_type'] = 'vgg19' |
|
opt['train_perceptual_layer_weights'] = {'conv1_2': 0.1, 'conv2_2': 0.1, 'conv3_4': 1, 'conv4_4': 1, 'conv5_4': 1} |
|
opt['Danbooru_layer_weights'] = {"0": 0.1, "4_2_conv3": 20, "5_3_conv3": 25, "6_5_conv3": 1, "7_2_conv3": 1} |
|
|
|
|
|
opt["discriminator_type"] = "PatchDiscriminator" |
|
opt["gan_loss_weight"] = 0.2 |
|
|
|
else: |
|
raise NotImplementedError("Please check you architecture option setting!") |
|
|
|
|
|
|
|
|
|
|
|
opt["degradation_batch_size"] = 128 |
|
opt["augment_prob"] = 0.5 |
|
|
|
|
|
if opt['architecture'] in ["ESRNET", "ESRGAN", "GRL", "GRLGAN", "CUNET", "CUGAN"]: |
|
|
|
opt['parallel_num'] = 8 |
|
|
|
|
|
opt['kernel_range'] = [3, 11] |
|
opt['kernel_list'] = ['iso', 'aniso', 'generalized_iso', 'generalized_aniso', 'plateau_iso', 'plateau_aniso'] |
|
opt['kernel_prob'] = [0.45, 0.25, 0.12, 0.03, 0.12, 0.03] |
|
opt['sinc_prob'] = 0.1 |
|
opt['blur_sigma'] = [0.2, 3] |
|
opt['betag_range'] = [0.5, 4] |
|
opt['betap_range'] = [1, 2] |
|
|
|
|
|
opt['kernel_list2'] = ['iso', 'aniso', 'generalized_iso', 'generalized_aniso', 'plateau_iso', 'plateau_aniso'] |
|
opt['kernel_prob2'] = [0.45, 0.25, 0.12, 0.03, 0.12, 0.03] |
|
opt['sinc_prob2'] = 0.1 |
|
opt['blur_sigma2'] = [0.2, 1.5] |
|
opt['betag_range2'] = [0.5, 4] |
|
opt['betap_range2'] = [1, 2] |
|
|
|
|
|
opt['resize_prob'] = [0.2, 0.7, 0.1] |
|
opt['resize_range'] = [0.1, 1.2] |
|
opt['gaussian_noise_prob'] = 0.5 |
|
opt['noise_range'] = [1, 30] |
|
opt['poisson_scale_range'] = [0.05, 3] |
|
opt['gray_noise_prob'] = 0.4 |
|
opt['jpeg_range'] = [30, 95] |
|
|
|
|
|
opt['second_blur_prob'] = 0.8 |
|
opt['resize_prob2'] = [0.2, 0.7, 0.1] |
|
opt['resize_range2'] = [0.15, 1.2] |
|
opt['gaussian_noise_prob2'] = 0.5 |
|
opt['noise_range2'] = [1, 25] |
|
opt['poisson_scale_range2'] = [0.05, 2.5] |
|
opt['gray_noise_prob2'] = 0.4 |
|
|
|
|
|
opt['resize_options'] = ['area', 'bilinear', 'bicubic'] |
|
|
|
|
|
|
|
opt['compression_codec1'] = ["jpeg", "webp", "heif", "avif"] |
|
opt['compression_codec_prob1'] = [0.4, 0.6, 0.0, 0.0] |
|
|
|
|
|
opt["jpeg_quality_range1"] = [20, 95] |
|
opt["webp_quality_range1"] = [20, 95] |
|
opt["webp_encode_speed1"] = [0, 6] |
|
opt["heif_quality_range1"] = [30, 100] |
|
opt["heif_encode_speed1"] = [0, 6] |
|
opt["avif_quality_range1"] = [30, 100] |
|
opt["avif_encode_speed1"] = [0, 6] |
|
|
|
|
|
|
|
opt['compression_codec2'] = ["jpeg", "webp", "avif", "mpeg2", "mpeg4", "h264", "h265"] |
|
opt['compression_codec_prob2'] = [0.06, 0.1, 0.1, 0.12, 0.12, 0.3, 0.2] |
|
|
|
|
|
opt["jpeg_quality_range2"] = [20, 95] |
|
|
|
opt["webp_quality_range2"] = [20, 95] |
|
opt["webp_encode_speed2"] = [0, 6] |
|
|
|
opt["avif_quality_range2"] = [20, 95] |
|
opt["avif_encode_speed2"] = [0, 6] |
|
|
|
|
|
opt['h264_crf_range2'] = [23, 38] |
|
opt['h264_preset_mode2'] = ["slow", "medium", "fast", "faster", "superfast"] |
|
opt['h264_preset_prob2'] = [0.05, 0.35, 0.3, 0.2, 0.1] |
|
|
|
opt['h265_crf_range2'] = [28, 42] |
|
opt['h265_preset_mode2'] = ["slow", "medium", "fast", "faster", "superfast"] |
|
opt['h265_preset_prob2'] = [0.05, 0.35, 0.3, 0.2, 0.1] |
|
|
|
opt['mpeg2_quality2'] = [8, 31] |
|
opt['mpeg2_preset_mode2'] = ["slow", "medium", "fast", "faster", "superfast"] |
|
opt['mpeg2_preset_prob2'] = [0.05, 0.35, 0.3, 0.2, 0.1] |
|
|
|
opt['mpeg4_quality2'] = [8, 31] |
|
opt['mpeg4_preset_mode2'] = ["slow", "medium", "fast", "faster", "superfast"] |
|
opt['mpeg4_preset_prob2'] = [0.05, 0.35, 0.3, 0.2, 0.1] |
|
|
|
|
|
|