Flower Classification using CNN

AI Technology & Systems
AITS Journal
3 min readAug 27, 2021

--

Photo by dongkyu lim on Dribbble

We all come across numerous flowers on a daily basis. But we don’t even know their names at times. We all wonder “I wish my computer/mobile could classify this” when we come across a beautiful looking flower. That is the motive behind this article, to classify flower images.

The main objective of this article is to use Convolutional Neural Networks (CNN) to classify flower images into 10 categories

DATASET

Kaggle Datasethttps://www.kaggle.com/olgabelitskaya/flower-color-images

The 10 classes in the dataset are:

  1. Phlox
  2. Rose
  3. Calendula
  4. Iris
  5. Leucanthemum maximum (Shasta daisy)
  6. Campanula (Bellflower)
  7. Viola
  8. Rudbeckia laciniata (Goldquelle)
  9. Peony
  10. Aquilegia

IMPORTS

I will be using Tensorflow to implement the CNN, Matplotlib to plot graphs and display images, Seaborn to display the heatmap

MODEL

The model consists of 2 Conv2D layers of 128 neurons each along with MaxPooling layers and followed by 2 Dense layers

I have used LeakyReLU here. ReLU might also provide good results here.

The Loss is Categorical Crossentropy and Optimizer is Adam

Model Architecture:

Callbacks

I have defined 2 callbacks

  • ModelCheckpoint — To save the best model during training
  • ReduceLROnPlateau — Reduce the learning rate accordingly during training

Train

The model is being training with a Batch Size = 32 and for 75 Epochs

As we don’t have a large amount of data, we use Image Augmentation to synthesize more data and train our model with it

RESULT

The model reached a validation accuracy of 80.95238% which is quite decent. And we can see that the model did not overfit a lot. So it’s quite a good model

PREDICTIONS

Let’s look at some prediction made by our model on randomly chosen images

Notebook Link: Here

Credit: Rasswanth Shankar

--

--