Skip to content

Repository files navigation

🥦 GreenClassify

GreenClassify Logo

Smart CNN-Powered Vegetable Classifier

Identify 15 common vegetable categories in seconds using deep learning.

Python TensorFlow Flask Accuracy


🌟 Visual Preview

Home Interface (Vibrant Glassmorphism Theme)

Below is the responsive landing page featuring modern gradients, a hero search component, and theme options.

GreenClassify Home Screen


📖 Project Overview

GreenClassify is a production-ready, deep learning-powered image classification system. It combines a state-of-the-art MobileNetV2 Convolutional Neural Network (CNN) backbone with a lightweight Flask web server to classify vegetables in real-time. It features a bilingual output engine, theme toggles, and pre-inference confidence checks to verify if the uploaded image is actually a vegetable.


🚀 Key Features

  • Deep Learning Classifier: Backed by a fine-tuned MobileNetV2 model achieving a near-perfect 99.90% test set accuracy.
  • 15 Supported Categories: Bean, Bitter Gourd, Bottle Gourd, Brinjal, Broccoli, Cabbage, Capsicum, Carrot, Cauliflower, Cucumber, Papaya, Potato, Pumpkin, Radish, and Tomato.
  • Bilingual Translations (English & Hindi): Instantly translates predictions (e.g., Carrot ↔️ गाजर).
  • Intelligent Validation Guard: Employs a confidence filter (threshold >= 50%). If the image confidence score drops below 50%, the application warns the user: "This is not a vegetable."
  • Interactive Frontend Experience:
    • Theme Switcher: Seamlessly toggle between Vibrant (glassmorphic styling) and Minimal (clean flat UI) themes.
    • Real-time Previews: Instant client-side file reading to display thumbnail previews before predicting.
    • Smart Loader: Fluid progress indicator during inference time.

🖼️ Prediction Example

Classification Output (Minimal Theme)

Below is a live classification example predicting a Carrot with 98.3% confidence score in the Minimal theme:

GreenClassify Prediction Result


📂 Repository Structure

GreenClassify/
├── screenshots/               # Folder for application preview images
│   ├── image.png              # Developer workspace screenshot
│   ├── image copy.png         # Web UI landing page preview
│   └── image copy 2.png       # Web UI prediction output preview
├── static/
│   ├── css/
│   │   └── style.css          # Core CSS variables, layout, and theme toggling
│   ├── uploads/               # Holds uploaded images temporarily
│   ├── background.jpg         # Hero header background image
│   └── vibrant-green.avif     # App logo branding image
├── templates/
│   └── index.html             # Responsive Flask UI layout
├── 01_data_analysis_preprocessing.ipynb  # Notebook for dataset preprocessing and EDA
├── 02_model_evaluation_testing.ipynb     # Notebook for model loading, evaluation, and test summary
├── app.py                     # Main Flask web application
├── requirements.txt           # Package dependencies
└── vegetable_classifier_model.h5  # Trained MobileNetV2 CNN model file

🧠 Model Architecture & Training

The classification engine relies on a pre-trained MobileNetV2 backbone trained on large-scale datasets, with custom dense output layers tailored for the 15 classes of vegetables.

Model Configuration

  • Input Dimension: 224 x 224 x 3 (RGB normalized images)
  • Normalization: Normalized pixel values to [0, 1] range (1./255)
  • Total Parameters: 2,277,201
  • Trainable Parameters: 2,243,087
  • Non-trainable Parameters: 34,112
  • Optimizer: Adam

Performance Evaluation

Evaluated on a balanced test partition of 3,000 images (200 test images per category):

  • Test Accuracy: 99.90% (2,997 / 3,000 correct predictions)
  • Test Loss: 0.0051 (Categorical Cross-Entropy)

Test Set Performance Breakdown

              precision    recall  f1-score   support

        Bean       1.00      1.00      1.00       200
Bitter_Gourd       1.00      0.99      0.99       200
Bottle_Gourd       1.00      1.00      1.00       200
     Brinjal       1.00      1.00      1.00       200
    Broccoli       1.00      1.00      1.00       200
     Cabbage       1.00      1.00      1.00       200
    Capsicum       1.00      1.00      1.00       200
      Carrot       1.00      1.00      1.00       200
 Cauliflower       1.00      1.00      1.00       200
    Cucumber       1.00      1.00      1.00       200
      Papaya       1.00      0.99      1.00       200
      Potato       1.00      1.00      1.00       200
     Pumpkin       1.00      1.00      1.00       200
      Radish       1.00      1.00      1.00       200
      Tomato       1.00      1.00      1.00       200

    accuracy                           1.00      3000
   macro avg       1.00      1.00      1.00      3000
weighted avg       1.00      1.00      1.00      3000

🛠️ Development & Execution Workspace

Developers can launch and test the deep learning pipeline interactively through the provided Jupyter Notebooks.

Developer Workspace

Notebooks

  1. 01_data_analysis_preprocessing.ipynb: Analyzes directories, checks class-wise image distribution, maps Hindi labels, and pre-renders training dataset profiles.
  2. 02_model_evaluation_testing.ipynb: Validates the model architecture, parses parameter summaries, generates classification reports, and evaluates loss metrics on the test partition.

🚀 Setup & Installation

Follow these instructions to install dependencies and run the project locally.

1. Prerequisites

  • Make sure you have Python 3.11 installed.
  • We recommend using a Virtual Environment to avoid library version mismatches.

2. Setup Virtual Environment

# Create environment
python -m venv .venv

# Activate (Windows PowerShell)
.\.venv\Scripts\Activate.ps1

# Activate (Windows CMD)
.\.venv\Scripts\activate.bat

# Activate (macOS/Linux)
source .venv/bin/activate

3. Install Dependencies

python -m pip install --upgrade pip
python -m pip install -r requirements.txt

4. Launch Application

python app.py

Open your browser and navigate to:

http://127.0.0.1:5000/

About

AI-powered vegetable image classification system built with TensorFlow, MobileNetV2, and Python to identify vegetable categories from images using deep learning and computer vision.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages