A PyTorch semantic-segmentation experiment that predicts road pixels from aerial images. The notebook implements paired image/mask loading, augmentation, transfer learning, training and validation loops, checkpointing, and thresholded inference.
| Area | Notebook configuration |
|---|---|
| Data | A 200-image subset of Massachusetts Roads, supplied through the external dataset/helper repository |
| Split | 80% training / 20% validation, random seed 42 |
| Input | RGB images and binary masks resized to 512 × 512 |
| Augmentation | Horizontal and vertical flips on training pairs |
| Model | segmentation_models_pytorch.Unet, timm-efficientnet-b0 encoder, ImageNet initialization |
| Objective | Binary Dice loss plus BCEWithLogitsLoss |
| Training | Adam, learning rate 0.003, batch size 8, 25 epochs, CUDA configured by default |
| Checkpoint | best-model.pt, selected by lowest validation loss |
| Inference | Sigmoid followed by a 0.5 threshold |
The result is a qualitative example. This repository does not publish a newly reproduced IoU or Dice benchmark.
git clone https://github.com/paluuuk/Aerial-Image-Segmentation.git
cd Aerial-Image-Segmentation
python -m venv .venv
# Activate .venv using the command for your shell.
python -m pip install -r requirements.txt
jupyter notebook Aerial_Image_Segmentation_with_PyTorch.ipynbThe notebook was written for Google Colab. It clones parth1620/Road_seg_dataset, which supplies train.csv, image/mask files, and the imported helper module. The external data/helper material is a dependency of this guided experiment, not a module implemented in this repository.
For a local run, review the installation/download cells and change CSV_FILE, DATA_DIR, the helper import path, and the checkpoint load path from their /content/ defaults. Select an appropriate DEVICE for the machine. Dataset files and trained checkpoints are not committed here.
This is a notebook-based learning experiment. A random split of image patches is not a geographic generalization benchmark. The dependencies are not version-locked, so current library compatibility must be checked before a full rerun.
The custom dataset converts RGB arrays to channel-first float tensors in [0, 1] and masks to binary tensors. Training and evaluation are separated through model.train(), model.eval(), and torch.no_grad().
Stack: Python, PyTorch, segmentation-models-pytorch, timm, Albumentations, OpenCV, NumPy, pandas, scikit-learn.