The FGVC-Aircraft dataset containing 10,000 images of aircraft (covering 100 different models) can be downloaded at https://www.robots.ox.ac.uk/~vgg/data/fgvc-aircraft/#:~:text=FGVC%2DAircraft%20Benchmark,375%20KB%20%7C%20MD5%20Sum%5D.
The dataset is discussed in the paper "Fine-Grained Visual Classification of Aircraft" by Maji, et al [2013] which can be found at https://arxiv.org/abs/1306.5151
I modified the file structure a bit and have the re-structured code available for download at:
https://drive.google.com/file/d/1GMujsV2_kqMsbDAaEPgO-4hyYHkckjjW/view?usp=sharing
Unzip the data.zip file (see directory tree structure below).
This dataset is tricky; the image sizes are different, so I had to use transform.Resize() on the data. (I forced the images to be 64x64 which may hurt the accuracy of the model. Just as an aside, it would be good to cover data augmentation for image classification -- rotations, grayscale, resizing, etc.)
There are also many family classes for the aircraft (70 categories!), so I chose to reduce it to just the Airbus fleets (6 classes): ['Cessna 172','BAE-125','DR-400','Eurofighter Typhoon','Boeing 747','SR-20'].
We want to
- visualize the dataset
- train a deep neural network to classify images of the different aircraft models (CNN, ResNet152, VGG16)
For logging later on, optionally add a folder called log_test. Your directory structure should look like:
May-2022-Aircraft-Image-Classification/
log_test/
data/
train
(various image files...)
labels.csv
valid
(various image files...)
labels.csv
code/
__init__.py
models.py
train.py
utils.py
PlotCNNprediction.py
PlotDatasetImages.py
Install dependencies using:
python -m pip install -r requirements.txt
and if you are using conda use:
conda env create aircraft.yml
which can be activated for your Python environment using:
conda activate aircraft
Currently, in the folder code, you can train the models using a convolutional neural network and ResNet 152.
To train the CNN, the code is:
python -m code.train -m cnn
To train the ResNet, the code is:
python -m code.train -m resnet
To do some visualization:
Here is the code you can run before training the model to see a snapshot of what the dataset looks like:
python -m code.PlotDatasetImages data/train
If you want to train with the CNNClassifier model in models.py, run the code:
python -m code.train -m cnn -n 1000
This runs the CNN classifier for 1000 epochs in train.py
ResNet152 is a prebuilt image classification network that should beat our home-built CNN classifier. To run and test it, run
python -m code.train -m resnet -n 1000
To visualize the results of our model on the validation data, you can plot the following:
python -m code.PlotCNNprediction -model resnet -dataset data/valid
and compare with performance on the training set:
python -m code.PlotCNNprediction -model resnet -dataset data/train
If you want to use Tensorboard, here is some extra code:
python -m code.train -m cnn --log_dir log_test -n 1000
followed by:
tensorboard --logdir=log_test --port 6006 --bind_all
the message you'll receive will give you something like:
click on the address you get and open it in a web browser. See the interactive tensorboard. Done!