This project demonstrates the classification of images into two categories: cats and dogs, using image augmentation techniques and the Keras library. The goal is to build a convolutional neural network (CNN) model that can accurately classify images of cats and dogs.
The dataset used for this project consists of a large number of labeled images of cats and dogs. The dataset is sourced from the Microsoft Cats vs Dogs dataset, which can be downloaded from here. After downloading and extracting the dataset, the images are organized into separate directories for cats and dogs.
Image augmentation techniques are applied to the training dataset using the Keras ImageDataGenerator
class. This helps to artificially expand the training dataset and improve the model's ability to generalize to new images. The augmented images are then split into training and validation sets using a specified split size.
The model architecture used for this project is a CNN implemented in Keras. It consists of multiple convolutional layers with batch normalization, max pooling, and dropout layers to prevent overfitting. The model is compiled with the RMSprop optimizer and binary cross-entropy loss function.
The model is trained on the augmented training dataset using the fit
method in Keras. The training process is run for a specified number of epochs, and the training and validation accuracy and loss are recorded. The model's performance is evaluated on the validation dataset to assess its accuracy and generalization capability.
The training and validation accuracy and loss are plotted for each epoch to visualize the model's training progress. This helps to analyze the model's performance and identify overfitting or underfitting issues.
Once the model is trained and evaluated, it can be used to make predictions on new images of cats or dogs. The predict.py
script is provided, which takes the path to an image as input and outputs the predicted class label.
This project demonstrates the implementation of a cats vs dogs image classification model using image augmentation techniques and the Keras library. By leveraging image augmentation and a well-designed CNN architecture, the model achieves good accuracy in distinguishing between cats and dogs. Feel free to explore and modify the code to further enhance the model's performance or apply it to different image classification tasks.