Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cattle Detection — Cow vs Buffalo 🐄🐃

Object detection model that distinguishes between cows and buffalos using Faster R-CNN (ResNet50-FPN V2) with PyTorch Lightning.

One of the learning tasks from my AI Lead as part of transitioning from QA to AI

Overview

This project trains a Faster R-CNN model to detect and classify cattle in images into two categories:

  • Cow
  • Buffalo

The model uses transfer learning from COCO-pretrained weights and is fine-tuned on a cattle-specific dataset.

Architecture

Component Details
Backbone ResNet50-FPN V2 (pretrained on COCO)
Detection Head FastRCNNPredictor (3 classes: background, cow, buffalo)
Framework PyTorch Lightning
Optimizer AdamW (lr=1e-4, weight_decay=1e-4)
Scheduler ReduceLROnPlateau (patience=3)
Precision Mixed FP16 (on GPU)

Dataset

Uses the Cows and Buffalo Computer Vision Dataset from Kaggle with YOLO-format annotations.

  • Split: 70% train / 15% val / 15% test
  • Augmentation: 2x training set via albumentations (flips, color jitter, blur, noise, rotation, etc.)
  • Image size: 512×512

Training Configuration

  • Platform: Kaggle — NVIDIA T4 16GB GPU
  • Batch size: 4 (with gradient accumulation x2 -> effective BS of 8)
  • Max epochs: 30
  • Early stopping: patience 7
  • Checkpointing: top-3 models by val_loss

Evaluation Metrics

The model is evaluated using:

  • COCO-style mAP (IoU=0.50:0.95, IoU=0.50, IoU=0.75)
  • Per-class mAP (cow, buffalo)
  • Classification metrics at IoU≥0.5: Precision, Recall, F1 (macro & weighted)
  • Confusion matrix

Requirements

some bullshit

Quick Start

install requirements.txt duh...

Then open cattle_det/cattle-detection.ipynb and run the cells sequentially. The model was trained on Kaggle GPU T4x2 GPU

About

Simple OD for Cow/Buffalo with PyTorch Lightning

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages