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

Add model that inputs PlanetScope + Sentinel-2 images. #57

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion data/maldives_ecosystem_mapping/config_mapbox.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@
},
"tile_store": {
"name": "file",
"root_dir": "tiles"
"root_dir": "gs://rslearn-eai/datasets/maldives_ecosystem_mapping/dataset_v1/20240924/tiles"
}
}
64 changes: 63 additions & 1 deletion data/maldives_ecosystem_mapping/config_planetscope.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,72 @@
"time_offset": "-90d"
},
"type": "raster"
},
"sentinel2_with_planet": {
"alias": "sentinel2",
"band_sets": [
{
"bands": [
"B02",
"B03",
"B04",
"B08"
],
"dtype": "uint16",
"format": {
"always_enable_tiling": true,
"name": "geotiff"
},
"zoom_offset": -2
},
{
"bands": [
"B05",
"B06",
"B07",
"B8A",
"B11",
"B12"
],
"dtype": "uint16",
"format": {
"always_enable_tiling": true,
"name": "geotiff"
},
"zoom_offset": -3
},
{
"bands": [
"B01",
"B09",
"B10"
],
"dtype": "uint16",
"format": {
"always_enable_tiling": true,
"name": "geotiff"
},
"zoom_offset": -4
}
],
"data_source": {
"duration": "180d",
"index_cache_dir": "gs://rslearn-eai/datasets/maldives_ecosystem_mapping/dataset_v1/20240924/cache/sentinel2",
"max_time_delta": "1d",
"name": "rslearn.data_sources.gcp_public_data.Sentinel2",
"query_config": {
"max_matches": 6,
"space_mode": "CONTAINS"
},
"sort_by": "cloud_cover",
"time_offset": "-90d",
"use_rtree_index": false
},
"type": "raster"
}
},
"tile_store": {
"name": "file",
"root_dir": "tiles"
"root_dir": "gs://rslearn-eai/datasets/maldives_ecosystem_mapping/dataset_v1/20240924/tiles"
}
}
204 changes: 204 additions & 0 deletions data/maldives_ecosystem_mapping/config_planetscope_plus_sentinel2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
model:
class_path: rslp.maldives_ecosystem_mapping.train.CMLightningModule
init_args:
model:
class_path: rslearn.models.multitask.MultiTaskModel
init_args:
encoder:
- class_path: rslearn.models.simple_time_series.SimpleTimeSeries
init_args:
encoder:
class_path: rslearn.models.swin.Swin
init_args:
pretrained: true
output_layers: [1, 3, 5, 7]
input_channels: 17
image_channels: 17
groups: [[0, 1, 2, 3, 4, 5]]
decoders:
segment:
- class_path: rslearn.models.unet.UNetDecoder
init_args:
in_channels: [[4, 128], [8, 256], [16, 512], [32, 1024]]
out_channels: 17
conv_layers_per_resolution: 2
- class_path: rslearn.train.tasks.segmentation.SegmentationHead
lr: 0.0001
plateau: true
plateau_factor: 0.2
plateau_patience: 2
plateau_min_lr: 0
plateau_cooldown: 10
data:
class_path: rslearn.train.data_module.RslearnDataModule
init_args:
path: gcs://rslearn-eai/datasets/maldives_ecosystem_mapping/dataset_v1/20241017/
inputs:
planetscope:
data_type: "raster"
layers: ["planetscope"]
bands: ["b01", "b02", "b03", "b04", "b05", "b06", "b07", "b08"]
passthrough: true
planetscope.1:
data_type: "raster"
layers: ["planetscope.1"]
bands: ["b01", "b02", "b03", "b04", "b05", "b06", "b07", "b08"]
passthrough: true
planetscope.2:
data_type: "raster"
layers: ["planetscope.2"]
bands: ["b01", "b02", "b03", "b04", "b05", "b06", "b07", "b08"]
passthrough: true
planetscope.3:
data_type: "raster"
layers: ["planetscope.3"]
bands: ["b01", "b02", "b03", "b04", "b05", "b06", "b07", "b08"]
passthrough: true
planetscope.4:
data_type: "raster"
layers: ["planetscope.4"]
bands: ["b01", "b02", "b03", "b04", "b05", "b06", "b07", "b08"]
passthrough: true
planetscope.5:
data_type: "raster"
layers: ["planetscope.5"]
bands: ["b01", "b02", "b03", "b04", "b05", "b06", "b07", "b08"]
passthrough: true
sentinel2_0:
data_type: "raster"
layers: ["sentinel2_with_planet"]
bands: ["B04", "B03", "B02", "B05", "B06", "B07", "B08", "B11", "B12"]
passthrough: true
sentinel2_1:
data_type: "raster"
layers: ["sentinel2_with_planet.1"]
bands: ["B04", "B03", "B02", "B05", "B06", "B07", "B08", "B11", "B12"]
passthrough: true
sentinel2_2:
data_type: "raster"
layers: ["sentinel2_with_planet.2"]
bands: ["B04", "B03", "B02", "B05", "B06", "B07", "B08", "B11", "B12"]
passthrough: true
sentinel2_3:
data_type: "raster"
layers: ["sentinel2_with_planet.3"]
bands: ["B04", "B03", "B02", "B05", "B06", "B07", "B08", "B11", "B12"]
passthrough: true
sentinel2_4:
data_type: "raster"
layers: ["sentinel2_with_planet.4"]
bands: ["B04", "B03", "B02", "B05", "B06", "B07", "B08", "B11", "B12"]
passthrough: true
sentinel2_5:
data_type: "raster"
layers: ["sentinel2_with_planet.5"]
bands: ["B04", "B03", "B02", "B05", "B06", "B07", "B08", "B11", "B12"]
passthrough: true
targets:
data_type: "raster"
layers: ["label"]
bands: ["label"]
is_target: true
task:
class_path: rslearn.train.tasks.multi_task.MultiTask
init_args:
tasks:
segment:
class_path: rslearn.train.tasks.segmentation.SegmentationTask
init_args:
num_classes: 17
remap_values: [[0, 1], [0, 255]]
zero_is_invalid: true
metric_kwargs:
average: "micro"
input_mapping:
segment:
targets: "targets"
batch_size: 8
num_workers: 32
default_config:
transforms:
- class_path: rslearn.train.transforms.concatenate.Concatenate
init_args:
selections:
planetscope: []
sentinel2_0: []
planetscope.1: []
sentinel2_1: []
planetscope.2: []
sentinel2_2: []
planetscope.3: []
sentinel2_3: []
planetscope.4: []
sentinel2_4: []
planetscope.5: []
sentinel2_5: []
output_selector: image
- class_path: rslearn.train.transforms.normalize.Normalize
init_args:
mean: 0
std: 255
train_config:
patch_size: 128
transforms:
- class_path: rslearn.train.transforms.concatenate.Concatenate
init_args:
selections:
planetscope: []
sentinel2_0: []
planetscope.1: []
sentinel2_1: []
planetscope.2: []
sentinel2_2: []
planetscope.3: []
sentinel2_3: []
planetscope.4: []
sentinel2_4: []
planetscope.5: []
sentinel2_5: []
output_selector: image
- class_path: rslearn.train.transforms.normalize.Normalize
init_args:
mean: 0
std: 255
- class_path: rslearn.train.transforms.flip.Flip
init_args:
image_selectors: ["image", "target/segment/classes", "target/segment/valid"]
groups: ["crops_planetscope"]
tags:
split: train
val_config:
patch_size: 128
groups: ["crops_planetscope"]
tags:
split: val
test_config:
patch_size: 128
groups: ["crops_planetscope"]
tags:
split: val
predict_config:
groups: ["images_planetscope"]
load_all_patches: true
skip_targets: true
patch_size: 512
trainer:
max_epochs: 500
callbacks:
- class_path: lightning.pytorch.callbacks.LearningRateMonitor
init_args:
logging_interval: "epoch"
- class_path: rslearn.train.prediction_writer.RslearnWriter
init_args:
path: gcs://rslearn-eai/datasets/maldives_ecosystem_mapping/dataset_v1/20241017/
output_layer: output
selector: ["segment"]
- class_path: lightning.pytorch.callbacks.ModelCheckpoint
init_args:
save_top_k: 1
every_n_epochs: 50
save_last: true
monitor: val_segment/accuracy
mode: max
rslp_project: maldives_ecosystem_mapping
rslp_experiment: planetscope_plus_sentinel2_data_20241017_satlaspretrain_flip_crop128_00
4 changes: 2 additions & 2 deletions data/maldives_ecosystem_mapping/config_sentinel2.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
],
"data_source": {
"duration": "180d",
"index_cache_dir": "cache/sentinel2",
"index_cache_dir": "gs://rslearn-eai/datasets/maldives_ecosystem_mapping/dataset_v1/20240924/cache/sentinel2",
"max_time_delta": "1d",
"name": "rslearn.data_sources.gcp_public_data.Sentinel2",
"query_config": {
Expand All @@ -93,6 +93,6 @@
},
"tile_store": {
"name": "file",
"root_dir": "tiles"
"root_dir": "gs://rslearn-eai/datasets/maldives_ecosystem_mapping/dataset_v1/20240924/tiles"
}
}
2 changes: 1 addition & 1 deletion data/maldives_ecosystem_mapping/config_skysat.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,6 @@
},
"tile_store": {
"name": "file",
"root_dir": "tiles"
"root_dir": "gs://rslearn-eai/datasets/maldives_ecosystem_mapping/dataset_v1/20240924/tiles"
}
}
Loading
Loading