Skip to content

Detecting airplanes in satellite imagery using deep learning

Prerequisites

The dataset we used in this notebook is downloaded from RarePlanes. RarePlanes is an open-source machine learning dataset from CosmiQ Works and AI.Reverie that incorporates both real and synthetically generated satellite imagery. This data is licensed under the CC-BY-SA 4.0 license. We are going to use real training data that contains 5,815 training images. The images have dimensions of 512x512 and a resolution of 30cm. Tiled images have also been put into an images folder, and the annotations have been converted to the "PASCAL_VOC_rectangles" format and have been put into a labels folder. The dataset can be downloaded in the necessary format here.

Introduction

The goal of this notebook is to demonstrate how we can use the FasterRCNN model to detect airplanes in satellite imagery. Airplane detection is a valuable process across multiple industries, as it allows for the identification and monitoring of airports at a global scale.

Necessary Imports

from arcgis import learn
from arcgis.gis import GIS

We will now use the prepare_data() function to apply various types of transformations and augmentations to the training data. These augmentations enable us to train a better model with limited data, as well as better prevent the overfitting of the model.

This dataset contains multiple classes of planes, however, we are only interested in detecting planes and not classifying their categories. So, we will map the planes to one class using class_mapping.

This function returns a data object that can be fed into a model for training.

data = learn.prepare_data(path="airplane_chips", dataset_type="PASCAL_VOC_rectangles",
                          class_mapping={**dict.fromkeys(['1', '2', '3', '4', '5', '6', '7'],'airplane')})

Visualize training data

data.show_batch()
<Figure size 1440x1440 with 25 Axes>

Train a model

arcgis.learn provides the following deep learning algorithms that we can use to detect airplanes:

Here, we are going to use FasterRCNN

model = learn.FasterRCNN(data)

Next, we can simply call the model.fit() method and pass a number of epochs to it. The model will then begin to train after finding the optimal learning rate itself.

model.fit(15)
epochtrain_lossvalid_lossaverage_precisiontime
00.4899500.3753360.14554702:12
10.2586450.2519250.69088502:12
20.1743620.1846480.76655502:13
30.1341110.1601820.80906702:14
40.1173790.1481770.82749902:15
50.1038720.1472850.81803502:14
60.1037760.1332240.83182902:14
70.0995070.1371180.82386702:15
80.0966360.1333850.81934402:15
90.0915580.1291490.83587102:14
100.0900910.1281180.84763502:14
110.0906070.1232180.85653902:14
120.0897160.1218810.84497202:14
130.0909870.1216700.84672602:14
140.0896660.1215620.84817602:14

Detect and visualize airplanes on the validation set

Now that we have the trained model, we will examine how the model performs on data it has not yet seen.

model.show_results()
<Figure size 576x1440 with 10 Axes>

As we can see, with only 15 epochs, we are already seeing reasonable results. Further improvement can be achieved through more training and sophisticated hyperparameter tuning.

We will now save the model for further training or later inferences. By default, the model should save into a models folder in your data folder.

model.save("airplane_15ep")
PosixPath('/home/ubuntu/airplane_training/airplane_chips/models/airplane_15ep')

Model inference in ArcGIS Pro

Next, we will use the saved model to detect airplanes using the Detect Objects Using Deep Learning tool available in both ArcGIS Pro and ArcGIS Image Server. For this sample, we will deploy the model on the Amsterdam airport region.

  • Input Raster: Imagery
  • Output Detected Objects: Detected_airplanes
  • Model Definition: airplane_15ep.emd
  • Extent: Extent of the region where model will run.
  • Cell Size: The model is very susceptible to the cell size. This model works well with cell sizes 0.5 to 1

The Detect Objects Using Deep Learning tool will return a vector layer with the airplanes detected in the chosen region, as seen below.

The trained model is provided here. You can download the model and perform inferencing in ArcGIS Pro.

Conclusion

In this notebook, we demonstrated how to use the Faster R-CNN model from the ArcGIS API for Python to detect airplanes in satellite imagery.

References

[1] Dataset source https://www.cosmiqworks.org/rareplanes/

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.