Flower classification using CNN and data augmentation
There are three types of flowers in the dataset: Daisy,Rose,Sunflower. The task is to build a CNN model for classification.
The dataset size is very small hence the model tends to overfit a lot.
- Simple CNN : Overfits a lot due to scarcity of data
- Simple CNN with data augmentation : Performs well but the losses are a bit erratic
- Transfer learning with data augmentation : Best model. Performs well with smooth loss curve
Softmax cross entropy is used. Accuracy is 85%. Loss is 0.40
Folders:
- data : Contains the dataset with three sub folders
- dataAugmented : Contains the augmented images. Not used for training purpose. Just to visualize the augmented images to be used.
- model : The trained model is saved into this folder.
- templates : GUI related files : index.html, style.css, jqueryScript.js, default.png
- testImages : Used to store the images along with there predicted class
Files:
- FlowerClassification.ipynb : Ipython notebook to demonstrate various approaches
- train.py : The best model obtained is used to train and persist with this file
- test.py : Flask service which is triggered by the GUI to perform the predictions
Create folder data/rose,data/sunflower,data/daisy. Put contents of rose1 and rose2 into rose and sunflower1 and sunflower2 into sunflower.
Training: python train.py 30
30 : epochs
Test: python test.py
Flask service will start on http://127.0.0.1:5000. This is used in the jqueryScript.js to perform the prediction
Open the index.html in templates folder and trigger the service
Bootstrap:
https://bootsnipp.com/snippets/76778
https://www.w3schools.com/bootstrap/bootstrap_templates.asp
Flask:
https://www.tutorialspoint.com/flask