Image Classification using Convolutional
Neural Networks (CNN) for Cat and Dog
Detection
Akula Sonu
Department of Networking and
Communications
School of Computing College of
Engineering & Technology
SRM Institute of Science and
Technology
Kattankulathur-603203, India
as6626@[Link]
Abstract-- Image classification plays a crucial role in implements and analyzes a CNN model for binary image
modern artificial intelligence systems, particularly in classification using Python and Keras
applications such as autonomous vehicles, medical
imaging, and object recognition. Among several deep IV. Methodology
learning models, Convolutional Neural Networks (CNNs)
have shown remarkable efficiency in learning A. Dataset and Preprocessing
hierarchical features from raw image data. This paper
presents the design, implementation, and performance The dataset used in this study comprises images of cats and
evaluation of a CNN-based model for classifying images dogs labeled accordingly. Each image is resized to a
into two categories—cats and dogs. The model, built uniform dimension of 100 × 100 pixels and contains three
using the Keras library with TensorFlow as the backend, color channels (RGB). The dataset is split into training
employs layers of convolution, pooling, flattening, and and testing subsets, ensuring that both sets represent all
dense connections to extract and learn visual patterns. classes evenly.
Experimental results demonstrate that the proposed CNN
achieves high classification accuracy with efficient
Before training, the input images are normalized by
computation, making it suitable for lightweight image
dividing pixel values by 255, scaling them to a range
recognition tasks.
between 0 and 1. This normalization accelerates
convergence during training and stabilizes the learning
Keywords-- Convolutional Neural Network (CNN), Deep
process. Labels are stored as binary values (0 for dogs, 1
Learning, Image Classification, Keras, TensorFlow,
for cats).
Feature Extraction, Computer Vision.
I. Introduction B. CNN Architecture
The evolution of deep learning has revolutionized
computer vision by enabling machines to recognize and The convolution layer applies a set of filters across the
interpret images with near-human accuracy. Traditional input image to detect patterns. Each filter produces a
machine learning approaches required manual feature feature map that highlights specific features like edges or
extraction, where handcrafted features like edges, corners, color gradients. The use of a 3×3 kernel with 32 filters
or color histograms were computed before feeding data helps the model capture both fine and broad details. The
into classifiers. However, such methods lacked scalability ReLU (Rectified Linear Unit) activation function is
and generalization capabilities. applied to introduce non-linearity, defined as:
Convolutional Neural Networks (CNNs) address these
limitations by automatically learning spatial hierarchies of f (x)=max ( 0 , x )Pooling layers downsample feature
features directly from pixel data [1]. CNNs are designed to maps to reduce computational load and prevent overfitting.
capture local dependencies and spatial structures in images The 2×2 max pooling operation retains the maximum
through a combination of convolutional and pooling value within each region, preserving the most prominent
operations. features while discarding redundant information
The Cat vs Dog classification problem is a well-known
benchmark in computer vision. It challenges a model to Once high-level features are extracted, the Flatten layer
accurately distinguish between two visually similar converts the two-dimensional feature maps into a one-
categories. The ability of CNNs to learn complex visual dimensional vector, enabling connection to fully connected
features makes them ideal for this task. This paper layers for final classification
The results confirm that CNNs can effectively capture
The first dense layer has 64 neurons with ReLU
activation, which combines extracted features into visual features from limited-size datasets without manual
meaningful patterns. feature extraction. The learned filters in the early layers
The output dense layer contains a single neuron with a focused on low-level details such as edges, while deeper
Sigmoid activation function, producing a probability layers identified high-level concepts like fur texture and
value between 0 and 1: body shape.
1
σ (x)= −x The model’s simplicity and efficiency make it suitable for
1+e small-scale embedded systems and educational research
A threshold of 0.5 determines the class label — values where computational resources are limited. However,
below 0.5 correspond to “dog” and above 0.5 to “cat.” overfitting may occur if the dataset is too small, and future
implementations could use data augmentation or transfer
learning with pre-trained models like VGG16 or
ResNet50 to further enhance performance.
V. Conclusion
This paper demonstrated the design and implementation of
a Convolutional Neural Network for the binary
classification of cats and dogs. The model effectively
utilized convolutional, pooling, flatten, and dense layers to
extract hierarchical image features and achieve high
Fig 1 WorkFlow classification accuracy. The achieved performance of 98%
accuracy proves that CNNs are capable of learning robust
C. Model Compilation and Training visual representations even with moderate computational
resources.
The CNN model is compiled using the Adam optimizer
and the binary cross-entropy loss function. Adam is In future work, this model can be expanded for multi-class
preferred for its adaptive learning rate and efficient classification tasks or deployed in real-time animal
handling of sparse gradients [3]. The model is trained for detection systems using cloud-based platforms.
15 epochs with a batch size of 64, meaning 64 samples are Additionally, integrating transfer learning and
processed before each weight [Link] is performed regularization techniques can help generalize the model
on the preprocessed dataset, with the model’s weights to larger and more diverse datasets.
adjusted to minimize the loss function. During training,
both the loss and accuracy metrics are monitored to
evaluate performance.
IV. Result and Discussion
The proposed CNN achieved a training accuracy of
approximately 98% with a loss value of 0.0784 after 15
epochs. The model was tested on unseen images, and
predictions were made using the trained network. When
presented with random samples from the test dataset, the
model correctly identified the image category—either cat
or dog.
Fig 2. result
Figure 2 would typically illustrate sample predictions and
the learning curve of training accuracy versus epochs.