Deep learning for satellite imagery with Python
Build a complete deep-learning workflow for satellite imagery in Python: prepare training chips and labels, train a U-Net for semantic segmentation in PyTorch, and run the trained model over rasters far larger than memory.
- Intermediate to Advanced
- 3, all published
- About 38 minutes
The parts, in order
-
Training data for deep learning on satellite imagery: Sentinel-2 image chips in Python
Build a labelled deep learning dataset from free data: stream a Sentinel-2 L2A composite from the Planetary Computer, rasterise Overture building footprints over ESA WorldCover, cut georeferenced image chips, split them by spatial block so the test set does not leak, check the class balance and load it all as a TorchGeo dataset.
-
U-Net satellite image segmentation in PyTorch: a TorchGeo and Sentinel-2 tutorial on a CPU
Train a U-Net to segment Sentinel-2 imagery into buildings, built-up land, trees, grass and water with PyTorch, segmentation_models_pytorch and TorchGeo's Sentinel-2 pretrained ResNet-18 weights, on a CPU in five minutes. Real loss curves, per-class IoU and F1, a confusion matrix and an honest look at what limits accuracy.
-
Deep learning inference on large rasters: sliding-window prediction, COGs and polygons in Python
Run a trained PyTorch U-Net over a whole Sentinel-2 scene of a city it has never seen: tiled sliding-window inference on a large GeoTIFF with overlapping, blended windows, a georeferenced Cloud Optimised GeoTIFF of classes and confidence, raster-to-vector polygons with rasterio.features.shapes in a GeoPackage, and an honest check against reference labels.