- Introduction
- Dataset
- Problem Description
- Model Training
- Parameter Tuning
- Evaluation
- Dependency and Environment Management
- Containerization
- Usage
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.
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.
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 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.
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.
Therefore, I used transfer learning with existing models in keras - Xception and VGG16.
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.
After choosing VGG16, the model is fine tuned to find the best size for inner dense layer.
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.
Here is evaluation of the model.
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.
Dependencies are in 'pipfile'. To install dependencies, you need to create pipenv virtual environment.
pip install pipenv
pipenv --python 3.9
pipenv install
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.
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.