Skip to content

CODE-INAYAT/FlowerClassification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Flower Classification Project

Overview

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.

Features

  • 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.

Dataset

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.

Requirements

  • 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)

Installation

  1. Clone the repository:
    git clone https://github.com/CODE-INAYAT/FlowerClassification.git
    cd FlowerClassification
  2. Install dependencies:
    pip install tensorflow opencv-python numpy matplotlib seaborn scikit-learn pillow kagglehub

Usage

  1. Run the Code:
    • Open the flower_classification.ipynb notebook in Google Colab or a local Jupyter environment.
    • Execute the cells sequentially to download the dataset, preprocess data, train the model, and evaluate performance.
  2. 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).
  3. Test Predictions:
    • Run test_sample_predictions(num_samples=3) to classify random test images with visualizations.

File Structure

  • flower_classification.ipynb: Main Jupyter notebook with the complete code.
  • README.md: This file.
  • image1.jpeg: download

Training Details

  • 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).

Results

  • 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.

Future Improvements

  • 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.

References

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors