ML Internship at Prodigy InfoTech
Task - 03
This repository contains code on support vector machine (SVM) to classify images of cats and dogs from the Kaggle dataset.
-
Data Preparation:
- The script extracts the contents of two zip files ("cat vs dog train.zip" and "cat vs dog test.zip") containing training and testing images, respectively.
- The extracted images are stored in the directories specified by
train_dir
andtest_dir
.
-
Data Augmentation:
- ImageDataGenerator is used for data preprocessing and augmentation. It rescales pixel values to the range [0,1] and applies shear, zoom, and horizontal flip transformations to augment the training dataset.
-
Loading Data:
- Flow from Directory is used to load and augment images from the specified directories for both training and testing datasets.
-
CNN Model Architecture:
- A Sequential model is used to build the CNN.
- Convolutional layers (
Conv2D
) with rectified linear unit (ReLU) activation are used to capture image features. - MaxPooling layers reduce the spatial dimensions of the feature maps.
- A Flatten layer converts the 2D feature maps to a 1D vector.
- Dense layers with ReLU activation introduce non-linearity, and the final Dense layer uses a sigmoid activation for binary classification.
-
Model Compilation:
- The model is compiled with the Adam optimizer, binary crossentropy loss function (suitable for binary classification), and accuracy as the evaluation metric.
-
Model Training:
- The
fit
function is used to train the model on the training dataset for a specified number of epochs (10 in this case). - The validation dataset (
test_generator
) is used to monitor the model's performance during training.
- The
-
Model Evaluation:
- After training, the model is evaluated on the test dataset using the
evaluate
method. - The test accuracy is printed.
- After training, the model is evaluated on the test dataset using the
- Dataset from Kaggle Cat vs Dog.
- Used Jupiter Notebook for Python Coding.
The following techniques are implemented in this project:
- support vector machine (SVM)