Train a Transformer VQ-GAN VAE
mainBefore using Parti, you must train a VitVQGanVAE. This component acts as the visual tokenizer. You can use the VQGanVAETrainer to manage the training process, specifying the model, image directory, training steps, learning rate, and batch size.
from parti_pytorch import VitVQGanVAE, VQGanVAETrainer
vit_vae = VitVQGanVAE(
dim = 256, # dimensions
image_size = 256, # target image size
patch_size = 16, # size of the patches in the image attending to each other
num_layers = 3 # number of layers
).cuda()
trainer = VQGanVAETrainer(
vit_vae,
folder = '/path/to/your/images',
num_train_steps = 100000,
lr = 3e-4,
batch_size = 4,
grad_accum_every = 8,
amp = True
)
trainer.train()