Skip to content

Commit

Permalink
Update DATASET_GUIDE.md
Browse files Browse the repository at this point in the history
  • Loading branch information
VMarsocci authored Sep 25, 2024
1 parent 02bad1c commit eb8f7bc
Showing 1 changed file with 188 additions and 25 deletions.
213 changes: 188 additions & 25 deletions DATASET_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,77 @@

This document provides a detailed overview of the datasets used in this repository. For each dataset, you will find instructions on how to prepare the data, along with command-line examples for running models.

### HLSBurnScars

- The code supports automatic downloading of the dataset into `./data` folder.
- The basic experiment uses mean and std values for normalization and applies random cropping to align images with the size used for GFMs pretraining.
Below is a CLI example for running the experiment with the RemoteClip pretrained encoder and UperNet segmentation decoder:

```
torchrun --nnodes=1 --nproc_per_node=1 geofm_bench/run.py \
--config-name=train \
dataset=hlsburnscars \
encoder=remoteclip \
decoder=upernet\
preprocessing=default \
criterion=cross_entropy \
task=segmentation
```

### MADOS

- The code supports automatic downloading of the dataset into `./data` folder.
- The basic experiment uses mean and std values for normalization and applies random cropping to align images with the size used for GFMs pretraining.
Below is a CLI example for running the experiment with the RemoteClip pretrained encoder and UperNet segmentation decoder:

```
torchrun --nnodes=1 --nproc_per_node=1 geofm_bench/run.py \
--config-name=train \
dataset=mados \
encoder=remoteclip \
decoder=upernet\
preprocessing=default \
criterion=cross_entropy \
task=segmentation
```

### PASTIS

- The code supports automatic downloading of the dataset into `./data` folder.
- SPOT-6 images are available for single-temporal semantic segmentation, otherwise the basic experimental setup for this dataset is a multi-temporal multi-modal semantic segmentation task.
- Images are 64x64 patches, so a resize is needed to match input_size requirements of the encoders.
- For models that don't support multi-temporal data, each time frame is processed separately for feature extraction and then mapped into a single representation. This setup requires the configuration file `configs/decoder/upernet_mt.yaml`. Additionally, in the dataset configuration, specify the number of time frames, for example, `multi_temporal: 6`, where the latest six images are selected for both optical and SAR data. Below is a CLI example for running the experiment using the RemoteCLIP pretrained encoder and multi-temporal UPerNet with L-TAE processing of temporal information:

```
torchrun --nnodes=1 --nproc_per_node=1 geofm_bench/run.py \
--config-name=train \
dataset=pastis \
encoder=remoteclip \
decoder=upernet_mt_ltae \
preprocessing=mt_resize \
criterion=cross_entropy \
task=segmentation
```

### Sen1Floods11

- The code supports automatic downloading of the dataset into `./data` folder.
- The basic experiment uses mean and std values for nomralization and applies random cropping to align images with the size used for GFMs pretraining.
Below is a CLI example for running the experiment with the Prithvi pretrained encoder and UperNet segmentation decoder:
- The basic experiment uses mean and std values for normalization and applies random cropping to align images with the size used for GFMs pretraining.
Below is a CLI example for running the experiment with the RemoteClip pretrained encoder and UperNet segmentation decoder:

```
torchrun --nnodes=1 --nproc_per_node=1 run.py \
--config "configs/run/default.yaml" \
--encoder_config "configs/foundation_models/prithvi.yaml" \
--dataset_config "configs/datasets/sen1floods11.yaml" \
--segmentor_config "configs/segmentors/upernet.yaml" \
--augmentation_config "configs/augmentations/segmentation_default.yaml" \
--use_wandb
torchrun --nnodes=1 --nproc_per_node=1 geofm_bench/run.py \
--config-name=train \
dataset=sen1floods11 \
encoder=remoteclip \
decoder=upernet\
preprocessing=default \
criterion=cross_entropy \
task=segmentation
```

### xView2

- The dataset needs to be downloaded manually from the official website. This requires a registration and accepting the terms and conditions. On the download page, we need the datasets under `Datasets from the Challenge`, excluding the holdout set. Extract the datasets in the `./data/xView2/` folder, such that it contains e.g. `./data/xView2/tier3/images/...`.
- The `tier3` set does not come up labels in the form of images, so we first need to create them from the respective JSON data. We create a `masks` folder on the level of the `images` folder by running:

Expand All @@ -25,30 +81,137 @@ This document provides a detailed overview of the datasets used in this reposito
```
- The basic experimental setup for this dataset is a change detection task. Two images showing the same location are encoded using a foundation model as encoder. A smaller UPerNet model is trained to compute the 5-class segmentation mask from these encodings. Below is a CLI example for running the experiment with the Prithvi pretrained encoder:
```
torchrun --nnodes=1 --nproc_per_node=1 run.py \
--config configs/run/default.yaml \
--encoder_config configs/foundation_models/prithvi.yaml \
--dataset_config configs/datasets/xview2.yaml \
--segmentor_config configs/segmentors/siamdiffupernet.yaml \
--augmentation_config configs/augmentations/segmentation_oversampling.yaml \
--use_wandb
torchrun --nnodes=1 --nproc_per_node=1 geofm_bench/run.py \
--config-name=train \
dataset=xview2 \
encoder=prithvi \
decoder=siamdiffupernet \
preprocessing=default \
criterion=cross_entropy \
task=segmentation
```

### FiveBillionPixels

- The code is not supporting the automatic download. It will come soon.
- With respect to the original datasets, the images were cropped in 520x520 tiles, without overlapping. Few pixels on the borders of each original image got lost. The new class distribution is visible in the respective config.
- In the config, you can specify if using the CMYK or the NIR-RGB colour distribution.
- The basic experiment uses mean and std values for normalization and applies random cropping to align images with the size used for GFMs pretraining.
Below is a CLI example for running the experiment with the RemoteClip pretrained encoder and UperNet segmentation decoder:

```
torchrun --nnodes=1 --nproc_per_node=1 geofm_bench/run.py \
--config-name=train \
dataset=fivebillionpixels \
encoder=remoteclip \
decoder=upernet\
preprocessing=default \
criterion=cross_entropy \
task=segmentation
```

### DynamicEarthNet

- The code supports automatic downloading of the dataset into `./data` folder.
- The basic experimental setup for this dataset is a multi-temporal semantic segmentation task. For models that don't support multi-temporal data, each time frame is processed separately for feature extraction and then mapped into a single representation. This setup requires the configuration file `configs/decoder/upernet_mt.yaml`. Additionally, in the dataset configuration, specify the number of time frames, for example, `multi_temporal: 6`, where the latest six images are selected. Below is a CLI example for running the experiment using the RemoteCLIP pretrained encoder and multi-temporal UPerNet with L-TAE processing of temporal information:

```
torchrun --nnodes=1 --nproc_per_node=1 geofm_bench/run.py \
--config-name=train \
dataset=dynamicearthnet \
encoder=remoteclip \
decoder=upernet_mt_ltae \
preprocessing=mt_resize \
criterion=cross_entropy \
task=segmentation
```

### Crop Type Mapping (South Sudan)

- The code supports automatic downloading of the dataset into `./data` folder.
- Images are 64x64 patches, so a resize is needed to match input_size requirements of the encoders.
- The original dataset contains corrupted files, which are skipped during the experiment. We follow the dataset paper to use the most frequent 4 classes and the others are ignored.
- The basic experimental setup for this dataset is a multi-temporal multi-modal semantic segmentation task. For models that don't support multi-temporal data, each time frame is processed separately for feature extraction and then mapped into a single representation. This setup requires the configuration file `configs/segmentors/upernet_mt.yaml`. Additionally, in the dataset configuration, specify the number of time frames, for example, `multi_temporal: 6`, where the latest six images are selected for both optical and SAR data. Below is a CLI example for running the experiment using the CROMA pretrained encoder, which jointly processes optical and SAR information:
- The basic experimental setup for this dataset is a multi-temporal multi-modal semantic segmentation task. For models that don't support multi-temporal data, each time frame is processed separately for feature extraction and then mapped into a single representation. This setup requires the configuration file `configs/decoder/upernet_mt.yaml`. Additionally, in the dataset configuration, specify the number of time frames, for example, `multi_temporal: 6`, where the latest six images are selected for both optical and SAR data. Below is a CLI example for running the experiment using the RemoteCLIP pretrained encoder and multi-temporal UPerNet with L-TAE processing of temporal information:

```
torchrun --nnodes=1 --nproc_per_node=1 geofm_bench/run.py \
--config-name=train \
dataset=croptypemapping \
encoder=remoteclip \
decoder=upernet_mt_ltae \
preprocessing=mt_resize \
criterion=cross_entropy \
task=segmentation
```

### SpaceNet 7

- The code supports automatic downloading of the dataset into `./data` folder.
- The basic experiment uses mean and std values for normalization and applies random cropping to align images with the size used for GFMs pretraining.
- The dataset supports building mapping and change detection.
- Below is a CLI example for running the building mapping (i.e. single temporal semantic segmentation) experiment with the RemoteClip pretrained encoder and UperNet segmentation decoder:

```
torchrun --nnodes=1 --nproc_per_node=1 geofm_bench/run.py \
--config-name=train \
dataset=spacenet7 \
encoder=remoteclip \
decoder=upernet\
preprocessing=default \
criterion=cross_entropy \
task=segmentation
```
- Here is an example to run change detection:
```
torchrun --nnodes=1 --nproc_per_node=1 geofm_bench/run.py \
--config-name=train \
dataset=spacenet7 \
encoder=remoteclip \
decoder=siamdiffupernet\
preprocessing=default \
criterion=cross_entropy \
task=segmentation
```

### AI4SmallFarms

- The code supports automatic downloading of the dataset into `./data` folder.
- The original dataset contains vector files as well as Google Maps (GM) files, which are skipped during the experiment. Only the .tif Sentinel-2 images and delineation labels are kept after downloading.
- The dataset is uni-temporal, and the labels contain only two classes (farm boundary or background). For training using the Prithvi encoder, the following command should be used:
- The dataset is uni-temporal, and the labels contain only two classes (farm boundary or background). For training using the RemoteCLIP encoder, the following command should be used:

```
torchrun --nnodes=1 --nproc_per_node=1 geofm_bench/run.py \
--config-name=train \
dataset=ai4smallfarms \
encoder=remoteclip \
decoder=upernet\
preprocessing=default \
criterion=cross_entropy \
task=segmentation
```
torchrun --nnodes=1 --nproc_per_node=1 run.py \
--config "configs/run/default.yaml" \
--encoder_config "configs/foundation_models/prithvi.yaml" \
--dataset_config "configs/datasets/ai4smallfarms.yaml" \
--segmentor_config "configs/segmentors/upernet_binary.yaml" \
--augmentation_config "configs/augmentations/ai4smallfarms.yaml" \
--use_wandb

### BioMassters
- The code is not supporting the automatic download. It will come soon.
- The dataset is multi-modal and multi-temporal, so the default command is:
```
torchrun --nnodes=1 --nproc_per_node=1 geofm_bench/run.py \
--config-name=train \
dataset=biomassters \
encoder=prithvi \
decoder=reg_upernet_mt \
preprocessing=default \
criterion=cross_entropy \
task=regression
```
- If you want to try single temporal regression, you can use:
```
torchrun --nnodes=1 --nproc_per_node=1 geofm_bench/run.py \
--config-name=train \
dataset=biomassters \
encoder=prithvi \
decoder=reg_upernet \
preprocessing=default \
criterion=cross_entropy \
task=regression
```
In this case, you can specify in the `temp` parameter which frame you want to use.

0 comments on commit eb8f7bc

Please sign in to comment.