A PyTorch implementation of a Convolutional Variational Autoencoder for image generation and reconstruction, specifically designed for face datasets.
(it suffers from posterior collapse , it always generates a face with the same features -> styleGAN architectue solves this problem , check my implementation of it StyleGAN Repo )
- Convolutional Architecture: Encoder-decoder structure with convolutional and transposed convolutional layers
- Perceptual Loss: VGG19-based perceptual loss for improved reconstruction quality
- Beta Scheduling: Gradual increase of KL divergence weight during training
- Checkpointing: Resume training from saved checkpoints
- Memory Efficient: Built-in memory management for GPU training
- Input: 128×128 RGB images
- Encoder: 3 convolutional blocks (32→64→128 channels) with LayerNorm
- Latent Space: 256-dimensional latent vector
- Decoder: 3 transposed convolutional blocks with skip connections
- Reconstruction Loss: Binary Cross-Entropy + MAE
- KL Divergence Loss: Regularization term with beta scheduling
- Perceptual Loss: VGG19 feature matching (optional, enabled after epoch 10)
git clone https://github.com/HajarHAMDOUCH01/Convolutiional_VAE
pip install -r requirements.txt
# Train model
python train_vae.pyKey parameters in training_config.py:
batch_size: 64lr: 1e-4num_epochs: 300beta: KL weight (starts at 0.0, increases every 10 epochs => maximum 1.0)z_dim: Latent dimension (256)


.png)
.png)
.png)