Skip to content

A CNN model was built using TensorFlow to predict whether a low-resolution image contains a cactus.

Notifications You must be signed in to change notification settings

Jingyi-Luo/Aerial_Cactus_Detection_Using_CNN

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Aerial Cactus Detection Using CNN in TensorFlow

This project aims at building a CNN model with TensorFlow using a dataset of 17500 images of cactus to predict whether a low-resolution image contains a cactus.

The data can be accessed here: Data

Architecture of CNN

The first is the tensorboard graph of CNN. The second one is the flowchart of CNN using VALID as padding. This model consists of one input layer, two convolutional layers, one pooling layers, one fully connected layer accompanied by one dropout layer, and one output layer.

                      tensorboard_graph                    Screen Shot 2019-04-07 at 9 44 55 AM
                    Fig 1. Tensorboard Computational Graph (left) and Simplified Flowchart (right)

Detailed dimension description:

  • Input layer: the height (H), width (W), and channels of each colorful image 32 by 32 by 3.
  • The output of the first convolutional layer: the filter size (F) is 3, the striding (S) is 1, and the number of filters is 36, so the output dimension is 30 by 30 by 36 (Equation used: (W-F)/S +1= (32-3)/1 +1 = 30).
  • The output of the second convolutional layer: the input dimension is 30 by 30 by 36, the filter size (F) is 3, the striding (S) is 1, and the number of filters is 72, so the output dimension is 28 by 28 by 72 (Equation used: (W-F)/S +1= (30-3)/1 +1 = 28).
  • The output of the max-pooling layer: the input dimension is 28 by 28 by 72. The filter size (F) is two and the striding (S) is two. Max-pooling doen't change the number of channels, so the output dimension is 141472 (Equation used: (W-F)/S +1= (28-2)/2 +1 = 14).
  • The output of the reshaped vector for fully connected layer: its dimension is 1*14112 that is obtained from the product of 14, 14 and 72 from the output of the pooling layer.
  • The output of the fully connected layer: the fully connected layer has 128 units, so its output dimension is 128.
  • The output layer with the sigmoid function: the predicted classes are two, so this layer’s dimension is two.

Results

The effect of padding (VALID, SAME), optimization (Gradient Descent, and Adam optimizer), number of convolutional layers have been investigated to increase model's accuracy. Based on the optimized architecture, the training set obtained the accuray of 100% and the loss of 0.00088, and the test set obtained the accuracy of 99.7% and and the loss of 0.0096 as shown below.

accuracy_train_validloss_train_valid
                     Fig 2. Accuracy (left) and Loss (right) For Training and Testing Data With Epochs (graphs from tensorboard)


The project comes from Kaggle competition. When use this model to predict a fresh new dataset from Kaggle, the accuracy reaches 99% and ranks 195 among all the competitors (April, 2019)

195_0 99_kaggle
                                                                      Fig 3. Snapshot from Kaggle Competition

About

A CNN model was built using TensorFlow to predict whether a low-resolution image contains a cactus.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages