This project performs image classification on the popular Dogs vs Cats dataset using a K-Nearest Neighbors (KNN) classifier. Feature extraction is done using Histogram of Oriented Gradients (HOG), and visualization is performed using confusion matrices and classification reports.
Vaishnavi_imageClassification.ipynb
β Notebook implementing:- Dataset download via Kaggle
- Image preprocessing
- HOG feature extraction
- KNN training and evaluation
-
Download Dataset
- Automatically downloads
dogs-vs-cats
dataset from Kaggle using API token.
- Automatically downloads
-
Image Preprocessing
- Resizes images to 64x64
- Loads and batches ~300 sample images
-
Feature Extraction
- Converts images to grayscale
- Extracts HOG features using
skimage.feature.hog
-
Classification
- Splits data (80% train / 20% test)
- Trains a KNN classifier (with
k=3
) - Evaluates performance
-
Visualization
- Classification report
- Confusion matrix heatmap
Install the following packages before running the notebook:
pip install numpy opencv-python scikit-learn scikit-image tensorflow matplotlib seaborn
- Dataset: Dogs vs Cats
- Structure:
dataset/ βββ dogs_vs_cats/ βββ train/ β βββ cat.0.jpg β βββ dog.0.jpg βββ test/ β βββ cat.1.jpg β βββ dog.1.jpg
- Upload your
kaggle.json
token (from your Kaggle account API). - Run the notebook cells in order.
- Outputs:
- HOG feature-based KNN model performance
- Confusion matrix heatmap
- Precision, recall, and F1-score
- Classifier: K-Nearest Neighbors (
k=3
) - Feature Extractor: HOG
- Evaluation:
- Confusion Matrix
- Classification Report