← Back to Projects
Deep LearningCNNImage Classification

Vegetable Image Classification with CNN

Deep Learning — Image Classification

Project Overview

This project builds a deep learning image classification model for the Vegetable Image Dataset. A custom Convolutional Neural Network (CNN) is trained to distinguish 15 vegetable classes using image normalization, data augmentation, dropout regularization, and training callbacks.

Tools Used

PythonTensorFlowKerasNumPyMatplotlibPillow (PIL)scikit-learnTensorFlow.jsTensorFlow Litegdown

Dataset & Classes

The dataset contains 18,000 vegetable images across 15 classes: Bean, Bitter Gourd, Bottle Gourd, Brinjal, Broccoli, Cabbage, Capsicum, Carrot, Cauliflower, Cucumber, Papaya, Potato, Pumpkin, Radish, and Tomato. Images are resized to 224×224 pixels and split into 14,399 training, 1,801 validation, and 1,800 testing images.

Deep Learning Workflow

Dataset Preparation → Train/Validation/Test Split → Image Rescaling & Augmentation → CNN Architecture → Adam Optimization → Training with Callbacks → Accuracy & Loss Evaluation → Inference → SavedModel, TensorFlow Lite & TensorFlow.js Export

Model Results

98%

Training accuracy reported in the notebook reached 98.00%.

98%

Validation accuracy reported in the notebook reached 98.00%.

97.72%

Testing accuracy reported in the notebook reached 97.72%.

3×

The model was exported to SavedModel, TensorFlow Lite, and TensorFlow.js formats for broader deployment options.

Model Architecture

01

The CNN uses four Conv2D blocks with 64, 128, 256, and 512 filters, each followed by MaxPooling and Dropout.

02

A Dense layer with 128 units is used before the final Softmax output layer for 15-class classification.

03

Image augmentation includes rotation, width/height shifting, shear, zoom, and horizontal flipping.

04

EarlyStopping, ModelCheckpoint, and ReduceLROnPlateau are used to stabilize training and retain the best model.

Training & Inference Results

Vegetable class distribution
Training image distribution across the 15 vegetable classes
Augmented vegetable image samples
Augmented training image samples used during model training
Training and validation accuracy and loss curves
Training and validation accuracy/loss curves
Vegetable classification inference example
Example inference result from the testing set