Skip to content

Cattle & Buffalo Breed Classifier

A lightweight, mobile-deployable image classifier for 50 Indian cattle breeds and 18 Indian buffalo breeds. Built on EfficientNet-Lite with CBAM/SE attention and a 3-head multi-task training pipeline, with a React web app, a Flask API and an on-device OOD safety layer.

Field Value
Breeds 50 cattle + 18 buffalo = 68 total
Backbone EfficientNet-Lite2 (~6M params) or Lite4 (~13M params)
Input 260 × 260 RGB
Training 2-phase: head warm-up → multi-task fine-tune (+ EMA, optional teacher distillation; QAT opt-in)
Export TFLite INT8, ONNX Runtime INT8, ONNX, FP16, Portable bundle
Dataset Kaggle: algsoch/breed-cattle-buffalo
Web app React 18 + Vite (breed-classifier-react/) — zero-crop 260×260 capture, advanced optimizer panel, herd session, bilingual EN/தமிழ்
Serving Flask REST API + Socket.IO (server/), standalone tester (test_model.py)
Safety Post-hoc energy/MSP OOD detector with per-model calibration (including manual folder recalibration)

Quick Start

git clone https://github.com/Bharaths31/ML-CB-B-identifier
cd ML-CB-B-identifier

# Fastest local run (25% data, ~4× speedup)
python local_train.py --quarter-data

# Test the trained model visually
python test_model.py

Documentation

Page Description
Installation Step-by-step setup for Windows and Linux/macOS
Local Training (Automated) local_train.py — full flag reference
Training Pipeline 2-phase training, distillation, data modes, CUDA optimizations
Model Tester GUI test_model.py — visual testing tool
Post-hoc Attributes Gender, age group & morphological traits with no retraining (CLIP + heuristic)
Breed Knowledge & Farmer Advisory Offline ICAR/NBAGR knowledge base, gender/age-specific advisory, REST endpoints
Image Quality & OOD Explainer Pre-inference blur/exposure/framing gate with trilingual farmer tips
Verification & Validation tests/run_vv_suite.py — architecture, Big-4, OOD, knowledge, i18n, themes, latency
Veterinary Portal Standalone expert review app on port 5174
Web Application React app — capture, framing, optimizer, sessions, dev control plane
Architecture Model architecture and data flow
Data Pipeline Dataset layout, augmentation, splits
Export & Deployment TFLite INT8, ONNX INT8, Android deployment
Self-Describing Models Zero external JSON: embedded class maps, preprocessing and OOD thresholds
4-Layer Input Guardrails Offline photorealism, human/selfie, feature-entropy and OOD gates with trilingual rejection copy
Google Colab Training T4 GPU notebook setup
API Reference Complete flag reference for all CLI tools
Configuration src/config.py constants
Constraints & Gotchas Known issues and platform-specific notes
Changelog Version history

A full technical report (architecture, implementation and the complete inventory of non-ML product features) lives in REPORTS.md at the repository root.