Snow segmentation of Sentinel-2 imagery (Slovenia)
Binary snow segmentation from 13-band Sentinel-2 imagery, trained for the paper Semantična segmentacija zasneženih površin v Sloveniji na osnovi posnetkov Sentinel-2 (Semantic Segmentation of Snowcovered Areas in Slovenia Based on Sentinel-2 Imagery), GIS v Sloveniji 18, 2026.
Authors: Domen Kavran¹, Mihaela Triglav Čekada², Niko Lukač¹ ¹ University of Maribor, FERI · ² Geodetic Institute of Slovenia
Code: SAMPA-Project/semantic-segmentation-snowcovered-areas-Slovenia-sentinel-2 Dataset: Global Sentinel-2 Snow Semantic Segmentation Dataset with Dynamic World Labels
Models
| Folder | Architecture | Input bands | Loss |
|---|---|---|---|
GASSL-basic/ | ResNet-50 encoder initialised from GASSL (MoCo, fMoW) + UPerNet decoder | all 13 | Cross-entropy |
Unet/ | U-Net, ResNet-34 encoder (ImageNet init) | all 13 | Cross-entropy |
Each folder contains:
snow-best.ckpt: model weightschannel_stats.json: per-band means and standard deviations used for input standardisation
GASSL-basic achieved the best result, a mean IoU of 0.4027 on the independent test set (Martuljek mountains and Prisojnik, where snowfields persist through summer). Using all 13 bands outperformed RGB only.
Input and output
- Input: Sentinel-2 L1C top-of-atmosphere GeoTIFF (
COPERNICUS/S2_HARMONIZED) with 13 bands in the order B1, B2, B3, B4, B5, B6, B7, B8, B8A, B9, B10, B11, B12. Training tiles were 0.5–4 km wide at a base scale of 10 m, cloud-masked with QA60. - Preprocessing: bilinear resize to 512 × 512, negatives clipped to 0, division by the image maximum (over all bands), then per-band standardisation with
channel_stats.json(done inside the model). - Output: 2-class logits at 1024 × 1024. Softmax channel 1 is the snow probability. Training labels are Dynamic World
snow_and_icewith probability ≥ 0.51. - Threshold: τ = 0.25 worked best for GASSL; 0.01, 0.1, 0.25 and 0.5 were evaluated.
Usage
import sys
!{sys.executable} -m pip install torch torchvision segmentation-models-pytorch huggingface_hub rasterio
from huggingface_hub import hf_hub_download
import sys, os
sys.path.insert(0, os.path.dirname(hf_hub_download("SAMPA-Project/snow-segmentation-slovenia-sentinel-2", "snow_model.py")))
import snow_model as sm
model, stats = sm.load_model("GASSL-basic") # or "Unet"
image = sm.read_sentinel2("scene.tif", stats["rgb_indexes"])
snow_prob = sm.predict(model, image) # (1024, 1024)
snow_mask = (snow_prob >= 0.25).astype("uint8")
sm.save_geotiff(snow_mask, "scene.tif", "scene_snow.tif", dtype="uint8")
snow_model.py rebuilds the original MyModel without PyTorch Lightning or the foundation-model pretraining files, so the training checkpoints load with strict=True and give identical outputs. demo_snow_segmentation.ipynb is the full demo, the same as the one in the GitHub repository.
Limitations
The labels come from Dynamic World, not manual annotation, so the models inherit its errors. Clouds and cloud shadows can be confused with snow. Training and testing focused on Slovenia and the Julian Alps.
Acknowledgements
Co-funded by the Slovenian Research and Innovation Agency (ARIS), basic research project J7-50095 and research programme P2-0041. Sentinel-2 imagery: EU Copernicus programme.