Quick Start Guide for New Projects
0. Prepare the Environment
- Set up your environment:
conda create -n myenv python=3.9 conda activate myenv pip install -r requirements.txt
1. Project Initialization
- Use the Minimal Lightning Hydra Template: Click "Use this template" on GitHub, or clone and remove
.git
for a fresh start:git clone https://github.com/antonibigata/minimal-lightning-hydra-template.git <project-name> cd <project-name> rm -rf .git
2. Data Setup
- Structure data code in
src/datamodules
andcomponents/dataset.py
. - Configure in
configs/datamodule/datamodule.yaml
; usedefault.yaml
for shared parameters. - Example: Adapt FashionMNIST dataset and configurations. Implement and test custom datamodules and datasets.
3. Model and Network Configuration
- Define networks in
src/models/components/nets
and configure inconfigs/model/net
. - Create simple models for practice, referencing provided examples. Write unit tests to ensure functionality.
4. Model Creation
- Develop your model in
src/models
as a PyTorch LightningLightningModule
. - Use
configs/model/default.yaml
for base settings; add specific model configs as needed. - Examine example models and consult PyTorch Lightning documentation for guidance.
5. Training Setup
- Manage training with PyTorch Lightning
Trainer
and configurations inconfigs/trainer
. - Adjust training settings via command line, e.g.,
python src/train.py trainer.max_epochs=20
. - Use
configs/train.yaml
to encompass datamodule, model, callbacks, logger, trainer, and paths settings.
6. Launch Training
- Start with
python src/train.py
. Override configs as required, e.g.,python src/train.py model/net=conv_net
. - For GPU training, add
trainer=gpu
.
7. Logging with Wandb
- Install Wandb, sign up, and authenticate. Modify
configs/train.yaml
for Wandb logging or usepython src/train.py logger=wandb
. - Log training metrics, images, and explore advanced Wandb features as per documentation.
8. Evaluation
- Evaluate model performance with
python src/eval.py ckpt_path=<path_to_checkpoint>
. - Use test set for unbiased assessment; locate checkpoints in
logs/train/runs
.
9. Inference
- Perform inference on custom data:
python src/inference.py ckpt_path=<checkpoint> image_path=<image_path>
. - Repository includes sample FashionMNIST images in
logs/data_check
for quick tests.