A dictionary, gpu_chip, holds the required input data for the change detection model and is instantiated where:
“A” is the 2017 sample,
“B” is the 2022 sample,
“L” is an empty Torch Tensor (since we don’t have any labels for changes that have occurred).
This chip is placed on the GPU, input to the predict_chips function, and forward propagated through the change detection model.
The returned NumPy array is the predicted change mask at the same spatial window as the input.
6. Parallelizing Using Dask
To parallelize our analysis using Dask, we initialize an array of predictions (predictions_array) which calls Dask’s map_blocks function on each chunk of the data within our combined dataset (ds_comb).
Dask map_blocks Function
Runs our copy_and_predict_chunked function on each chunk of our dataset in parallel.
The output is initialized as a NumPy array of data type UINT8. The size of the output will be the same spatial size as that of the input, drop_axis=[0,1].
We input our loaded model that has been waiting on the client, and then wrap this NumPy array as an xarray DataArray.
The entire Planet dataset contains approximately 140 km x 120 km of data.
This takes several minutes to process.
For our demo, we use a small 4,000 px x 4,000 px snippet of the data (12 km x 12 km) and visualize change detection results.
To run the full dataset, simply run:
7. Predicting a subset of the data
Next, let’s set the sample size to 4,000 pixels and grab a patch around the center of the dataset.
We will run dask.compute on this subset.
Dask Dashboard Running
We make a figure 1 row x 3 columns that shows our 2017 sample data, predicted change mask, and 2022 sample data.
8. Visual Spot Checking
Let’s visually check that the change mask is corresponding to visual changes in the data.
Hao Chen, Z., & Zhenwei Shi (2021). Remote Sensing Image Change Detection with Transformers. IEEE Transactions on Geoscience and Remote Sensing, 1-14.
Helber, P., Bischke, B., Dengel, A., & Borth, D. (2018). Introducing EuroSAT: A Novel Dataset and Deep Learning Benchmark for Land Use and Land Cover Classification. In IGARSS 2018-2018 IEEE International Geoscience and Remote Sensing Symposium (pp. 204–207).
Helber, P., Bischke, B., Dengel, A., & Borth, D. (2019). Eurosat: A novel dataset and deep learning benchmark for land use and land cover classification. IEEE Journal of Selected Topics in Applied Earth Observations and Remote Sensing.