Skip to content

DianaC01/cat-vs-dog-classifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cat vs Dog Image Classifier 🐱🐶

Deep learning project for image classification (cat vs dog) using MobileNetV2 with transfer learning in TensorFlow/Keras.
The model achieves high accuracy on the Kaggle Dogs vs Cats dataset and includes scripts for both training and testing on new images.

✨ Features

  • Transfer learning with MobileNetV2 (pre-trained on ImageNet)
  • Automatic dataset extraction from train.zip
  • Data augmentation (rotation, zoom, shift, shear, flip) for better generalization
  • Evaluation with accuracy, precision, recall, F1-score
  • Confusion matrix and training curves visualization
  • Separate script for testing unseen images with probability outputs

📂 Project Structure

cat-vs-dog-classifier/ ├─ src/ │ ├─ train_model.py # training script (80/10/10 split) │ └─ test_model.py # test script for new images ├─ results/ # generated plots and reports ├─ docs/ # project presentation ├─ models/ # saved models (ignored by Git) ├─ data/ # put train.zip here (ignored by Git) ├─ dataset/ # extracted dataset (ignored by Git) ├─ requirements.txt └─ .gitignore

📊 Dataset

  • Place the train.zip (from Kaggle Dogs vs Cats) inside the data/ folder.
  • The archive will be automatically extracted into dataset/train/ when running the training script.
  • Images are not uploaded to GitHub (they are ignored via .gitignore).

⚙️ Installation & Usage

# 1) (optional) create a virtual environment
python -m venv .venv
# Windows: .venv\Scripts\activate
# Linux/Mac: source .venv/bin/activate

# 2) install dependencies
pip install -r requirements.txt

# 3) training (train.zip must be in data/)
python src/train_model.py --zip_train data/train.zip --epochs 20

# 4) testing on new images
python src/test_model.py --images_folder "C:/path/to/test_images" --model_path models/model.h5

If models/model.h5 exceeds 100MB, use Git LFS or share the model externally (e.g., Google Drive):
git lfs install
git lfs track "*.h5"
git add .gitattributes
git add models/model.h5
git commit -m "Track model via LFS"
git push


During training, results are saved automatically into results/:
-training_curves.png
-classification_report.txt
-metrics_test.csv
-confusion_matrix.png

About

Image classifier for cats vs dogs using MobileNetV2 and TensorFlow/Keras

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages