This project implements a computer vision pipeline using a Support Vector Machine (SVM) to classify images into binary categories (Cats vs. Dogs). The model reads raw images, processes them into normalized numerical representations, and fits an optimal linear separating hyperplane to make predictions.
The workflow is designed around the Cats-And-Dogs-Mini-Dataset on Kaggle, an optimized 23 MB collection ideal for efficient machine learning tasks.
- Total Sample Count: 1,000 images
- Class Balance: 500 images of cats (
cats_set/ Label: 0) & 500 images of dogs (dogs_set/ Label: 1)
⚠️ Note: Raw image folders are excluded from this remote repository via.gitignoreto adhere to clean code hosting size practices.
- Image Preprocessing: Uses
opencv-python(cv2) to parse local image directories, convert images to grayscale (IMREAD_GRAYSCALE), and resize them uniformly to (100 \times 100) pixels. - Feature Flattening: Flattens the 2D image matrices into 1D arrays ((10,000) individual feature inputs per image) packed into structured
numpyarrays. - Data Splitting: Uses a stratified 80/20 train-test split (
train_test_split) to maintain perfect class balance across training and validation sets. - Model Architecture: Initializes and trains a Scikit-Learn
SVCalgorithm configured with alinearkernel. - Diagnostics: Performance is validated using
accuracy_scoreand a comprehensiveclassification_report(measuring Precision, Recall, and F1-Score).
git clone https://github.com
cd your-repository-nameEnsure you have Python installed, then run:
pip install numpy scikit-learn opencv-python notebook- Download the archive zip directly from the Kaggle Cats-And-Dogs-Mini-Dataset.
- Extract the archive into your preferred local directory, maintaining the structural subfolder format:
📁 Your_Local_Dataset_Folder ├── 📁 cats_set └── 📁 dogs_set - Update the
data_dirstring variable in your notebook to match your machine's exact directory path before executing the cells.
Launch your local Jupyter interface to run the script:
jupyter notebook Task3.ipynb