Voice of Code
Published in

Voice of Code

Aerial Image Classification using Monk AI

This classifier can classify aerial images, specifically between images captured by drones or images taken from helicopters/airplanes. Seven classes corresponding to coarse ground occupancy labels have been provided : Orchard, Vineyard, Urban, Forest , Water, Crop and Land.

Aerial image captured by drone

The classifier can be used to actively study and survey ground patches as what percentage of land is agricultural land, or what percentage has settlements in it, and also help in topological research.

About the dataset:

For this project, I have used the HistAerial image dataset, which contains grayscale images representing 9 square kilometer areas (~ 6k per 6k pixels per image). These images were acquired between 1970 and 1990 over the France country (mainly in Rhones-Alpes region) with an optical camera mounted on an aircraft system.

The HistAerial Dataset

As you can see, the images are available in 25x25, 50x50 and 100x100 pixels.For this classifier, I have used the 100x100 to train the model.

Data Preparation:

Some preparation steps has to followed to prepare the data, to train the model using the Monk AI library.

  1. Download the data set

2. Unzip the data set

3. Make the train, test and validation data sets, from this one.

When you’ll be done with unzipping the data, the you’ll find the data set has the images, classified in class wise folder, with three “.txt” files available, with train, validation and test image names and corresponding labels. I took the help of these files, to make my train,test and validation sets. However you can use any other methods, to split the data set.

I have read the “.txt” files, into pandas “Data Frame”.

Preparing the train data:

Here the images will be stored in the train_data directory, from the common directory.

Now the dataframe, containing the image names and labels, is slightly modified to be used for training.

Lastly the dataframe is saved into a .csv file, with the name “train_labels.csv”.

Similarly the validation and test data is also prepared.

Setting up the Monk AI Library:

Now that the data is prepared, we have to set up the library, to build our classifier. Installing the library is very easy.

I used PyTorch to build the classifier , however Monk AI supports PyTorch,Keras and Gluon backend.

This is to setup the backend, to perform the classification.

Deciding upon Model Architecture:

Once the library is installed and set up, we’ll decide upon the model architecture, we’ll train, to make the classifier.

For this classification, I referred to the research paper, titled “Automatic Land Cover Reconstruction From Historical Aerial Images: An Evaluation of Features Extraction and Classification Algorithms”. The research paper, suggested that for transfer learning, AlexNet is the best architecture, to suite the purpose.

AlexNet contains eight layers; the first five are convolutional layers, some of them followed by max-pooling layers, and the last three are fully connected layers.It used the non-saturating ReLU activation function, which showed improved training performance over tanh and sigmoid.

AlexNet architecture

Performing Classification:

Once we have decided, the model architecture, let’s start the classification.

for the data set path, first the train data set path is given , and then the validation data set path is given, and then the path to the .csv files containing the labels.

We are training the classifier, for 5 epochs.Once we run this, we’ll see an output as this.

Here you can see the details about the image data, like there are 26460 train images and 11,340 validation images, and a total of 7 class labels. Moreover you can check some information on the model, and data transformations.

Now to start training, we have to just do the simple step.

This will take 5–10 mins to complete training the model.

Validation and testing the model performance:

Once the model is trained, now we have to check the model performance. Using Monk AI its quite easy to check the model performance.

Here the model, is loaded to perform inference.

Loading the test data set, to check model performance.

Here you can again see the details on test data, as there are 4200 images, in the test data set.

Checking the class based accuracy, this testing step takes around 2–3 mins. Once finished you can see an output as this.

As you can see the model has an average accuracy of 84.09 %. Now we will test the model on individual images.

Checking on individual images:

Now that the classifier is ready, let’s test it on individual images.

You can see the model classifies the image, correctly with a score of 0.98.

Here also the model can classify the image as an “URBAINS”(urban settlement) with an accuracy score of 0.99.

So this way, you can easily build a classifier for aerial images, using MonkAI library.Also, you can adjust the hyper-parameters, and try to get even better class based accuracy.

Resources:

The Notebook with the code for classifier : https://github.com/Tessellate-Imaging/monk_v1/blob/master/study_roadmaps/4_image_classification_zoo/Classifier%20-%20Hist%20Aerial%20Images.ipynb

The Monk AI library : https://github.com/Tessellate-Imaging/monk_v1

The Research paper referred to,for this purpose : http://eidolon.univ-lyon2.fr/~remi1/HistAerialDataset/paper/ratajczak2019-tip-preprint.pdf

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store