GAN_Ai is a lightweight Python project demonstrating Generative Adversarial Networks (GANs) for image generation and experimentation. It provides training scripts, model checkpoints, and utilities to train, evaluate, and sample from GAN models. The repository is intended for researchers, students, and hobbyists who want a simple, well-documented starting point for GAN experiments.
- Simple, modular GAN implementation in Python
- Training script with configurable hyperparameters
- Utilities for dataset preparation, logging, and checkpointing
- Sampling script to generate images from saved checkpoints
- Example configuration and tips for experimentation
- data/ - datasets or dataset download utilities
- models/ - model definitions (Generator, Discriminator)
- scripts/ - training, sampling, and evaluation scripts
- checkpoints/ - saved model weights and training logs
- notebooks/ - Jupyter notebooks for exploration and visualization
- requirements.txt - Python dependencies
- README.md - this file
Note: adjust paths above if your repository uses a different layout.
- Python 3.8+
- PyTorch (or TensorFlow) depending on the implementation
- torchvision (if using common image datasets)
- numpy, matplotlib, tqdm
Install dependencies (if a requirements.txt is present):
pip install -r requirements.txt
Or install common packages manually:
pip install torch torchvision numpy matplotlib tqdm
- Prepare dataset
- Place images in
data/<dataset-name>/with subfolders per class if required, or implement a dataset loader inscripts/data_loader.py.
- Train a model
python scripts/train.py --config configs/default.yaml --dataset data/
Common arguments:
- --config: path to YAML/JSON config with hyperparameters
- --epochs: number of training epochs
- --batch-size: training batch size
- --lr: learning rate
- --device: cpu or cuda
- Generate samples
python scripts/generate.py --checkpoint checkpoints/latest.pt --output samples/
- Evaluate or visualize results
- Use notebooks in
notebooks/for interactive analysis - Plot losses and sample grids saved by the training script
Configurations are typically stored in configs/ as YAML or JSON. Example fields:
- model: generator/discriminator architecture and hyperparameters
- optimizer: type, learning rate, betas
- training: batch size, epochs, checkpoint interval
- dataset: path, image size, transforms
- Training saves checkpoints to
checkpoints/by default. Use--resumeor--checkpointto resume training or sample from a saved model.
- Start with smaller models and datasets to verify your pipeline
- Use learning rate schedulers and gradient penalty for improved stability
- Normalize images to [-1, 1] if using Tanh in generator output
- Monitor FID or IS scores for quantitative evaluation
Contributions are welcome. Please open an issue to discuss major changes or submit a pull request with:
- a clear description of the change
- tests or example usage when applicable
- updates to documentation if behavior changes
Specify a license in a LICENSE file (e.g., MIT). If you have a preferred license, add it to the repository.
This project is inspired by many GAN tutorials and research papers. Credit to authors of the original GAN, DCGAN, WGAN, and others for ideas and best practices.
For questions or help, open an issue or contact the repository owner.