Fruits Image Classification

Fruit Image Classification — CNN (Fruits 360)
Deep learning pipeline that classifies fruit images using a Convolutional Neural Network trained on the Fruits 360 dataset — production-aware and business-focused.
Project Overview
This project builds a Convolutional Neural Network (CNN) to classify fruit images into their correct categories using the Fruits 360 dataset (apples, bananas, oranges, grapes, and many more). The pipeline emphasizes robust preprocessing, augmentation, and regularization to maximize accuracy and generalization.
Key Features
- Dataset: Fruits 360 — well-labeled images across multiple fruit classes and varieties.
- Preprocessing: resize, normalize, and standardize image inputs for model consistency.
- Augmentation: on-the-fly image augmentation (rotation, flip, zoom, shift) to increase effective dataset size and reduce overfitting.
- CNN Architecture: layered convolution, pooling, batch normalization, dropout, and dense classification head designed for visual feature extraction.
- Training & Evaluation: train/validation/test split, use of callbacks (EarlyStopping, ModelCheckpoint), and evaluation via accuracy, precision, recall, and confusion matrices.
- Visualization: training curves, confusion matrix, and per-class performance plots to guide model diagnostics.
Technologies Used
- Python — orchestration and preprocessing
- TensorFlow & Keras — model definition, training, and deployment artifacts
- NumPy & Pandas — dataset handling
- Matplotlib & Seaborn — performance visualization
- Kaggle — dataset source and experiment tracking
How to run
- Download the Fruits 360 dataset (or point the notebook to the Kaggle dataset).
- Install dependencies:
pip install -r requirements.txt(includes tensorflow, numpy, pandas, matplotlib). - Run preprocessing → create data generators with augmentation → define CNN → train with callbacks.
- Export model:
model.save('fruit_cnn.h5')and generate evaluation plots for reporting.
Project Overview
Customers who left within the last month - the column is called Churn Services that each customer has signed up for - phone, multiple lines, internet, online security, online backup, device protection, tech support, and streaming TV and movies Customer account information - how long they've been a customer, contract, payment method, paperless billing, monthly charges, and total charges Demographic info about customers - gender, age range, and if they have partners and dependents Inspiration To explore this type of models and learn more about the subject.
Code Snippet
import os
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import tensorflow as tf
from zipfile import ZipFile
import datetime
# Load the dataset
train_ds=(os.path.join('/content/fruits','fruits-360-original-size','fruits-360-original-size','Training'))
test_ds=(os.path.join('/content/fruits','fruits-360-original-size','fruits-360-original-size','Test'))
val_ds=(os.path.join('/content/fruits','fruits-360-original-size','fruits-360-original-size','Validation'))
# Preprocessing
autotune=tf.data.AUTOTUNE
train_ds=train_ds.cache().prefetch(buffer_size=autotune)
test_ds=test_ds.cache().prefetch(buffer_size=autotune)
val_ds=val_ds.cache().prefetch(buffer_size=autotune)
# Model Architecture
model=tf.keras.Sequential([
tf.keras.layers.Rescaling(1./255),
tf.keras.layers.Conv2D(30,4,activation='relu'),
tf.keras.layers.Dropout(0.2),
tf.keras.layers.MaxPooling2D(),
tf.keras.layers.Dropout(0.2),
tf.keras.layers.Conv2D(60,5,activation='relu'),
tf.keras.layers.Dropout(0.2),
tf.keras.layers.MaxPooling2D(),
tf.keras.layers.Dropout(0.2),
tf.keras.layers.Conv2D(90,6,activation='relu'),
tf.keras.layers.Dropout(0.2),
tf.keras.layers.MaxPooling2D(),
tf.keras.layers.Dropout(0.2),
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(len(class_num))
#tf.keras.layers.Softmax()
])
# Make predictions
checkpoint_path='training_1/cp.ckpt'
checkpoint_dir=os.path.dirname(checkpoint_path)
cp_calllback=tf.keras.callbacks.ModelCheckpoint(filepath=checkpoint_path,
save_weights_only=True,
verbose=1)
)



















