AI-Powered Animal Type Classification for Precision Dairy Farming
AgriNN is an AI-powered livestock classification system that uses computer vision to analyze images of cattle and buffaloes. It extracts body structure features such as body length, height, and key proportions, then generates standardized classification scores to support Animal Type Classification (ATC).
Repository: https://github.com/adityai0/AgriNN
Manual livestock type assessment is time-consuming, subjective, and prone to human bias, which can reduce consistency and accuracy in dairy farming and breeding decisions.
AgriNN automates ATC using an end-to-end AI pipeline. Users upload animal images, the system detects whether the subject is cattle or buffalo, extracts structural body features, computes standardized scores, and presents results with visual overlays. Historical records are stored for review and long-term analysis.
- Upload animal images from a web interface
- Detect cattle or buffalo using AI-based object detection
- Extract body structure features (length, height, proportions)
- Generate standardized classification scores
- Display results with visual overlays for interpretability
- Store and retrieve historical analysis records
- Frontend: Next.js, Tailwind CSS
- Backend: FastAPI (Python)
- AI/ML: PyTorch, YOLOv8, OpenCV
- Database: PostgreSQL
[User]
|
v
[Next.js + Tailwind Frontend]
|
| HTTP/REST
v
[FastAPI Backend]
| \
| \--> [PostgreSQL: records, metadata, scores]
v
[Inference Pipeline: YOLOv8 + OpenCV + PyTorch]
|
v
[Feature Extraction + ATC Scoring Engine]
|
v
[API Response: class, measurements, score, overlays]
- Node.js 18+
- Python 3.10+
- PostgreSQL (local or cloud)
- Git
git clone https://github.com/adityai0/AgriNN.git
cd AgriNN# from project root
cd backend
python -m venv .venv
# Windows
.venv\Scripts\activate
# Linux/macOS
source .venv/bin/activate
pip install -r requirements.txtCreate a .env file in backend/ with values similar to:
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/agrinn
MODEL_PATH=./models/yolov8.ptStart backend:
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000# from project root
cd frontend
npm installCreate a .env.local file in frontend/:
NEXT_PUBLIC_API_BASE_URL=http://localhost:8000Start frontend:
npm run devFrontend runs at http://localhost:3000.
- Open the frontend in your browser.
- Upload an image of cattle or buffalo.
- Submit for analysis.
- Review detected animal type, extracted measurements, and classification score.
- Inspect visual overlays and save/revisit historical records.
- Multi-animal image handling and tracking
- Mobile-first capture flow for on-farm use
- Explainable AI dashboard with confidence decomposition
- Breed-specific calibration of scoring rules
- Role-based access and audit logging
- Model monitoring and auto-retraining workflows
Contributions are welcome. Please read CONTRIBUTING.md for setup, coding standards, and pull request guidelines.
This project is licensed under the MIT License. See LICENSE for details.