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.
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.
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.
- Extract SIFT keypoint descriptors with OpenCV.
- Fit a KMeans visual vocabulary from training descriptors.
- Convert each image into a Bag of Visual Words histogram.
- Train an SVC classifier on those histograms.
- Resize each image to the VGG16 input size and apply VGG16 preprocessing.
- Use an ImageNet-pretrained VGG16 model without its classification head to extract feature vectors.
- Train a linear SVC on the flattened feature vectors.
Labeled image folders
|
+--> SIFT descriptors --> KMeans visual vocabulary --> BoVW histogram --> SVM
|
+--> VGG16 feature extractor --> flattened feature vector -----------> Linear SVM
|
Accuracy evaluation
| 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.
- Python
- OpenCV and SIFT
- NumPy
- scikit-learn: KMeans, SVC, train_test_split, and accuracy evaluation
- TensorFlow/Keras and VGG16
- Transfer-learning-based feature extraction
.
├── 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
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.
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txtRun 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.jsonOptional 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 notebookThe 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.
- 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.
- 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.
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.