GFPGAN
1# general settings
2name: train_GFPGANv1_512
3model_type: GFPGANModel
4num_gpu: auto # officially, we use 4 GPUs
5manual_seed: 0
6
7# dataset and data loader settings
8datasets:
9train:
10name: FFHQ
11type: FFHQDegradationDataset
12# dataroot_gt: datasets/ffhq/ffhq_512.lmdb
13dataroot_gt: datasets/ffhq/ffhq_512
14io_backend:
15# type: lmdb
16type: disk
17
18use_hflip: true
19mean: [0.5, 0.5, 0.5]
20std: [0.5, 0.5, 0.5]
21out_size: 512
22
23blur_kernel_size: 41
24kernel_list: ['iso', 'aniso']
25kernel_prob: [0.5, 0.5]
26blur_sigma: [0.1, 10]
27downsample_range: [0.8, 8]
28noise_range: [0, 20]
29jpeg_range: [60, 100]
30
31# color jitter and gray
32color_jitter_prob: 0.3
33color_jitter_shift: 20
34color_jitter_pt_prob: 0.3
35gray_prob: 0.01
36
37# If you do not want colorization, please set
38# color_jitter_prob: ~
39# color_jitter_pt_prob: ~
40# gray_prob: 0.01
41# gt_gray: True
42
43crop_components: true
44component_path: experiments/pretrained_models/FFHQ_eye_mouth_landmarks_512.pth
45eye_enlarge_ratio: 1.4
46
47# data loader
48use_shuffle: true
49num_worker_per_gpu: 6
50batch_size_per_gpu: 3
51dataset_enlarge_ratio: 1
52prefetch_mode: ~
53
54val:
55# Please modify accordingly to use your own validation
56# Or comment the val block if do not need validation during training
57name: validation
58type: PairedImageDataset
59dataroot_lq: datasets/faces/validation/input
60dataroot_gt: datasets/faces/validation/reference
61io_backend:
62type: disk
63mean: [0.5, 0.5, 0.5]
64std: [0.5, 0.5, 0.5]
65scale: 1
66
67# network structures
68network_g:
69type: GFPGANv1
70out_size: 512
71num_style_feat: 512
72channel_multiplier: 1
73resample_kernel: [1, 3, 3, 1]
74decoder_load_path: experiments/pretrained_models/StyleGAN2_512_Cmul1_FFHQ_B12G4_scratch_800k.pth
75fix_decoder: true
76num_mlp: 8
77lr_mlp: 0.01
78input_is_latent: true
79different_w: true
80narrow: 1
81sft_half: true
82
83network_d:
84type: StyleGAN2Discriminator
85out_size: 512
86channel_multiplier: 1
87resample_kernel: [1, 3, 3, 1]
88
89network_d_left_eye:
90type: FacialComponentDiscriminator
91
92network_d_right_eye:
93type: FacialComponentDiscriminator
94
95network_d_mouth:
96type: FacialComponentDiscriminator
97
98network_identity:
99type: ResNetArcFace
100block: IRBlock
101layers: [2, 2, 2, 2]
102use_se: False
103
104# path
105path:
106pretrain_network_g: ~
107param_key_g: params_ema
108strict_load_g: ~
109pretrain_network_d: ~
110pretrain_network_d_left_eye: ~
111pretrain_network_d_right_eye: ~
112pretrain_network_d_mouth: ~
113pretrain_network_identity: experiments/pretrained_models/arcface_resnet18.pth
114# resume
115resume_state: ~
116ignore_resume_networks: ['network_identity']
117
118# training settings
119train:
120optim_g:
121type: Adam
122lr: !!float 2e-3
123optim_d:
124type: Adam
125lr: !!float 2e-3
126optim_component:
127type: Adam
128lr: !!float 2e-3
129
130scheduler:
131type: MultiStepLR
132milestones: [600000, 700000]
133gamma: 0.5
134
135total_iter: 800000
136warmup_iter: -1 # no warm up
137
138# losses
139# pixel loss
140pixel_opt:
141type: L1Loss
142loss_weight: !!float 1e-1
143reduction: mean
144# L1 loss used in pyramid loss, component style loss and identity loss
145L1_opt:
146type: L1Loss
147loss_weight: 1
148reduction: mean
149
150# image pyramid loss
151pyramid_loss_weight: 1
152remove_pyramid_loss: 50000
153# perceptual loss (content and style losses)
154perceptual_opt:
155type: PerceptualLoss
156layer_weights:
157# before relu
158'conv1_2': 0.1
159'conv2_2': 0.1
160'conv3_4': 1
161'conv4_4': 1
162'conv5_4': 1
163vgg_type: vgg19
164use_input_norm: true
165perceptual_weight: !!float 1
166style_weight: 50
167range_norm: true
168criterion: l1
169# gan loss
170gan_opt:
171type: GANLoss
172gan_type: wgan_softplus
173loss_weight: !!float 1e-1
174# r1 regularization for discriminator
175r1_reg_weight: 10
176# facial component loss
177gan_component_opt:
178type: GANLoss
179gan_type: vanilla
180real_label_val: 1.0
181fake_label_val: 0.0
182loss_weight: !!float 1
183comp_style_weight: 200
184# identity loss
185identity_weight: 10
186
187net_d_iters: 1
188net_d_init_iters: 0
189net_d_reg_every: 16
190
191# validation settings
192val:
193val_freq: !!float 5e3
194save_img: true
195
196metrics:
197psnr: # metric name
198type: calculate_psnr
199crop_border: 0
200test_y_channel: false
201
202# logging settings
203logger:
204print_freq: 100
205save_checkpoint_freq: !!float 5e3
206use_tb_logger: true
207wandb:
208project: ~
209resume_id: ~
210
211# dist training settings
212dist_params:
213backend: nccl
214port: 29500
215
216find_unused_parameters: true
217