Formatting

This commit is contained in:
Craig
2025-04-12 10:44:52 +01:00
parent 97776a4a82
commit 620c34bf13
4 changed files with 365 additions and 25 deletions

50
todo.md
View File

@@ -26,34 +26,34 @@ This list outlines the steps required to complete the Torchvision Finetuning pro
- [x] `__len__`: Return dataset size.
- [x] Implement `get_transform(train)` function in `utils/data_utils.py` (using `torchvision.transforms.v2`).
- [x] Implement `collate_fn(batch)` function in `utils/data_utils.py`.
- [ ] Implement `get_maskrcnn_model(num_classes, ...)` function in `models/detection.py`.
- [ ] Load pre-trained Mask R-CNN (`maskrcnn_resnet50_fpn_v2`).
- [ ] Replace box predictor head (`FastRCNNPredictor`).
- [ ] Replace mask predictor head (`MaskRCNNPredictor`).
- [x] Implement `get_maskrcnn_model(num_classes, ...)` function in `models/detection.py`.
- [x] Load pre-trained Mask R-CNN (`maskrcnn_resnet50_fpn_v2`).
- [x] Replace box predictor head (`FastRCNNPredictor`).
- [x] Replace mask predictor head (`MaskRCNNPredictor`).
## Phase 3: Training Script & Core Logic
- [ ] Set up basic `train.py` structure.
- [ ] Add imports.
- [ ] Implement `argparse` for `--config` argument.
- [ ] Implement dynamic config loading (`importlib`).
- [ ] Set random seeds.
- [ ] Determine compute device (`cuda` or `cpu`).
- [ ] Create output directory structure (`outputs/<config_name>/checkpoints`).
- [ ] Instantiate `PennFudanDataset` (train).
- [ ] Instantiate `DataLoader` (train) using `collate_fn`.
- [ ] Instantiate model using `get_maskrcnn_model`.
- [ ] Move model to device.
- [ ] Add `if __name__ == "__main__":` guard.
- [ ] Implement minimal training step in `train.py`.
- [ ] Instantiate optimizer (`torch.optim.SGD`).
- [ ] Set `model.train()`.
- [ ] Fetch one batch.
- [ ] Move data to device.
- [ ] Perform forward pass (`loss_dict = model(...)`).
- [ ] Calculate total loss (`sum(...)`).
- [ ] Perform backward pass (`optimizer.zero_grad()`, `loss.backward()`, `optimizer.step()`).
- [ ] Print/log loss for the single step (and temporarily exit).
- [x] Set up basic `train.py` structure.
- [x] Add imports.
- [x] Implement `argparse` for `--config` argument.
- [x] Implement dynamic config loading (`importlib`).
- [x] Set random seeds.
- [x] Determine compute device (`cuda` or `cpu`).
- [x] Create output directory structure (`outputs/<config_name>/checkpoints`).
- [x] Instantiate `PennFudanDataset` (train).
- [x] Instantiate `DataLoader` (train) using `collate_fn`.
- [x] Instantiate model using `get_maskrcnn_model`.
- [x] Move model to device.
- [x] Add `if __name__ == "__main__":` guard.
- [x] Implement minimal training step in `train.py`.
- [x] Instantiate optimizer (`torch.optim.SGD`).
- [x] Set `model.train()`.
- [x] Fetch one batch.
- [x] Move data to device.
- [x] Perform forward pass (`loss_dict = model(...)`).
- [x] Calculate total loss (`sum(...)`).
- [x] Perform backward pass (`optimizer.zero_grad()`, `loss.backward()`, `optimizer.step()`)
- [x] Print/log loss for the single step (and temporarily exit).
- [ ] Implement logging setup in `utils/log_utils.py` (`setup_logging` function).
- [ ] Configure `logging.basicConfig` for file and console output.
- [ ] Integrate logging into `train.py`.