You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Following the project structure below, create a directory in the `rslearn-projects/data/` directory. This directory will contain all the necessary files for your prediction or fine-tuning pipeline.
14
23
15
24
## Project Structure
16
25
-`checkpoint.ckpt`: (Optional)
17
26
-`dataset.json`: This is the rslearn dataset definition file.
18
27
-`model.yaml`: This is the rslearn (pytorch) model definition file.
19
-
-`partition_strategies.yaml`:
20
-
-`postprocessing_strategies.yaml`: This file defines how the esrunner will post-process the predictions.
21
-
-`requirements.txt`: This file contains the additional Python packages required for the pipeline. It should include any dependencies that are not part of the base environment.
22
-
-`prediction/test-request1.geojson`: This directory contains the prediction requests in GeoJSON format. Each file represents a set of prediction requests for a specific region or time period. Many different prediction requests can be defined within a single file as separate features in the feature collection. The esrunner will partition these requests into smaller tasks based on the partition strategies defined in `partition_strategies.yaml`.
28
+
-`esrun.yaml`: This file defines the esrun model configuration. It defines partitioning and post-processing strategies.
29
+
-`prediction_request_geometry.geojson`: The prediction request GeoJSON feature collection.
23
30
-`run_pipeline.py`: This script is used to run the prediction pipeline. It will read the configuration files and execute the necessary steps to perform predictions or fine-tuning. You can customize this script to suit your specific needs, such as adding additional logging or error handling.
24
31
25
32
## Partitioning Strategies
@@ -33,18 +40,28 @@ Partitioning strategies can be mixed and matched for flexible development.
33
40
Available partitioners:
34
41
-`FixedWindowPartitioner` - Given a fixed window size, this partitioner will create partitions of that size for each lat/lon or polygon centroid in the prediction request.
35
42
-`GridPartitioner` - Given a grid size, this partitioner will create partitions based on the grid cells that intersect with the prediction request.
36
-
- NoopPartitioner - Does not partition the prediction request. This is useful for testing or when you want to run the entire prediction request as a single task.
43
+
-`NoopPartitioner` - Does not partition the prediction request. This is useful for testing or when you want to run the entire prediction request as a single task.
44
+
45
+
Example `esrun.yaml` snippet. This will leave the original input as a single partition, but will create individual windows of size 128x128 pixels for each feature.
37
46
38
-
Example `partition_strategies.yaml`. This will leave the original input as a single partition, but will create individual windows of size 128x128 pixels for each feature.
x_resolution: 9.554628535647032# PIXEL_SIZE in rslp/forest_loss_driver/extract_dataset/extract_alerts.py
64
+
y_resolution: -9.554628535647032
48
65
```
49
66
50
67
## Post-Processing Strategies
@@ -53,101 +70,134 @@ There are 3 different stages to postprocessing:
53
70
- `postprocess_partition()`- This is the stage where the outputs from the window postprocessors are combined into a single per-partition artifact.
54
71
- `postprocess_dataset()`- This is the final stage of postprocessing where the partition level outputs are combined into a artifact.
55
72
73
+
Example: This uses the `CombineGeojson` postprocessor to combine the outputs from the window postprocessors into a single GeoJSON file for each partition and the entire dataset.
The `scratch/results/result.geojson` file should contain the results of the prediction request. The scratch/dataset directory should contain the materialized dataset for the prediction request.
104
+
58
105
### Run a pipeline end-to-end
59
106
60
107
```python file=run_pipeline.py
61
-
from rslp.espredict_runner import EsPredictRunner
62
-
63
-
runner = EsPredictRunner(
64
-
'model.yaml',
65
-
'dataset.json',
66
-
'partition_strategies.yaml',
67
-
'postprocessing_strategies.yaml',
68
-
'prediction/test-request1.geojson',
69
-
scratch_path='scratch/'
70
-
)
108
+
from pathlib import Path
109
+
110
+
from esrun.runner.local.predict_runner import EsPredictRunner
partition_id ='my-existing-partition-id'# Replace with the actual partition ID you want to run
111
154
runner.run_inference(partition_id)
112
155
```
113
156
114
157
### Run inference for a single window.
115
158
Since we don't expose window-level inference via the runner API, you can configure your partitioners to produce limited sets of partitions and windows.
partition_id = 'my-existing-partition-id' # Replace with the actual partition ID you want to run
141
191
partitions = runner.partition()
142
192
for partition_id in partitions:
143
193
runner.run_inference(partition_id)
144
194
```
145
195
146
196
## Writing Your Own Partitioners
147
-
You may supply your own partitioners by creating a new class that implements the ` PartitionInterface` class in the `esrun.tools.partitioners.partition_interface` module. You can then specify your custom partitioner in the `partition_strategies.yaml` file. This class must exist on your PYTHONPATH and be importable by the esrunner. As such we recommend you place your custom partitioner in the `rslp/common/partitioners` directory of this repository to ensure it gets installed into the final Dockerimage artifact.
197
+
You may supply your own partitioners by creating a new class that implements the `PartitionInterface` class in the `esrun.runner.tools.partitioners.partition_interface` module. You can then specify your custom partitioner in the `esrun.yaml` file. This class must exist on your PYTHONPATH and be importable by the esrunner. As such we recommend you place your custom partitioner in the `rslp/common/partitioners` directory of this repository to ensure it gets installed into the final Dockerimage artifact.
148
198
149
199
## Writing your own post-processing strategies
150
-
You may supply your own post-processing strategies by creating a new class that implements the `PostprocessInterface` class in the `esrun.tools.postprocessors.postprocess_inferface` module. You can then specify your custom post-processing strategy in the `postprocessing_strategies.yaml` file. This class must exist on your `PYTHONPATH` and be importable by the esrunner. As such we recommend you place your custom post-processing strategy in the `rslp/common/postprocessing` directory of this repository to ensure it gets installed into the final Docker image artifact.
200
+
You may supply your own post-processing strategies by creating a new class that implements the `PostprocessInterface` class in the `esrun.runner.tools.postprocessors.postprocess_inferface` module. You can then specify your custom post-processing strategy in the `esrun.yaml` file. This class must exist on your `PYTHONPATH` and be importable by the esrunner. As such we recommend you place your custom post-processing strategy in the `rslp/common/postprocessing` directory of this repository to ensure it gets installed into the final Docker image artifact.
See the [earth-system-run](https://github.com/allenai/earth-system-run) repository for tests covering existing [partitioner](https://github.com/allenai/earth-system-run/tree/v1-develop/tests/unit/tools/partitioners) and [post-processor](https://github.com/allenai/earth-system-run/tree/v1-develop/tests/unit/tools/postprocessors) implementations.
0 commit comments