Skip to content

Deep Learning model for classifying images of daisy and dandelion

Notifications You must be signed in to change notification settings

Hokfu/Flower-image-classification

Repository files navigation

Table of Contents

  1. Introduction
  2. Dataset
  3. Problem Description
  4. Model Training
  5. Parameter Tuning
  6. Evaluation
  7. Dependency and Environment Management
  8. Containerization
  9. Usage

Flower-image-classification

Classification model for the flowers 'daisy' and 'dandelion'. This dataset is from Kaggle.

https://www.kaggle.com/datasets/alsaniipe/flowers-dataset

The notebook was run in Kaggle. You can install the necessary libraries from requirements.txt, or you can run it in Kaggle.

The trained model is converted to Tensorflowlite for light usages.

Dataset

Train dataset has 529 daisy images and 1275 dandelion images.
Validation dataset has 1620 daisy images and 1821 dandelion images.
Test dataset has 1352 daisy images and 1457 dandelion images.

Here are a few sample images from the dataset.

sample images

Problem Description

This model intends to identify and differentiate between daisy and dandelion.

Example use cases: image detection IoT devices, gardening, environmental monitoring, mobile app for nature enthusiasts

Model Training

Model is trained with sequential model with CNN, and pre-trained models- 'VGG16' and 'Xception'.

Firstly, the keras model is built on my own with following features.
model summary

However, using our own model, we need to add a lot more layers to gain high accuracy. It requires a lot of GPU resources.

Here is my model's accuracy and loss during training.

model_accuracy

Therefore, I used transfer learning with existing models in keras - Xception and VGG16.

vgg16_model_accuracy xception_model_accuracy

According to the images, xception model is inconsistent and might be vulnerable to overfitting. Transfer learning with VGG16 seems like it has consistent accuracy and loss in both training and validation.
So, VGG16 model is chosen as the final model.

Parameter Tuning

After choosing VGG16, the model is fine tuned to find the best size for inner dense layer.

finding_best_inner_layer_size

Size 100 and 10 seems like the best inner dense layer for the model. I used size 10 for the final model and trained with 10 epoches. The best model is found in 10th epoch with 87.6% accuracy.

Evaluation

Here is evaluation of the model.

evaluation_result

When tested with the test dataset, the accuracy is 86.8% which is pretty acceptable. The model performs well in most of the images and performs worse if the flower in the image has a very small size.

Dependency and Environment Management

Dependencies are in 'pipfile'. To install dependencies, you need to create pipenv virtual environment.

pip install pipenv
pipenv --python 3.9
pipenv install



Containerization



To build the docker file in local, use

Docker build -t 'container_name' .



After containerization, the container can be deployed to Amazon ECS service.

With the deployed container in ECS, we can use AWS Lambda and use the model to classify between daisy and dandelion.

Usage



Clone the model in your device and can be used. If your device is not compatible with Tensorflow lite, you can run the repository in cloud services like saturncloud.

Releases

No releases published

Packages

No packages published

Languages