This is a learning project to understand how to track multiple experiments efficiently in PyTorch.
It is based on the course PyTorch for Deep Learning (Udemy).
The project uses EfficientNet-B0 and EfficientNet-B2 on the Pizza, Steak, and Sushi dataset,
which is a subset of the original Food101 dataset.
It demonstrates:
- Experiment reproducibility
- TensorBoard tracking
- Automatic dataset preparation
- ✅ Dataset Download & Preprocessing (10% & 20% splits)
- ✅ EfficientNet-B0 and B2 (ImageNet-pretrained)
- ✅ Transfer Learning with Frozen Feature Extractor
- ✅ TensorBoard Logging (loss, accuracy, graph)
- ✅ Custom Classifier Heads for 3-class Output
- ✅ Reproducibility with Random Seeds
- ✅ Modular Codebase and CLI Support
.
├── artifacts # Saved models
│ └── models
├── data # Downloaded datasets
│ ├── pizza_steak_sushi_10
│ └── pizza_steak_sushi_20
├── LICENSE
├── README.md
├── runs # TensorBoard logs
│ └── 2025-Aug-14
└── src
├── data_module.py # DataLoader creation
├── data_setup.py # Dataset download and extraction
├── engine.py # Train/test steps
├── __init__.py
├── model_builder.py # EfficientNet model creation
├── predictions.py # Single image prediction and visualization
├── train.py # Main training orchestration (CLI + logging + experiment loop)
└── utils.py # Utility functions (saving, logging, plotting)
git clone https://github.com/Niloy009/pytorch_experiment_tracking.git
cd pytorch_experiment_trackingpip install torch torchvision torchmetrics matplotlib requests tqdm tensorboardpython -m src.trainpython -m src.train \
--models effnetb0 effnetb2 \
--data_pct 10 20 \
--epochs 5 10 \
--batch-size 32 \
--lr 0.001 \
--seed 42 \
--data-root ./data \
--artifacts-dir ./artifacts \
-vvStart TensorBoard to monitor metrics:
tensorboard --logdir runsThen navigate to http://localhost:6006
from predictions import pred_and_plot_image
from model_builder import create_effnetb0
import torch
model = create_effnetb0()
model.load_state_dict(torch.load("path_to_model.pth"))
class_names = ["pizza", "steak", "sushi"]
pred_and_plot_image(model, class_names, "path_to_image.jpg")- Train/Test Loss per Epoch
- Train/Test Accuracy per Epoch
- Model Graph Summary
- Optimizer: Adam
- Loss: CrossEntropyLoss
- Accuracy: torchmetrics.Accuracy
- Transforms: Model-specific (from torchvision weights)
- Device: Automatic CUDA/CPU selection
- Seeded Execution:
torch.manual_seed()
This project is licensed under the MIT License - see the LICENSE file for details.
Niloy Saha Roy
Machine Learning & Deep Learning Engineer
Email: niloysaha.887@gmail.com