This is the official repository for the paper "On the Generalizability of Foundation Models for Crop Type Mapping", accepted at IEEE IGARSS 2025.
Authors: Yi-Chia Chang, Adam J. Stewart, Favyen Bastani, Piper Wolters, Shreya Kannan, George R. Huber, Jingtong Wang, Arindam Banerjee.
-
Clone the repository:
git clone https://github.com/yichiac/crop-type-transfer-learning.git cd crop-type-transfer-learning -
Create a virtual environment and activate it:
python3 -m venv env source env/bin/activate -
Install the required packages:
pip install -r requirements.txt
The dataset is available on the HuggingFace. Login to download the crop type datasets.
huggingface-cli loginYou can run the following Python script to download the dataset:
from huggingface_hub import snapshot_download
snapshot_download(repo_id="torchgeo/harmonized_global_crops", repo_type="dataset", local_dir="harmonized_global_crops")Sentinel-2 donwload pipeline can be found in Ai2 rslearn_projects.
Follow the files in train-test-splits/ to split the dataset into training and testing sets. For demo, you can run the following command to create train/test data for a CDL OOD experiment:
python3 train-test-splits/create_splits.pyRun the training script for CDL with SSL4EO-S12 pre-trained weights:
python3 -m torchgeo fit --config experiments/fewshot/cdl_100_ood_ssl4eo.yaml \
data.dict_kwargs.sentinel2_paths='./harmonized_global_crops/sentinel2_subsample_cdl_2023_100_ood' \
--seed_everything 0After completing training, you can use the checkpoints to test on the data.
python3 -m torchgeo test --config experiments/fewshot/cdl_100_ood_ssl4eo.yaml \
data.dict_kwargs.sentinel2_paths='./harmonized_global_crops/sentinel2_subsample_test' \
--seed_everything 0 \
--ckpt_path=...To cite our IGARSS publication, use the following citation:
@INPROCEEDINGS{chang2025croptypetransfer,
author={Chang, Yi-Chia and Stewart, Adam J. and Bastani, Favyen and Wolters, Piper and Kannan, Shreya and Huber, George R. and Wang, Jingtong and Banerjee, Arindam},
booktitle={IGARSS 2025 - 2025 IEEE International Geoscience and Remote Sensing Symposium},
title={On the Generalizability of Foundation Models for Crop Type Mapping},
year={2025},
pages={948-953},
doi={10.1109/IGARSS55030.2025.11242260}
}