A deep learning project that classifies fruits and vegetables images using custom CNN architectures, comparing model performance across two dataset configurations: 131 classes with 100 epochs and 81 classes with 200 epochs.
Automated fruit and vegetable recognition has practical applications in quality control, retail automation, and dietary monitoring systems. This project builds and evaluates custom Convolutional Neural Network architectures on the Fruits360 dataset to classify images across a large number of fruit and vegetable categories.
The project is structured as two progressive experiments: the first trains two CNN models on the full 131-class dataset, and the second refines the approach by reducing the class count to 81 and doubling the number of training epochs, providing a direct comparison of how dataset scope and training duration affect model performance.
- Loaded Training and Test image folders using
osandglob - Counted images per class in both training and test sets
- Visualized class distribution using bar charts
- Displayed sample images from the 15 most common fruit categories
- Inspected image shapes across the dataset
- Loaded images using Keras
load_imgand converted to arrays usingimg_to_array - Resized all images to 100x100 pixels
- Applied
ImageDataGeneratorwith rescaling, shear, horizontal flip, and zoom augmentation for training - Applied rescaling only for test data
- Model 1: CNN with four Conv2D layers (16, 32, 64, and 128 filters), MaxPooling, Dropout, Flatten, and Dense layers using RMSprop optimizer
- Model 2: Deeper CNN with Conv2D layers (32 and 64 filters), MaxPooling, Flatten, Dense (1024 units), and Dropout layers using RMSprop optimizer
- Trained both models using
fit_generatorwithsteps_per_epochandvalidation_stepsfor memory-efficient training
- Evaluated both models on the test set using loss and accuracy
- Plotted training vs validation loss and accuracy curves for each model
| Tool | Usage |
|---|---|
| TensorFlow / Keras | CNN model building, training, evaluation, data augmentation, and batch loading |
| numpy / pandas | Data manipulation and array operations |
| matplotlib / seaborn | Training curves and data distribution visualization |
| glob / os | File system navigation and image path management |
This project uses the Fruits360 dataset from Kaggle.