Stage I involves training the VQGAN.
Note for PyTorch >= 1.10: Replace python -m torch.distributed.launch with torchrun in the command below.
After training VQGAN, you can run python scripts/generate_latent_gt.py to pre-generate the codebook sequences for the training dataset, which accelerates subsequent training stages.
If you prefer not to train your own VQGAN, you can download the pre-trained weights (vqgan_code1024.pth) and the corresponding codebook sequences (latent_gt_code1024.pth) from the v0.1.0 Release.
# Replace gpu_num with your actual number of GPUs
python -m torch.distributed.launch --nproc_per_node=gpu_num --master_port=4321 basicsr/train.py -opt options/VQGAN_512_ds32_nearest_stage1.yml --launcher pytorch
# Generate latent ground truth to accelerate later stages
python scripts/generate_latent_gt.py