Cat Dog Classification Project
Cat Dog Classification Project
Using ResNet50
A Binary Classification Project with
Image Preprocessing and Machine
Learning
Project Overview
• This project aims to implement a complete
image processing pipeline for binary
classification (cat vs. dog) using ResNet50
architecture and various techniques such as
image preprocessing, segmentation, feature
extraction, and machine learning
classification.
Dataset
• The dataset used is Kaggle's Dogs vs. Cats
dataset, containing 1,000 images (500 cats and
500 dogs) with a standardized resolution of
512x512 pixels. The dataset is split into three
subsets: training, validation, and testing.
Image Preprocessing
• In this stage, image quality is enhanced by
performing the following tasks:
• 1. Resizing images to 128x128 pixels.
• 2. Normalizing pixel values (scaling between 0
and 1).
• 3. Reducing noise using filters.
• 4. Optionally converting to grayscale.
• 5. Contrast enhancement using histogram
equalization.
Image Segmentation
• Segmentation isolates regions of interest
(animals). Techniques include:
• 1. Classical Methods: Thresholding, Edge
Detection (Canny, Sobel), Color Segmentation.
• 2. Advanced Methods: DeepLabV3+, U-Net,
Mask R-CNN.
• Segmentation creates binary masks for cats
and dogs, helping isolate animals from the
background.
Feature Extraction
• In feature extraction, we calculate geometric,
textural, and structural features:
• 1. Geometric: Area, perimeter, aspect ratio,
circularity.
• 2. Texture: Gray-Level Co-occurrence Matrix
(GLCM), Local Binary Patterns (LBP).
• 3. Structural: Hu moments, color histograms.
• These features help describe the images for
classification.
Machine Learning Classification
• The images are classified using machine
learning algorithms:
• 1. Support Vector Machine (SVM)
• 2. k-Nearest Neighbors (k-NN)
• 3. Random Forest
• 4. Logistic Regression
• The model is evaluated using a confusion
matrix and accuracy metrics.
Code Walkthrough
• The code includes the following key steps:
• 1. **Dataset Loading & Preprocessing:**
Using `cv2` and `Pandas` to load and clean the
dataset.
• 2. **Data Augmentation & Generators:**
Creating `ImageDataGenerator` for training,
validation, and test sets.
• 3. **Model Creation:** Using ResNet50 with
customizable frozen layers.
• 4. **Model Training:** Applying early
Model Evaluation & Results
• After training, the model's performance is
evaluated on the test set.
• We use metrics like accuracy, precision, recall,
and F1-score to compare the models.
• Results are displayed using confusion matrices
and performance curves.
Conclusion
• This project demonstrates the use of image
preprocessing, segmentation, feature
extraction, and machine learning classification
for the task of distinguishing between cats and
dogs.
• ResNet50, a powerful pre-trained model, was
fine-tuned for the task, providing high
performance.