Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flower Classification with Deep Learning

This project implements and compares three different deep learning approaches for flower classification:

  1. Custom CNN from scratch
  2. VGG16 as a feature extractor
  3. Fine-tuned VGG16

Project Structure

.
├── data.py              # Data loading and preprocessing
├── model.py            # Model architectures
├── train.py            # Training and evaluation functions
├── main.py             # Main execution script
├── requirements.txt    # Project dependencies
└── results/            # Output directory for models and visualizations

Dataset

The project uses the Flowers Dataset from Kaggle, which contains five categories of flowers:

  • Daisy
  • Dandelion
  • Rose
  • Sunflower
  • Tulip

How to use the dataset:

  1. Download the dataset from Kaggle.
  2. Extract the images and organize them as follows:
    Flowers/
      └── train/
          ├── daisy/
          ├── dandelion/
          ├── rose/
          ├── sunflower/
          └── tulip/
    
  3. Place the Flowers folder in the project root.

Model Architectures

1. Custom CNN

  • 5 convolutional layers with batch normalization
  • Max pooling layers
  • Dropout for regularization
  • Fully connected layers for classification

2. VGG16 Feature Extractor

  • Uses pretrained VGG16 as feature extractor
  • All VGG16 layers are frozen
  • Custom classifier added on top

3. VGG16 Fine-tuned

  • Uses pretrained VGG16
  • First two blocks frozen
  • Remaining layers fine-tuned
  • Custom classifier added on top

Training Procedure

  • The dataset is split into training and validation sets (80%/20%) automatically in the code.
  • Data augmentation is applied to the training set.
  • Each model is trained and evaluated on the validation set.
  • For VGG16 Fine-tuned and Custom CNN, feature maps are visualized for the 1st, 3rd, and 5th convolutional layers.

Results

Model Comparison

Model Accuracy Precision Recall F1 Score Training Time (s)
CustomCNN 0.62 0.65 0.62 0.62 520
VGG16FeatureExtractor 0.90 0.91 0.90 0.90 1399
VGG16FineTuned 0.95 0.95 0.95 0.95 3307

Training History

CustomCNN

CustomCNN Training History

VGG16 Feature Extractor

VGG16FeatureExtractor Training History

VGG16 Fine-Tuned

VGG16FineTuned Training History

Feature Visualizations

CustomCNN

CustomCNN Feature Maps

VGG16 Fine-Tuned

VGG16FineTuned Feature Maps

Interpretation

  • CustomCNN: Achieves moderate accuracy, showing the effectiveness of a model built from scratch.
  • VGG16 Feature Extractor: Transfer learning with frozen layers significantly improves performance.
  • VGG16 Fine-Tuned: Fine-tuning the upper layers of VGG16 yields the best results, demonstrating the power of adapting pretrained models to specific tasks.

How to Run

  1. Install dependencies:
    pip install -r requirements.txt
  2. Download and prepare the dataset as described above.
  3. Run the main script:
    python main.py
  4. Results, model weights, and visualizations will be saved in the results/ directory.

Trained Models

Trained model weights are available via the following Google Drive links:

Note: Model files are not included in this repository due to their large size. Please use the links above to download them as needed.

Features

  • Multi-class image classification
  • Transfer learning with VGG16
  • Feature visualization using Zeiler & Fergus method
  • Comprehensive model evaluation metrics
  • Training history visualization
  • Model comparison and analysis

Requirements

Install the required packages:

pip install -r requirements.txt

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages