Assessing the Robustness of Prithvi Geospatial Foundation Model for Coastal Habitat Mapping under Data Availability and Domain Shift Scenarios
This repository contains the code for the analysis presented in Assessing the Robustness of Prithvi Geospatial Foundation Model for Coastal Habitat Mapping under Data Availability and Domain Shift Scenarios. Fine-tuning dataset and fine-tuned model weights are also published on Hugging Face.
You need to have Conda installed before setting up the environment. You also need to have a GPU available on your machine.
git clone https://github.com/git@github.com:ClarkCGA/prithvi-coastal-habitat-mapping.git
cd prithvi-coastal-habitat-mappingconda create env -f environment.yamlconda activate coastal-habitat - Download the pre-trained weights for Prithvi EO 2.0 300M parameter and 600M parameter from Hugging Face.
- Adapt
src/custom_dataset.pyto the specification of your dataset if needed. - Update
configs/config_300m.yamlorconfigs/config_600m.yamlwith file paths for model weights, data directory, and outputs folder.
To fine-tune Prithvi EO 2.0 model variants using the pre-trained weights, run main_prithvi_aquaculture.py as following:
CUDA_VISIBLE_DEVICES=[replace_with_the_GPU_index] torchrun --rdzv_endpoint=0.0.0.0:29500 main_prithvi_aquaculture.py --config configs/[name_of_the_config]To train Prithvi EO 2.0 model variants from scratch, run main_prithvi_aquaculture_scratch.py as following:
CUDA_VISIBLE_DEVICES=[replace_with_the_GPU_index] torchrun --rdzv_endpoint=0.0.0.0:29500 main_prithvi_aquaculture_scratch.py --config configs/[name_of_the_config]You can use the same configs as in step 4 with no changes as prithvi_weight=None is hard-coded.
- To run the unet you need to use a different repo: multi-temporal-crop-classification-baseline
- Update
configs/config_unet.yamland add it to the config folder of the "multi-temporal-crop-classification-baseline" repo and follow the readme instructions of that repo.
- Make sure
configs/inference_config.yamlis up to date. - Run from CLI:
CUDA_VISIBLE_DEVICES=[replace_with_the_GPU_index] torchrun --rdzv_endpoint=0.0.0.0:29500 inference.py --config configs/[name_of_the_config]If you use this code, please cit the following paper: S. Khallaghi et al., "Assessing the Robustness of Prithvi Geospatial Foundation Model for Coastal Habitat Mapping under Data Availability and Domain Shift Scenarios," in IEEE Journal of Selected Topics in Applied Earth Observations and Remote Sensing, doi: 10.1109/JSTARS.2026.3698337.