A Python application for training Generative Adversarial Networks (GANs) with configurable architectures and training parameters, featuring a Tkinter-based graphical user interface.
This project allows users to:
- Define Generator and Discriminator architectures via a JSON configuration file.
- Set training parameters (learning rates, loss functions, epochs, batch sizes) through the UI.
- Load and preview network architectures.
- Start, pause, resume, and switch active training between the Generator and Discriminator.
- Monitor training progress with a simple log.
- Visualize training losses.
- Generate sample images from the current Generator.
GAN_Project_Root/
├── .git/
├── .venv/
├── GAN/
│ ├── **init**.py
│ ├── main.py
│ ├── controller.py
│ ├── model_builder.py
│ ├── train_manager.py
│ ├── data_loader.py
│ └── config.json
├── data/
│ └── MNIST/
│ └── raw/
│ └── ...
├── .gitignore
├── pyproject.toml
├── requirements.txt
├── README.md
├── LICENSE
└── uv.lock
- Python 3.8+
uv(orpipandvenv) for environment and package management
-
Clone the repository (if applicable):
# git clone <repository-url> # cd <repository-name>
-
Create and activate a virtual environment: Using
uv:uv venv .venv source .venv/bin/activateOr using standard
venv:python3 -m venv .venv source .venv/bin/activate -
Install dependencies: Using
uv:uv pip install -r requirements.txt
Or using
pip:pip install -r requirements.txt
If you also want to install the project itself in editable mode (useful for development):
uv pip install -e . # or pip install -e .
-
Ensure you have a
config.jsonfile (an example is provided inGAN/config.json) defining the GAN architecture and default training settings. -
Run the application:
python -m GAN.main
This will launch the Tkinter GUI.
-
Using the GUI:
- Network Preview Tab: Load your
config.jsonto see a textual representation of the Generator and Discriminator architectures. - Training Parameters Tab:
- Adjust learning rates, loss functions, epochs, and batch sizes for both Generator and Discriminator.
- Select the data folder (defaults to
./datafor MNIST). - Choose which network (Generator or Discriminator) should be active initially.
- Use the control buttons (Start, Pause, Resume, Switch, Stop) to manage the training process.
- Training logs will appear in the text area.
- Summary & Generation Tab:
- View a summary of the loaded configuration.
- Plot the training losses (Generator vs. Discriminator).
- Generate a sample image using the current state of the Generator.
- Network Preview Tab: Load your
The config.json file defines:
generator: Input dimension, layer configurations (type, units/filters, activation, etc.), output size.discriminator: Input shape, layer configurations, output size.training: Default training parameters for generator and discriminator (loss function, learning rate, epochs, batch size), data folder path, and initial active network.
See GAN/config.json for a detailed example.
Contributions are welcome! Please feel free to submit a pull request or open an issue.
This project is licensed under the MIT License - see the LICENSE file for details.