Skip to content

Commit ef29638

Browse files
authored
Merge pull request #57 from allenai/favyen/20241022-maldives-updates
Add model that inputs PlanetScope + Sentinel-2 images.
2 parents cba7754 + 38d7d8a commit ef29638

File tree

7 files changed

+490
-5
lines changed

7 files changed

+490
-5
lines changed

data/maldives_ecosystem_mapping/config_mapbox.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,6 @@
6262
},
6363
"tile_store": {
6464
"name": "file",
65-
"root_dir": "tiles"
65+
"root_dir": "gs://rslearn-eai/datasets/maldives_ecosystem_mapping/dataset_v1/20240924/tiles"
6666
}
6767
}

data/maldives_ecosystem_mapping/config_planetscope.json

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,72 @@
9797
"time_offset": "-90d"
9898
},
9999
"type": "raster"
100+
},
101+
"sentinel2_with_planet": {
102+
"alias": "sentinel2",
103+
"band_sets": [
104+
{
105+
"bands": [
106+
"B02",
107+
"B03",
108+
"B04",
109+
"B08"
110+
],
111+
"dtype": "uint16",
112+
"format": {
113+
"always_enable_tiling": true,
114+
"name": "geotiff"
115+
},
116+
"zoom_offset": -2
117+
},
118+
{
119+
"bands": [
120+
"B05",
121+
"B06",
122+
"B07",
123+
"B8A",
124+
"B11",
125+
"B12"
126+
],
127+
"dtype": "uint16",
128+
"format": {
129+
"always_enable_tiling": true,
130+
"name": "geotiff"
131+
},
132+
"zoom_offset": -3
133+
},
134+
{
135+
"bands": [
136+
"B01",
137+
"B09",
138+
"B10"
139+
],
140+
"dtype": "uint16",
141+
"format": {
142+
"always_enable_tiling": true,
143+
"name": "geotiff"
144+
},
145+
"zoom_offset": -4
146+
}
147+
],
148+
"data_source": {
149+
"duration": "180d",
150+
"index_cache_dir": "gs://rslearn-eai/datasets/maldives_ecosystem_mapping/dataset_v1/20240924/cache/sentinel2",
151+
"max_time_delta": "1d",
152+
"name": "rslearn.data_sources.gcp_public_data.Sentinel2",
153+
"query_config": {
154+
"max_matches": 6,
155+
"space_mode": "CONTAINS"
156+
},
157+
"sort_by": "cloud_cover",
158+
"time_offset": "-90d",
159+
"use_rtree_index": false
160+
},
161+
"type": "raster"
100162
}
101163
},
102164
"tile_store": {
103165
"name": "file",
104-
"root_dir": "tiles"
166+
"root_dir": "gs://rslearn-eai/datasets/maldives_ecosystem_mapping/dataset_v1/20240924/tiles"
105167
}
106168
}
Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
model:
2+
class_path: rslp.maldives_ecosystem_mapping.train.CMLightningModule
3+
init_args:
4+
model:
5+
class_path: rslearn.models.multitask.MultiTaskModel
6+
init_args:
7+
encoder:
8+
- class_path: rslearn.models.simple_time_series.SimpleTimeSeries
9+
init_args:
10+
encoder:
11+
class_path: rslearn.models.swin.Swin
12+
init_args:
13+
pretrained: true
14+
output_layers: [1, 3, 5, 7]
15+
input_channels: 17
16+
image_channels: 17
17+
groups: [[0, 1, 2, 3, 4, 5]]
18+
decoders:
19+
segment:
20+
- class_path: rslearn.models.unet.UNetDecoder
21+
init_args:
22+
in_channels: [[4, 128], [8, 256], [16, 512], [32, 1024]]
23+
out_channels: 17
24+
conv_layers_per_resolution: 2
25+
- class_path: rslearn.train.tasks.segmentation.SegmentationHead
26+
lr: 0.0001
27+
plateau: true
28+
plateau_factor: 0.2
29+
plateau_patience: 2
30+
plateau_min_lr: 0
31+
plateau_cooldown: 10
32+
data:
33+
class_path: rslearn.train.data_module.RslearnDataModule
34+
init_args:
35+
path: gcs://rslearn-eai/datasets/maldives_ecosystem_mapping/dataset_v1/20241017/
36+
inputs:
37+
planetscope:
38+
data_type: "raster"
39+
layers: ["planetscope"]
40+
bands: ["b01", "b02", "b03", "b04", "b05", "b06", "b07", "b08"]
41+
passthrough: true
42+
planetscope.1:
43+
data_type: "raster"
44+
layers: ["planetscope.1"]
45+
bands: ["b01", "b02", "b03", "b04", "b05", "b06", "b07", "b08"]
46+
passthrough: true
47+
planetscope.2:
48+
data_type: "raster"
49+
layers: ["planetscope.2"]
50+
bands: ["b01", "b02", "b03", "b04", "b05", "b06", "b07", "b08"]
51+
passthrough: true
52+
planetscope.3:
53+
data_type: "raster"
54+
layers: ["planetscope.3"]
55+
bands: ["b01", "b02", "b03", "b04", "b05", "b06", "b07", "b08"]
56+
passthrough: true
57+
planetscope.4:
58+
data_type: "raster"
59+
layers: ["planetscope.4"]
60+
bands: ["b01", "b02", "b03", "b04", "b05", "b06", "b07", "b08"]
61+
passthrough: true
62+
planetscope.5:
63+
data_type: "raster"
64+
layers: ["planetscope.5"]
65+
bands: ["b01", "b02", "b03", "b04", "b05", "b06", "b07", "b08"]
66+
passthrough: true
67+
sentinel2_0:
68+
data_type: "raster"
69+
layers: ["sentinel2_with_planet"]
70+
bands: ["B04", "B03", "B02", "B05", "B06", "B07", "B08", "B11", "B12"]
71+
passthrough: true
72+
sentinel2_1:
73+
data_type: "raster"
74+
layers: ["sentinel2_with_planet.1"]
75+
bands: ["B04", "B03", "B02", "B05", "B06", "B07", "B08", "B11", "B12"]
76+
passthrough: true
77+
sentinel2_2:
78+
data_type: "raster"
79+
layers: ["sentinel2_with_planet.2"]
80+
bands: ["B04", "B03", "B02", "B05", "B06", "B07", "B08", "B11", "B12"]
81+
passthrough: true
82+
sentinel2_3:
83+
data_type: "raster"
84+
layers: ["sentinel2_with_planet.3"]
85+
bands: ["B04", "B03", "B02", "B05", "B06", "B07", "B08", "B11", "B12"]
86+
passthrough: true
87+
sentinel2_4:
88+
data_type: "raster"
89+
layers: ["sentinel2_with_planet.4"]
90+
bands: ["B04", "B03", "B02", "B05", "B06", "B07", "B08", "B11", "B12"]
91+
passthrough: true
92+
sentinel2_5:
93+
data_type: "raster"
94+
layers: ["sentinel2_with_planet.5"]
95+
bands: ["B04", "B03", "B02", "B05", "B06", "B07", "B08", "B11", "B12"]
96+
passthrough: true
97+
targets:
98+
data_type: "raster"
99+
layers: ["label"]
100+
bands: ["label"]
101+
is_target: true
102+
task:
103+
class_path: rslearn.train.tasks.multi_task.MultiTask
104+
init_args:
105+
tasks:
106+
segment:
107+
class_path: rslearn.train.tasks.segmentation.SegmentationTask
108+
init_args:
109+
num_classes: 17
110+
remap_values: [[0, 1], [0, 255]]
111+
zero_is_invalid: true
112+
metric_kwargs:
113+
average: "micro"
114+
input_mapping:
115+
segment:
116+
targets: "targets"
117+
batch_size: 8
118+
num_workers: 32
119+
default_config:
120+
transforms:
121+
- class_path: rslearn.train.transforms.concatenate.Concatenate
122+
init_args:
123+
selections:
124+
planetscope: []
125+
sentinel2_0: []
126+
planetscope.1: []
127+
sentinel2_1: []
128+
planetscope.2: []
129+
sentinel2_2: []
130+
planetscope.3: []
131+
sentinel2_3: []
132+
planetscope.4: []
133+
sentinel2_4: []
134+
planetscope.5: []
135+
sentinel2_5: []
136+
output_selector: image
137+
- class_path: rslearn.train.transforms.normalize.Normalize
138+
init_args:
139+
mean: 0
140+
std: 255
141+
train_config:
142+
patch_size: 128
143+
transforms:
144+
- class_path: rslearn.train.transforms.concatenate.Concatenate
145+
init_args:
146+
selections:
147+
planetscope: []
148+
sentinel2_0: []
149+
planetscope.1: []
150+
sentinel2_1: []
151+
planetscope.2: []
152+
sentinel2_2: []
153+
planetscope.3: []
154+
sentinel2_3: []
155+
planetscope.4: []
156+
sentinel2_4: []
157+
planetscope.5: []
158+
sentinel2_5: []
159+
output_selector: image
160+
- class_path: rslearn.train.transforms.normalize.Normalize
161+
init_args:
162+
mean: 0
163+
std: 255
164+
- class_path: rslearn.train.transforms.flip.Flip
165+
init_args:
166+
image_selectors: ["image", "target/segment/classes", "target/segment/valid"]
167+
groups: ["crops_planetscope"]
168+
tags:
169+
split: train
170+
val_config:
171+
patch_size: 128
172+
groups: ["crops_planetscope"]
173+
tags:
174+
split: val
175+
test_config:
176+
patch_size: 128
177+
groups: ["crops_planetscope"]
178+
tags:
179+
split: val
180+
predict_config:
181+
groups: ["images_planetscope"]
182+
load_all_patches: true
183+
skip_targets: true
184+
patch_size: 512
185+
trainer:
186+
max_epochs: 500
187+
callbacks:
188+
- class_path: lightning.pytorch.callbacks.LearningRateMonitor
189+
init_args:
190+
logging_interval: "epoch"
191+
- class_path: rslearn.train.prediction_writer.RslearnWriter
192+
init_args:
193+
path: gcs://rslearn-eai/datasets/maldives_ecosystem_mapping/dataset_v1/20241017/
194+
output_layer: output
195+
selector: ["segment"]
196+
- class_path: lightning.pytorch.callbacks.ModelCheckpoint
197+
init_args:
198+
save_top_k: 1
199+
every_n_epochs: 50
200+
save_last: true
201+
monitor: val_segment/accuracy
202+
mode: max
203+
rslp_project: maldives_ecosystem_mapping
204+
rslp_experiment: planetscope_plus_sentinel2_data_20241017_satlaspretrain_flip_crop128_00

data/maldives_ecosystem_mapping/config_sentinel2.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
],
7878
"data_source": {
7979
"duration": "180d",
80-
"index_cache_dir": "cache/sentinel2",
80+
"index_cache_dir": "gs://rslearn-eai/datasets/maldives_ecosystem_mapping/dataset_v1/20240924/cache/sentinel2",
8181
"max_time_delta": "1d",
8282
"name": "rslearn.data_sources.gcp_public_data.Sentinel2",
8383
"query_config": {
@@ -93,6 +93,6 @@
9393
},
9494
"tile_store": {
9595
"name": "file",
96-
"root_dir": "tiles"
96+
"root_dir": "gs://rslearn-eai/datasets/maldives_ecosystem_mapping/dataset_v1/20240924/tiles"
9797
}
9898
}

data/maldives_ecosystem_mapping/config_skysat.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,6 @@
124124
},
125125
"tile_store": {
126126
"name": "file",
127-
"root_dir": "tiles"
127+
"root_dir": "gs://rslearn-eai/datasets/maldives_ecosystem_mapping/dataset_v1/20240924/tiles"
128128
}
129129
}

0 commit comments

Comments
 (0)