Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Animal Image Classification

A comparison of handcrafted computer vision features versus transfer-learning-based deep features for multi-class animal image classification. The project is organized as reusable Python pipelines, with a cleaned notebook kept as an experimentation companion rather than the main entry point.

Project Overview

This repository compares two supervised image-classification workflows on a labeled folder-based animal-image dataset. It contrasts a SIFT and Bag of Visual Words baseline with features extracted from an ImageNet-pretrained VGG16 model, then trains an SVM classifier for each representation.

Problem

Given an image placed in a class-specific dataset folder, predict its animal class. The implementation expects images organized by label and evaluates each pipeline with a held-out train/test split.

Approaches Compared

1. SIFT + Bag of Visual Words + SVM

  1. Extract SIFT keypoint descriptors with OpenCV.
  2. Fit a KMeans visual vocabulary from training descriptors.
  3. Convert each image into a Bag of Visual Words histogram.
  4. Train an SVC classifier on those histograms.

2. Pre-trained VGG16 Features + Linear SVM

  1. Resize each image to the VGG16 input size and apply VGG16 preprocessing.
  2. Use an ImageNet-pretrained VGG16 model without its classification head to extract feature vectors.
  3. Train a linear SVC on the flattened feature vectors.

Pipeline

Labeled image folders
        |
        +--> SIFT descriptors --> KMeans visual vocabulary --> BoVW histogram --> SVM
        |
        +--> VGG16 feature extractor --> flattened feature vector -----------> Linear SVM
                                                                         |
                                                                  Accuracy evaluation

Key Results

Approach Classifier Recorded Test Accuracy
SIFT + Bag of Visual Words SVM 59.37%
VGG16 Deep Features Linear SVM 88.72%

These values are historical saved results from the original experiment notebook. The refactored reusable pipelines have not yet been rerun on the original dataset to verify exact reproducibility.

The saved experiment showed an increase in test accuracy from 59.37% using SIFT/BoVW features to 88.72% using VGG16 deep features. See results/README.md for the result context.

Technologies

  • Python
  • OpenCV and SIFT
  • NumPy
  • scikit-learn: KMeans, SVC, train_test_split, and accuracy evaluation
  • TensorFlow/Keras and VGG16
  • Transfer-learning-based feature extraction

Repository Structure

.
├── README.md
├── requirements.txt
├── .gitignore
├── src/
│   ├── sift_pipeline.py
│   ├── vgg16_pipeline.py
│   └── evaluate.py
├── notebooks/
│   └── animal_classification_experiments.ipynb
├── data/
│   └── README.md
└── results/
    └── README.md

Dataset

The dataset is intentionally excluded from version control. Supply your own folder-per-class image dataset; no dataset source, license, or distribution is claimed by this repository. Read data/README.md for the expected structure.

Installation

python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt

Usage

Run either reusable pipeline from the repository root. Replace the example dataset path with the path to your own labeled image folders.

python src/sift_pipeline.py --dataset-dir .\data\your_dataset --result-path .\results\sift_run.json
python src/vgg16_pipeline.py --dataset-dir .\data\your_dataset --result-path .\results\vgg16_run.json

Optional parameters such as --test-size, --random-state, and the SIFT pipeline's --num-clusters are available through each command's --help output.

For interactive exploration, start Jupyter from the repository root and open notebooks/animal_classification_experiments.ipynb.

jupyter notebook

Evaluation

The original recorded notebook used an 80/20 train/test split with random_state=42 and reported accuracy. The only verified evaluation metrics are the two historical saved accuracies in the Key Results table:

  • SIFT + BoVW + SVM: 59.37%
  • VGG16 features + linear SVM: 88.72%

No verified precision, recall, F1-score, ROC-AUC, confusion matrix, loss, execution-time, dataset-size, or class-count result is available in the repository. These values are historical experiment outputs, not a claim of performance on every animal-image dataset. The included pipelines make the dataset location and experiment settings configurable for future reruns.

Limitations

  • The dataset and original image count are not included, so the saved results cannot be independently reproduced from this repository alone.
  • The recorded experiment reports accuracy only; no per-class metrics, confusion matrix, or repeated cross-validation results are available.
  • Both pipelines extract features for the full supplied dataset in memory.
  • This repository is an experiment project, not a deployed inference service.

Future Improvements

  • Add per-class precision, recall, F1-score, and confusion-matrix reporting.
  • Evaluate repeated splits or cross-validation where the dataset supports it.
  • Add model persistence and a small prediction interface for trained models.
  • Compare data augmentation and VGG16 fine-tuning against fixed feature extraction.

Attribution

The original experiment and project materials list Moris Sameh and Marco Magdy as collaborators. This portfolio-oriented repository preserves that attribution while removing personal student identifiers and environment-specific paths.

About

Animal image classification using SIFT and VGG16 feature extraction with machine learning-based classification.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages