
TorchGeo Inference: Stitching Patch Predictions into a Seamless Map
Learn how to run a trained TorchGeo model over a whole satellite scene and stitch the patch predictions back into one clean, georeferenced map. We start with the basics: rasters, coordinate systems and the affine transform.
Notes
Learn how to run a trained TorchGeo model over a whole satellite scene and stitch the patch predictions back into one clean, georeferenced map. We start with the basics: rasters, coordinate systems and the affine transform. Then we cut a scene into overlapping patches with GriddedPatchSampler, which replaces GridGeoSampler in TorchGeo 0.10, and use each patch’s bounds and transform to put its prediction back in the right place. You’ll see why patch edges leave seams and compare three fixes: center cropping, weighted blending and larger inference patches. The video covers every model type: segmentation, regression and change detection; patch-level classification maps; and object detection and instance segmentation, where overlap creates duplicate objects that need NMS or a keep-center rule. Everything is checked against TorchGeo 0.10.1 and Lightning 2.6.6, with code for a plain PyTorch loop and for Lightning’s trainer.predict.