Skip to content

the11dev/ImageClassificationUsingKNN

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 

Repository files navigation

🐢🐱 Image Classification of Dogs vs Cats using KNN and HOG Features

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.


πŸ“ Contents

  • Vaishnavi_imageClassification.ipynb – Notebook implementing:
    • Dataset download via Kaggle
    • Image preprocessing
    • HOG feature extraction
    • KNN training and evaluation

πŸ“Œ Workflow Summary

  1. Download Dataset

    • Automatically downloads dogs-vs-cats dataset from Kaggle using API token.
  2. Image Preprocessing

    • Resizes images to 64x64
    • Loads and batches ~300 sample images
  3. Feature Extraction

    • Converts images to grayscale
    • Extracts HOG features using skimage.feature.hog
  4. Classification

    • Splits data (80% train / 20% test)
    • Trains a KNN classifier (with k=3)
    • Evaluates performance
  5. Visualization

    • Classification report
    • Confusion matrix heatmap

πŸ› οΈ Dependencies

Install the following packages before running the notebook:

pip install numpy opencv-python scikit-learn scikit-image tensorflow matplotlib seaborn

πŸ“‚ Dataset Details

  • Dataset: Dogs vs Cats
  • Structure:
    dataset/
    └── dogs_vs_cats/
        β”œβ”€β”€ train/
        β”‚   β”œβ”€β”€ cat.0.jpg
        β”‚   β”œβ”€β”€ dog.0.jpg
        β”œβ”€β”€ test/
        β”‚   β”œβ”€β”€ cat.1.jpg
        β”‚   β”œβ”€β”€ dog.1.jpg
    

πŸš€ How to Use (in Google Colab)

  1. Upload your kaggle.json token (from your Kaggle account API).
  2. Run the notebook cells in order.
  3. Outputs:
    • HOG feature-based KNN model performance
    • Confusion matrix heatmap
    • Precision, recall, and F1-score

πŸ“Š Results

  • Classifier: K-Nearest Neighbors (k=3)
  • Feature Extractor: HOG
  • Evaluation:
    • Confusion Matrix
    • Classification Report

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published