This project implements and compares three different deep learning approaches for flower classification:
- Custom CNN from scratch
- VGG16 as a feature extractor
- Fine-tuned VGG16
.
├── 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
The project uses the Flowers Dataset from Kaggle, which contains five categories of flowers:
- Daisy
- Dandelion
- Rose
- Sunflower
- Tulip
How to use the dataset:
- Download the dataset from Kaggle.
- Extract the images and organize them as follows:
Flowers/ └── train/ ├── daisy/ ├── dandelion/ ├── rose/ ├── sunflower/ └── tulip/ - Place the
Flowersfolder in the project root.
- 5 convolutional layers with batch normalization
- Max pooling layers
- Dropout for regularization
- Fully connected layers for classification
- Uses pretrained VGG16 as feature extractor
- All VGG16 layers are frozen
- Custom classifier added on top
- Uses pretrained VGG16
- First two blocks frozen
- Remaining layers fine-tuned
- Custom classifier added on top
- 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.
| 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 |
- 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.
- Install dependencies:
pip install -r requirements.txt
- Download and prepare the dataset as described above.
- Run the main script:
python main.py
- Results, model weights, and visualizations will be saved in the
results/directory.
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.
- 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
Install the required packages:
pip install -r requirements.txt



