This small project is an attempt to train a classifer using transfer learning. The classifier will detect two species of similar small sized dogs, namely Pomeranian and Chihuahua. Goal is to demonstrate how transfer learning can be used on small amount of data.
- A pretrained convolutional network will be used as a feature extractor.
- The pretrained network is VGG16 which has been pretrained on ImageNet.
- ImageNet has a lot of images of dogs, so the VGG16 network is familiar with extracting dog features.
- The fully connected layers of VGG16 is replaced with a custom classifier.
- The custom classifier will be a simple fully connected network to avoid overfitting the small dataset.
- After training, the model will be evaluated and wrongly classified images will be displayed for an easy human analysis of possible reasons for wrong classification.
- 70% of data will be for Training, 20% for Validation and 10% for Testing.
Google Colab is used to build this model
Comprised of images of pomeraninans and chihuahua collected over the internet. Some of the photos are my personal collection.
- 202 images of pomeranians.
- 201 images of chihuahua.
As I will be using the ImageDataGenerator class's method called flow_from_directory(), the images of the two dog types must be organized according to the directory structure show in the diagram below.
Start with a small fully connected layer. Because there is only small number of images available for training, if you have a large fully connected layer for classification, it will tend to overfit easily or the network simply memorized the training data.
High dropout rate will cause wild swings in the training data.
Some Pomeranians and long-haired Chihuahuas can be difficult to distinguish even for humans. The model also tend to classify images wrongly whenever there are two types of dogs in the same image.
Fine Tuning
If you attempt to do fine tuning, don't turn on too many layers for training. There is insufficient data to train the the initial layers.