This project implements a deep learning-based flower classification system that identifies five flower species (Daisy, Dandelion, Rose, Sunflower, and Tulip) from images. The system uses a lightweight Convolutional Neural Network (CNN) built with TensorFlow/Keras, trained on the Flowers Recognition dataset from Kaggle. It includes an interactive interface for uploading images and provides predictions with confidence scores and additional botanical information.
- Classification: Accurately classifies images into one of five flower species.
- Data Preprocessing: Resizes images to 224x224 pixels, normalizes pixel values, and applies data augmentation (random flips, rotations, zooms).
- Model: Lightweight CNN with convolutional layers, max-pooling, dropout, and global average pooling for efficient performance.
- Evaluation: Includes accuracy metrics, confusion matrix, and classification report.
- Interactive Predictions: Allows users to upload images for real-time classification with detailed flower information (e.g., scientific name, family, habitat).
- Visualizations: Displays sample images, class distribution, training history, and prediction probabilities.
The project uses the Flowers Recognition dataset from Kaggle, containing images of five flower classes:
- Daisy (Bellis perennis)
- Dandelion (Taraxacum officinale)
- Rose (Rosa)
- Sunflower (Helianthus annuus)
- Tulip (Tulipa)
Each class is limited to 200 images per class for memory efficiency during training.
- Python 3.7+
- Libraries:
- TensorFlow 2.x
- OpenCV (cv2)
- NumPy
- Matplotlib
- Seaborn
- Scikit-learn
- PIL (Pillow)
- KaggleHub
- Google Colab (recommended for cloud-based execution with GPU support)
- Clone the repository:
git clone https://github.com/CODE-INAYAT/FlowerClassification.git cd FlowerClassification - Install dependencies:
pip install tensorflow opencv-python numpy matplotlib seaborn scikit-learn pillow kagglehub
- Run the Code:
- Open the
flower_classification.ipynbnotebook in Google Colab or a local Jupyter environment. - Execute the cells sequentially to download the dataset, preprocess data, train the model, and evaluate performance.
- Open the
- Classify Images:
- Use the
upload_and_predict()function to upload an image and get predictions. - Example output includes the predicted flower class, scientific name, confidence score, and additional information (e.g., family, habitat).
- Use the
- Test Predictions:
- Run
test_sample_predictions(num_samples=3)to classify random test images with visualizations.
- Run
flower_classification.ipynb: Main Jupyter notebook with the complete code.README.md: This file.image1.jpeg:
- Model Architecture: Lightweight CNN with 3 convolutional layers, max-pooling, dropout (0.25-0.5), and global average pooling.
- Training Setup:
- Optimizer: Adam (learning rate=0.001)
- Loss: Sparse categorical cross-entropy
- Epochs: 30 (with early stopping)
- Batch Size: 16
- Data Split: 70% training, 15% validation, 15% test.
- Performance: Achieves ~85-90% test accuracy (based on typical CNN performance).
- Accuracy: Approximately 85-90% on the test set.
- Visualizations:
- Sample images with scientific names.
- Confusion matrix showing classification performance.
- Training/validation accuracy and loss plots.
- Sample Prediction:
- Input: Flower image.
- Output: Predicted class (e.g., "Rose"), scientific name (e.g., "Rosa"), confidence score (e.g., 92%), and botanical details.
- Expand the dataset to include more flower species and diverse image conditions.
- Implement transfer learning with pre-trained models (e.g., MobileNet, EfficientNet).
- Develop a mobile app for real-time flower identification.
- Integrate augmented reality for interactive flower information display.
- Optimize for edge devices using edge computing.
- Kaggle Flowers Recognition Dataset: https://www.kaggle.com/datasets/alxmamaev/flowers-recognition
- Nilsback, M. E., & Zisserman, A. (2008). Automated flower classification over a large number of classes. 2008 Sixth Indian Conference on Computer Vision, Graphics & Image Processing, 722-729.
- Chollet, F. (2017). Deep Learning with Python. Manning Publications.
- TensorFlow Documentation: https://www.tensorflow.org/tutorials/images/classification/
- Goodfellow, I., Bengio, Y., & Courville, A. (2016). Deep Learning. MIT Press.