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 GeoJSON output option for vessel detection pipelines #97

Merged
merged 15 commits into from
Feb 6, 2025
Merged
8 changes: 8 additions & 0 deletions data/sentinel2_vessels/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ data:
load_all_patches: true
skip_targets: true
patch_size: 512
overlap_ratio: 0.1
trainer:
max_epochs: 500
callbacks:
Expand All @@ -124,6 +125,13 @@ trainer:
path: gs://rslearn-eai/datasets/sentinel2_vessels/dataset_v1/20240927/
output_layer: output
selector: ["detect"]
merger:
class_path: rslp.utils.nms.NMSDistanceMerger
init_args:
grid_size: 64
distance_threshold: 10
property_name: "category" # same as task.property_name
class_agnostic: false
- class_path: lightning.pytorch.callbacks.ModelCheckpoint
init_args:
save_top_k: 1
Expand Down
7 changes: 4 additions & 3 deletions docs/landsat_vessels.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ The easiest way to apply the model is using the prediction pipeline in `rslp/lan
"B8": "/home/data/LC08_L1TP_125059_20240727_20240801_02_T1_B8.TIF",
},
"scratch_path": "/home/data/scratch/",
"json_path": "/home/data/vessels.json",
"geojson_path": "/home/data/vessels.geojson",
"crop_path": "/home/data/crops/"
}
```
Expand All @@ -52,11 +52,12 @@ Now we can run the pipeline:

python -m rslp.main landsat_vessels predict --config /path/to/config.json

Here, `scratch_path` saves the rslearn dataset, `crop_path` saves the cropped RGB images centered around the detected ships, and `json_path` saves the JSON output of the detected ships, all of which are optional, depending on whether the user wants to save the intermediate results or not.
Here, `scratch_path` saves the rslearn dataset, `crop_path` saves the cropped RGB images centered around the detected ships, and `geojson_path` saves the GeoJSON output of the detected ships, all of which are optional, depending on whether the user wants to save the intermediate results or not.

The prediction pipeline also accepts a Landsat scene ID and automatically downloads the scene images from [AWS](https://aws.amazon.com/marketplace/pp/prodview-ivr4jeq6flk7u#resources). You will need to set up your AWS account for accessing Landsat data. Use the command below to run the pipeline with scene ID:

python -m rslp.main landsat_vessels predict --scene_id LC08_L1TP_125059_20240727_20240801_02_T1
python -m rslp.main landsat_vessels predict --scene_id LC08_L1TP_125059_20240727_20240801_02_T1 --geojson_path out.geojson --scratch_path scratch_dir/
qgis out.geojson scratch_dir/windows/default/default/layers/landsat/B8/geotiff.tif


Training
Expand Down
5 changes: 3 additions & 2 deletions docs/sentinel2_vessels.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ automatically downloads the scene images from a

mkdir output_crops
mkdir scratch_dir
python -m rslp.main sentinel2_vessels predict '["scene_id": "S2A_MSIL1C_20180904T110621_N0206_R137_T30UYD_20180904T133425", "json_path": "out.json", "crop_path": "output_crops/"]' scratch_dir/
python -m rslp.main sentinel2_vessels predict '[{"scene_id": "S2A_MSIL1C_20180904T110621_N0206_R137_T30UYD_20180904T133425", "geojson_path": "out.geojson", "crop_path": "output_crops/"}]' scratch_dir/
qgis out.geojson scratch_dir/windows/default/default/layers/sentinel2/R_G_B/geotiff.tif

Then, `out.json` will contain a JSON list of detected ships while `output_crops` will
Then, `out.geojson` will contain a GeoJSON of detected ships while `output_crops` will
contain corresponding crops centered around those ships (showing the RGB B4/B3/B2
bands).

Expand Down
2 changes: 2 additions & 0 deletions rslp/landsat_vessels/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

# Landsat config
LANDSAT_LAYER_NAME = "landsat"
OUTPUT_LAYER_NAME = "output"
LANDSAT_RESOLUTION = 15
LANDSAT_SOURCE = "landsat"

# Data config
LOCAL_FILES_DATASET_CONFIG = "data/landsat_vessels/predict_dataset_config.json"
Expand Down
Loading
Loading