Downloads · 30 days
57
10% of all-time downloads
a-01a/dogs-vs-cats-svm
dogs-vs-cats-svm is a image classification model from a-01a. Use it when you need a label for an image. It is set up for keras. The card lists the license as mit.
A binary image classification model that distinguishes between cats and dogs using Support Vector Machine (SVM) combined with VGG16 transfer learning. The model is trained on two combined datasets and saved in modern…
Downloads · 30 days
57
10% of all-time downloads
All-time downloads
583
Public
Repo size
127 MB
Likes
0
Public
Click a slice to open those files.
.pkl62.8 MB · 50%
From the Hugging Face model README
A binary image classification model that distinguishes between cats and dogs using Support Vector Machine (SVM) combined with VGG16 transfer learning. The model is trained on two combined datasets and saved in modern .keras format.
This model implements a hybrid approach combining classical machine learning with deep learning:
Input Image (224×224×3)
↓
VGG16 Feature Extractor (frozen)
↓
Global Average Pooling → 512 features
↓
StandardScaler (normalization)
↓
PCA (512 → 256 components)
↓
SVM (RBF kernel)
↓
Binary Output (Cat=0, Dog=1)
Install dependencies:
uv pip install tensorflow scikit-learn h5py huggingface-hub pillow
Run inference:
uv run python inference.py test/cat1.jpeg
Expected output:
🐱🐶 Dogs vs Cats Classifier - Inference (.keras format)
Image: test/cat1.jpeg
✓ Using local model files
Loading model components...
✓ Feature extractor loaded
✓ PCA, Scaler, and SVM loaded
Making prediction...
Prediction: Cat 🐱
Confidence: 92.34%
Install dependencies:
uv pip install tensorflow scikit-learn h5py kagglehub pillow jupyter matplotlib seaborn tqdm
Start Jupyter Notebook:
jupyter notebook train_model.ipynb
Training process:
./kaggle_data/.keras formatFiles generated:
cats-vs-dogs-components.keras - Feature extractorcats-vs-dogs-components.keras - PCA/Scaler/SVM componentsTest the model:
uv run python inference.py test/dog1.jpeg
Create .env file:
HF_TOKEN_CD=hf_your_token_here
Get your token from: https://huggingface.co/settings/tokens
Run upload script:
uv run python upload_to_huggingface.py
View your model:
Visit https://huggingface.co/YOUR_USERNAME/dogs-vs-cats-svm
1. Kaggle Dataset: dog-and-cat-classification-dataset
./kaggle_data/2. Local Dataset: dogs-vs-cats/train/
Total Combined: 10,000 images from diverse sources
Edit train_model.ipynb Cell 4 for different configurations:
| Config | Samples | Time | Expected Accuracy |
|---|---|---|---|
| Fast | 2K (1K each) | 5-10 min | ~75% |
| Balanced | 10K (5K each) | 30-45 min | ~87% |
| Maximum | 25K (12.5K each) | 60-90 min | ~95% |
N_SAMPLES_PER_DATASET = 5000 # Adjust
PCA_COMPONENTS = 256 # 128 (fast), 256 (balanced), 512 (max)
| Metric | Score |
|---|---|
| Accuracy | ~87-95% |
| Precision | >0.85 |
| Recall | >0.85 |
| F1-Score | >0.85 |
cats_dogs_svm/
├── train_model.ipynb # Training notebook (multi-dataset)
├── inference.py # Inference script (.keras format)
├── upload_to_huggingface.py # HuggingFace upload script
│
├── cats-vs-dogs-components.keras # VGG16 feature extractor (~58 MB)
├── cats-vs-dogs-components.keras # PCA/Scaler/SVM (~3-5 MB)
│
├── kaggle_data/ # Auto-downloaded Kaggle dataset
│ └── dog-and-cat-classification-dataset/
│ └── train/
│
├── dogs-vs-cats/ # Local dataset
│ └── train/
│
├── test/ # Test images
│ ├── cat1.jpeg
│ ├── dog1.jpeg
│ └── ...
│
└── model_cache/ # HuggingFace model cache
./kaggle_data/✅ Binary classification of cat and dog images
✅ Educational demonstration of transfer learning
✅ Baseline model for image classification tasks
✅ Feature extraction pipeline for similar datasets
uv pip install --upgrade tensorflow scikit-learn h5py
Reduce samples in train_model.ipynb Cell 4:
N_SAMPLES_PER_DATASET = 2000 # Smaller dataset
BATCH_SIZE = 8 # Smaller batches
Train with more samples:
N_SAMPLES_PER_DATASET = 10000 # More data
PCA_COMPONENTS = 512 # Keep more features
This model is released under the MIT License.
@misc{dogs_cats_svm_vgg16_2025,
author = {{Abdul Ahad}},
title = {Dogs vs Cats Classification using SVM and VGG16 Transfer Learning},
year = {2025},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/990aa/SCT_ML_3}}
}
Author: Abdul Ahad (@990aa)
Last Updated: November 2025
Model Format: Keras (.keras)