Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A copy of pr89 but from the main repo #90

Merged
merged 26 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
7e265b5
only fixed bugs
LeungTsang Oct 11, 2024
776366d
only fixed bugs
LeungTsang Oct 11, 2024
c82eed2
only fixed bugs
LeungTsang Oct 11, 2024
1621375
only fixed bugs
LeungTsang Oct 11, 2024
5710159
only fixed bugs
LeungTsang Oct 11, 2024
8c3a376
only fixed bugs
LeungTsang Oct 11, 2024
fc50576
fixed evaluator
LeungTsang Oct 13, 2024
11dd64b
Revert "fixed evaluator"
LeungTsang Oct 13, 2024
94f1f90
fixed evaluator
LeungTsang Oct 13, 2024
4152afe
fixed evaluator
LeungTsang Oct 13, 2024
7ccc8db
set default test batch size as 1
LeungTsang Oct 13, 2024
b7d05b9
Update pastis dataset
gle-bellier Oct 15, 2024
1dbb46c
Update docstring and output shapes/types
gle-bellier Oct 15, 2024
ad02515
Update single temporal datasets output shape to (C T H W)
gle-bellier Oct 15, 2024
0502ce2
Update dataset section
gle-bellier Oct 15, 2024
5d817a6
Remove legacy script
gle-bellier Oct 15, 2024
3919d82
Minor change to ensure output dim is a list
gle-bellier Oct 15, 2024
8af4c51
Remove exp
gle-bellier Oct 15, 2024
09e02f7
fix ssl4eomae-sar encoder, add a function to save final ckpt
yurujaja Oct 15, 2024
5c2fd24
fix spectralgpt, remove print in satlasnet
yurujaja Oct 15, 2024
210a5bc
minor fix for unet, and reg_upernet
yurujaja Oct 15, 2024
0b87ca5
change dataset target type to Long
yurujaja Oct 15, 2024
83c22fb
Add LTAE adaptor for inputs with different number of channels
gle-bellier Oct 15, 2024
0376156
Adapt SegUperNetMT to ltae + ltae adaptor
gle-bellier Oct 15, 2024
24e08c0
Update SegUperNetMT and RegUperNetMT
gle-bellier Oct 15, 2024
efea90b
Minor changes
gle-bellier Oct 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,16 +177,16 @@ We have designed the repo to allow for using your own datasets with minimal effo
1. **Implement a Dataset Class**:

- In the `pangaea/datasets/` directory, create a new Python file named after your dataset (e.g., `my_dataset.py`).
- Implement a class that inherits from `GeoFMDataset`. You can check it in `pangaea/datasets/base.py`.
- Implement a class that inherits from `RawGeoFMDataset`. You can check it in `pangaea/datasets/base.py`.
- Be sure that your dataset is instantiated with all the required parameters from the `GeoFMDataset`. You can also add new parameters.
- Implement the required methods: `__init__`, `__len__`, `__getitem__`, and `download` (if applicable, otherwise a `NotImplementedError is raised`).
- **Example**:

```python
import torch
from pangaea.datasets.base import GeoFMDataset
from pangaea.datasets.base import RawGeoFMDataset

class MyDataset(GeoFMDataset):
class MyDataset(RawGeoFMDataset):
def __init__(
self,
split: str,
Expand Down Expand Up @@ -236,6 +236,25 @@ We have designed the repo to allow for using your own datasets with minimal effo
return len(self.file_list)

def __getitem__(self, index):
"""Returns the i-th item of the dataset.

Args:
i (int): index of the item

Raises:
NotImplementedError: raise if the method is not implemented

Returns:
dict[str, torch.Tensor | dict[str, torch.Tensor]]: output dictionary follwing the format
{"image":
{
"optical": torch.Tensor of shape (C T H W) (where T=1 if single-temporal dataset),
"sar": torch.Tensor of shape (C T H W) (where T=1 if single-temporal dataset),
},
"target": torch.Tensor of shape (H W) of type torch.int64 for segmentation, torch.float for
regression datasets.,
"metadata": dict}.
"""
# Load your data and labels here
image = ... # Load image
target = ... # Load target label or mask
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
**/__pycache__/
*.egg-info

aaa_mystuff/
work-dir/
outputs/
old_files/
pretrained/
pretrained_models/
work-dir/
wandb/
data/*
data
pretrained_models
# Scenes for mados tiny
# Wow gitignore pattern mathcing is a mess
!data/mados
Expand Down
16 changes: 12 additions & 4 deletions configs/dataset/dynamicen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ distribution:
- 0.28
- 0.08

sample_dates:
- 1
- 5
- 10
- 15
- 20
- 25

# data stats
bands:
optical:
Expand All @@ -36,15 +44,15 @@ bands:

data_mean:
optical:
- 1042.59240722656
- 915.618408203125
- 671.260559082031
- 915.618408203125
- 1042.59240722656
- 2605.20922851562
data_std:
optical:
- 957.958435058593
- 715.548767089843
- 596.943908691406
- 715.548767089843
- 957.958435058593
- 1059.90319824218

data_min:
Expand Down
8 changes: 4 additions & 4 deletions configs/dataset/pastis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ multi_modal: True
#limited_label: False

# classes
ignore_index: 0
num_classes: 19
ignore_index: 19
num_classes: 20
classes:
- Background
- Meadow
Expand All @@ -32,7 +32,7 @@ classes:
- Orchard
- Mixed Cereal
- Sorghum
#- Void Label
- Void Label
distribution:
- 0.00000
- 0.25675
Expand All @@ -53,7 +53,7 @@ distribution:
- 0.02460
- 0.00696
- 0.00580
#- 0.29476
- 0.29476

bands:
optical:
Expand Down
2 changes: 2 additions & 0 deletions configs/encoder/croma_joint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ output_layers:
- 5
- 7
- 11

output_dim: 1024
2 changes: 2 additions & 0 deletions configs/encoder/croma_optical.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ output_layers:
- 5
- 7
- 11

output_dim: 1024
4 changes: 3 additions & 1 deletion configs/encoder/croma_sar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ output_layers:
- 3
- 5
- 7
- 11
- 11

output_dim: 1024
2 changes: 2 additions & 0 deletions configs/encoder/dofa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ output_layers:
- 5
- 7
- 11

output_dim: 768
6 changes: 5 additions & 1 deletion configs/encoder/gfmswin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ in_chans: 3
t_patch_size: 3
depth: 12
embed_dim: 128
output_dim: 1024
img_size: 192 # fixed to 192 to avoid interpolation in checkpoints which leads to drop in performance
depths: [ 2, 2, 18, 2 ]
num_heads: [ 4, 8, 16, 32 ]
Expand All @@ -28,3 +27,8 @@ output_layers:
- 2
- 3

output_dim:
- 256
- 512
- 1024
- 1024
2 changes: 2 additions & 0 deletions configs/encoder/prithvi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ output_layers:
- 5
- 7
- 11

output_dim: 768
4 changes: 3 additions & 1 deletion configs/encoder/remoteclip.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ output_layers:
- 3
- 5
- 7
- 11
- 11

output_dim: 768
13 changes: 12 additions & 1 deletion configs/encoder/satlasnet_mi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ download_url: null
model_identifier: Sentinel2_SwinB_MI_MS # Multi-Image Multi-Spectral
fpn: False
input_size: 128
output_dim: 1024

input_bands:
optical:
Expand All @@ -23,3 +22,15 @@ input_bands:
- B8
- B11
- B12

output_layers:
- 0
- 1
- 2
- 3

output_dim:
- 128
- 256
- 512
- 1024
13 changes: 12 additions & 1 deletion configs/encoder/satlasnet_si.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ download_url: null
model_identifier: Sentinel2_SwinB_SI_MS # Single Image Multi-Spectral
fpn: False
input_size: 128
output_dim: 1024

input_bands:
optical:
Expand All @@ -23,3 +22,15 @@ input_bands:
- B8
- B11
- B12

output_layers:
- 0
- 1
- 2
- 3

output_dim:
- 128
- 256
- 512
- 1024
2 changes: 2 additions & 0 deletions configs/encoder/scalemae.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ output_layers:
- 11
- 15
- 23

output_dim: 1024
3 changes: 2 additions & 1 deletion configs/encoder/spectralgpt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ encoder_weights: ./pretrained_models/SpectralGPT+.pth
download_url: https://zenodo.org/records/8412455/files/SpectralGPT+.pth

input_size: 128
output_dim: 3072 # 768 * (in_chans / t_patch_size)

in_chans: 12 # number of spectral bands
t_patch_size: 3
depth: 12
Expand Down Expand Up @@ -34,4 +34,5 @@ output_layers:
- 7
- 11

output_dim: 3072 # 768 * (in_chans / t_patch_size)

2 changes: 2 additions & 0 deletions configs/encoder/ssl4eo_data2vec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ output_layers:
- 5
- 7
- 11

output_dim: 384
2 changes: 2 additions & 0 deletions configs/encoder/ssl4eo_dino.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ output_layers:
- 5
- 7
- 11

output_dim: 384
4 changes: 3 additions & 1 deletion configs/encoder/ssl4eo_mae_optical.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ output_layers:
- 3
- 5
- 7
- 11
- 11

output_dim: 384
4 changes: 3 additions & 1 deletion configs/encoder/ssl4eo_mae_sar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ output_layers:
- 3
- 5
- 7
- 11
- 11

output_dim: 384
2 changes: 2 additions & 0 deletions configs/encoder/ssl4eo_moco.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ output_layers:
- 5
- 7
- 11

output_dim: 384
6 changes: 6 additions & 0 deletions configs/encoder/unet_encoder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ topology: [64, 128, 256, 512,]

input_bands: ${dataset.bands}

output_dim:
- 64
- 128
- 256
- 512

52 changes: 19 additions & 33 deletions configs/preprocessing/reg_default.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,21 @@
train:
- _target_: pangaea.engine.data_preprocessor.RegPreprocessor
# overwritten in run
dataset: null
encoder: null
train:
_target_: pangaea.engine.data_preprocessor.Preprocessor
preprocessor_cfg:
- _target_: pangaea.engine.data_preprocessor.RandomCropToEncoder
- _target_: pangaea.engine.data_preprocessor.BandFilter
- _target_: pangaea.engine.data_preprocessor.NormalizeMeanStd
- _target_: pangaea.engine.data_preprocessor.BandPadding

- _target_: pangaea.engine.data_preprocessor.NormalizeMinMax
# overwritten in run
dataset: null
encoder: null
data_min: -1
data_max: 1
val:
_target_: pangaea.engine.data_preprocessor.Preprocessor
preprocessor_cfg:
- _target_: pangaea.engine.data_preprocessor.BandFilter
- _target_: pangaea.engine.data_preprocessor.NormalizeMeanStd
- _target_: pangaea.engine.data_preprocessor.BandPadding

- _target_: pangaea.engine.data_preprocessor.RandomCropToEncoder
# overwritten in run
dataset: null
encoder: null

test:
- _target_: pangaea.engine.data_preprocessor.RegPreprocessor
# overwritten in run
dataset: null
encoder: null

- _target_: pangaea.engine.data_preprocessor.NormalizeMinMax
# overwritten in run
dataset: null
encoder: null
data_min: -1
data_max: 1

- _target_: pangaea.engine.data_preprocessor.Tile
# overwritten in run
dataset: null
encoder: null
test:
_target_: pangaea.engine.data_preprocessor.Preprocessor
preprocessor_cfg:
- _target_: pangaea.engine.data_preprocessor.BandFilter
- _target_: pangaea.engine.data_preprocessor.NormalizeMeanStd
- _target_: pangaea.engine.data_preprocessor.BandPadding
Loading