Here is the text with corrected grammar:
I have trained the baseline model on the CelebAHQ-Ref dataset (a dataset of ~6500 training examples) for about 600 epochs and ~500K iterations for the restoration task.
Baseline: Using a pre-trained Codebook and Decoder, fine-tuning the Encoder, and training the Transformer.
I have attached the results. The problem is that the loss hasn’t decreased properly. We have two losses: 1) MSE loss, which encourages the LQ feature to closely resemble the quantized feature, and 2) Cross entropy loss for code index prediction. Most of the loss reduction is expected to come from the MSE loss. This loss doesn’t decrease properly, so the gap between the LQ feature and HQ feature is not reduced. Consequently, the Transformer fails to match the correct indices.
If you train the baseline on the HQ images as a sanity check, it converges very fast.
I have also checked the gradient flow and confirmed that gradients were flowing for both the Transformer and the Encoder during training. As I sent an update before, the model can restore one image very well, but it fails when tested on a full dataset.
One potential cause may be that there are only a few codes related to faces. Alternatively, since we have a downsampling factor of 8, 4096 tokens might be too many for the Transformer compared to Codeformer, which uses 256 tokens. The code embedding dimension of 4 might also be too small. Another possibility is that gradually increasing the noise level during training might help. Otherwise, we might need to use a different backbone. Alternatively, if prioritizing the downsampling factor (where 16 might be a better choice for our needs), we would need to train a custom model on the FFHQ dataset.
Another option is to use Codeformer to process LQ images and predict codes, and use the LDM VQVAE model to process reference images and find matched codes (as it is better than Codeformer for HQ reconstruction). We would then need to train a fusion module to combine the outputs of these two models, placed before the decoder. We would also need to fine-tune the decoder.
Additionally, there was another model on the Taming-Transformer GitHub repository trained on the FFHQ dataset at 256x256 resolution, with a codebook size of 1024 and a downsampling factor of 16. However, the reconstruction quality was not adequate for the 512x512 resolution that we require.