- RasterFlow_FTW.ipynb — Complete FTW field boundary detection tutorial
- RasterFlow_Bring_Your_Own_Model.ipynb — Export custom PyTorch models
Why Fields of the World (FTW)?
FTW predicts 3 classes (non_field_background, field, field_boundaries). While FTW is a field boundary segmentation model (not a true change detection model), it takes bi-temporal input (two seasons), making it useful for demonstrating change detection.
Model signature
Change detection models receive multi-temporal imagery stacked along the channel dimension:| Shape | |
|---|---|
| Input | (Batch, Channels × TimeSteps, H, W) — e.g. (N, 8, 256, 256) for 4 bands × 2 seasons |
| Output | (Batch, Classes, H, W) — e.g. (N, 3, 256, 256) for 3 classes |
InferenceActorEnum.SEMANTIC_SEGMENTATION_CHANGE_DETECTION_PYTORCH.
Selecting an Area of Interest (AOI)
To start, we will choose an Area of Interest (AOI) for our analysis. The area around Haskell County, Kansas has some interesting crop field patterns so we will try out the model there.Initializing the RasterFlow client
See our docs to learn more about all methods available on the client https://docs.wherobots.com/reference/rasterflow/clientBuilding a Mosaic
RasterFlow provides abuild_mosaic workflow to create analysis-ready imagery for your Area of Interest (AOI). This step:
- Ingests Sentinel-2 imagery for the specified AOI across your defined time range (e.g., 2 years)
- Applies quality filtering and cloud masking to select valid observations
- Generates a seamless, temporally-composited mosaic from multiple image tiles
xarray we can print out a nice representation of our mosaic and see that it has two time steps for our change detection task.
Mosaic Inference
Now that we have built the mosaic and understand the features that were included, we can runpredict_mosaic.
We’ll pass in the band names we want to predict, as well as other inference configs that specify how to run inference.
storeis the mosaic we just created for sentinel-2model_pathcan be a path to a Pytorch 2 Archive file on s3 or Huggingface. In this case we’ll use the Fields of the World model from the Wherobots’ Huggingface Collection.patch_sizecontrols the XY size of the array input to the modelclip_sizein conjunction withMergeModeEnum, controls how to run overlapping windowed inference to reduce edge effects relative to non-overlapping inferencedevicespecifies what device to use for running inference. Our runtimes are GPU only at this time, but you could run on the CPU device if you wanted to!featuresselects what bands and in what order to run inference onlabelssets the labels on the models output. Order matters here based on what your model returns!actordetermines the kind of inference handler to use. The correct actor to select depends on the task your model is solving and the kind of input it expects. For change detection, we support models that take in an input where time and channels dimensions are stacked together. So the channel dimension is ordered like so in in this example:
max_batch_size: Maximum number of patches fed through the model in a single forward pass.- Higher values = better GPU utilization but more GPU memory required
- Lower values = less memory but potentially slower inference
xy_block_multiplier: Controls how many Zarr chunks are processed together as a single block during inference.- Higher values = larger blocks = fewer tasks but more memory per task
- Lower values = smaller blocks = more tasks but less memory per task Use a smaller multiplier (e.g., 1) if you’re running into memory issues; use the default (4) for better throughput when memory allows.
time coordinate of the Zarr store using the start date used to build the input mosaic. We also store a time delta coordinate to represent the interval of time between the start_date and end_date.
Visualize a subset of the model outputs
The raster outputs from the model for this AOI are approximately 1GB. We can choose a small subset of the data around the Plymell, Kansas and use hvplot to visualize the model outputs.Vectorize the raster model outputs
The output for the FTW model is a raster with three classes as bands: field, field_boundaries, and non_field_background. We will run a separate flow to convert the fields and field boundaries into vector geometries. Converting these results to geometries allows us to more easily post process the results or join the results with other vector data.Save the vectorized results to the catalog
We can store these vectorized outputs in the catalog by using WherobotsDB to persist the GeoParquet results.Visualize the vectorized results
To visualize the vectorized results, we will show the fields around Plymell, Kansas and filter out results with a score lower than 0.5. This threshold was determined through observation to strike a balance: it eliminates obvious noise without being overly aggressive, ensuring that we don’t accidentally filter out too many relevant results.Generate PM Tiles for visualization
To improve visualization performance of a large number of geometries, we can use Wherobots built-in high performance PM tile generator. The FTW model has a tendency to create extremely large boundary geometries, which doesn’t play nicely with PMTiles. To avoid this we subdivide the boundary geometries.Sharing PMTiles results with the Wherobots PMTiles Viewer
You can generate a pre-signed url to your pmtiles usingget_url.
Then, copy this to your clipboard with right-click + “Copy Output to Clipboard”.
You can paste this url into https://tile-viewer.wherobots.com/ and create a publicly accessible PMTiles map served from your own bucket.
References
- Kerner, H., Chaudhari, S., Ghosh, A., Robinson, C., Ahmad, A., Choi, E., Jacobs, N., Holmes, C., Mohr, M., et al. (2024). Fields of The World: A Machine Learning Benchmark Dataset For Global Agricultural Field Boundary Segmentation. arXiv preprint arXiv:2409.16252. Accepted at AAAI-2025 Artificial Intelligence for Social Impact (AISI) track.
- ESA. (2015). Sentinel-2 User Handbook (Issue 1, Rev. 2). European Space Agency. https://sentinels.copernicus.eu/documents/247904/685211/Sentinel-2_User_Handbook

