Skip to content

Ubada12/Deonar-AI

Repository files navigation

DEONAR AI

Real-Time Livestock Detection, Tracking & Counting Platform

Built for Deonar Abattoir, Mumbai


Overview

DEONAR AI is a production-grade livestock counting platform developed to automate animal counting operations at Deonar Abattoir, Mumbai.

The platform combines computer vision, object tracking, counting intelligence, vendor session management, and real-time streaming to replace manual counting processes with an accurate, auditable, and scalable AI solution.

Key Highlights

  • Real-time livestock counting from CCTV feeds
  • YOLOv11 & YOLOv12 object detection
  • ByteTrack & BoT-SORT multi-object tracking
  • Dual-line counting intelligence
  • Vendor slot management system
  • Browser-based WebRTC live monitoring
  • Multi-threaded processing pipeline
  • CSV audit trail and reporting
  • Production-ready deployment architecture

System Overview

End-to-end overview of the Deonar AI livestock counting platform.


Demo

Real-Time Livestock Detection, Tracking and Counting

Click the preview above to watch the complete end-to-end system demonstration.

What the Demo Covers

  • Live CCTV ingestion

  • Real-time goat detection

  • Multi-object tracking

  • Dual-line counting intelligence

  • Vendor session management

  • Browser-based monitoring

  • Audit reporting and analytics

Annotated Output

The annotated output video showcases:

  • YOLO detections

  • Tracking IDs

  • Counting line interactions

  • Live count updates

  • Real-time visual overlays


User Interface

Live Monitoring Dashboard

Slot Management Console

Monitor live counting sessions, track vendor operations, and access audit-ready reports through a centralized interface.

Documentation

For readers interested in the technical implementation details, counting algorithms, deployment architecture, project journey, and system design decisions, see:


Complete System Architecture

Complete architecture showing video ingestion, AI processing, counting intelligence, vendor management, and reporting.

Core Workflow

CCTV Feed / Video
          ↓
YOLO Detection
          ↓
Multi-Object Tracking
          ↓
Counting Intelligence
          ↓
Vendor Slot Mapping
          ↓
Reports & Audit Trail

Counting Intelligence Engine

Motion-aware counting engine designed to ensure every animal is counted exactly once.

The counting engine combines:

  • Object Detection
  • Multi-Object Tracking
  • Motion Validation
  • Direction Analysis
  • Count Confirmation Logic
  • Dual-Line Verification

Supported Counting Modes

1) Single-Line Counting

Counts animals crossing a single virtual counting line with anti-flicker validation and cooldown protection.

2) Dual-Line Counting (Recommended)

Uses Line A → Line B verification combined with motion validation and direction consistency checks to maximize counting accuracy.

3) Zone Counting

Counts entries and exits within a configurable region of interest, suitable for pen monitoring and wider gate scenarios.


Deployment Architecture

Production deployment architecture supporting local and remote monitoring.

Live Streaming

  • The platform streams annotated video through WebRTC and can be deployed on a remote server for browser-based monitoring.

  • Operators can securely monitor live counting sessions from anywhere without requiring direct access to the processing machine.


Technology Stack

➤ AI & Deep Learning

  • PyTorch
  • Ultralytics
  • YOLOv11
  • YOLOv12

➤ Tracking

  • ByteTrack
  • BoT-SORT

➤ Computer Vision

  • OpenCV
  • NumPy

➤ Live Streaming

  • WebRTC
  • aiortc
  • aiohttp

➤ Backend & APIs

  • FastAPI
  • Uvicorn
  • Pydantic

➤ Monitoring & Logging

  • Rich
  • JSONL Logging
  • CSV Reporting

➤ Infrastructure & Training

  • CVAT
  • Vast.ai (RTX 5090)
  • HuggingFace Hub
  • Tailscale

Pre-Trained Models

Models were trained on a custom dataset of more than 20,000 annotated livestock images collected under real operational conditions at Deonar Abattoir.

Model mAP@50 mAP@50-95 Size
YOLOv11 Nano 98.99% 78.05% ~5.4 MB
YOLOv11 Small 99.05% 79.00% ~19 MB
YOLOv12 Nano 99.04% 78.12% ~5.4 MB
YOLOv12 Small 99.09% 79.43% ~19 MB

Download Models

Models are hosted on HuggingFace:

https://huggingface.co/ubada11/goat-detection-yolov11

Download the preferred model and place it inside:

models/

before starting the application.


Dataset & Training

Metric Value
Dataset Size 20,000+ Images
Annotation Platform CVAT
Training Infrastructure Vast.ai RTX 5090
Detection Models YOLOv11 & YOLOv12
Validation Accuracy ~99% mAP@50

The dataset was collected and annotated directly from operational livestock counting environments under varying camera angles, lighting conditions, densities, and weather conditions.

Dataset Access

The dataset used for training was collected from real-world livestock counting environments and is not publicly distributed.

For academic, research, or industry collaboration inquiries regarding dataset availability, please contact:

Ubada Ghawte 📧 ubadaghawte2005@gmail.com


Results

Metric Performance
Detection Accuracy ~99% mAP@50
Miss Rate < 5%
Processing Mode Real-Time
Tracking ByteTrack / BoT-SORT
Streaming WebRTC
Reporting CSV + Video + Audit Logs

Real-World Deployment

The platform was designed and tested for livestock counting operations at Deonar Abattoir, Mumbai.

Supported capabilities include:

  • Automated livestock counting
  • Vendor session management
  • Browser-based live monitoring
  • Remote deployment support
  • Audit-ready reporting
  • Operational analytics

Project Structure

├── assets/                # Project media and documentation assets 
│   ├── architecture/      # System architecture diagrams and workflow visuals 
│   ├── screenshots/       # Application UI screenshots 
│   ├── demo/              # Demo videos and recordings
│ 
├── configs/               # Configuration files (models, streams, counting settings) 
├── models/                # Downloaded and trained AI model weights 
├── outputs/               # Generated reports, logs, videos, and run artifacts 
├── src/                   # Core application source code 
│   ├── capture/           # Video capture and stream ingestion modules
│   ├── infer/             # YOLO inference and detection pipeline 
│   ├── counting/          # Counting logic and event processing 
│   ├── display/           # Visualization, overlays, and UI rendering 
│   ├── slots/             # Vendor slot/session management system 
│   ├── geometry/          # Lines, zones, ROIs, and spatial calculations 
│   ├── runtime/           # Runtime orchestration and application services 
│   └── utils/             # Shared helper functions and utilities 
│
├── main.py                # Application entry point 
├── pyproject.toml         # Project metadata and build configuration 
├── requirements.txt       # Python dependency list 
└── README.md              # Project documentation

Installation

Requirements

  • Python 3.10+ (enforced by the installer; earlier versions are rejected)
  • NVIDIA GPU with CUDA recommended for real-time inference
  • See requirements.txt for full dependency list

Recommended Setup

git clone https://github.com/Ubada12/Deonar-AI.git

cd Deonar-AI

python -m venv .venv

# Windows
.venv\Scripts\activate

# Linux / macOS
source .venv/bin/activate

pip install -e .

Enhanced Installer

pip install -e . registers a setup-installer command that does more than plain pip install -r requirements.txt. It:

  • Detects your GPU/driver via nvidia-smi and picks a matching PyTorch (CUDA) build automatically
  • Detects whether your machine has a display (headless server vs desktop) and installs the correct OpenCV variant — opencv-python (GUI) or opencv-python-headless — without letting the two fight over the cv2 module
  • Checks ffmpeg availability on PATH (Windows/macOS/Linux)
  • Skips anything that's already correctly installed, and retries failed installs
  • Writes an install log + metrics JSON to ./logs/

Requires Python 3.10+.

Quick start (recommended — one command does everything)

setup-installer \
  --auto-detect-torch \
  --force-reinstall \
  --install-cuda-python \
  --install-nvidia-ml \
  --retries 3 \
  --run-after python main.py --source rtsp://your-stream-url

This will: detect your CUDA version → install/repair the matching PyTorch trio → install cuda-python + nvidia-ml-py for GPU monitoring → install/repair OpenCV for your machine → install all remaining project dependencies → and, only if everything succeeded, immediately launch main.py with your stream.

Preview only (no changes made)

setup-installer --auto-detect-torch --force-reinstall --dry-run

Other useful flags

Flag What it does
--auto-detect-torch Detects CUDA and installs a matching PyTorch build (or CPU build if no GPU)
--force-reinstall Uninstalls and reinstalls torch/torchvision/torchaudio if mismatched or broken
--torch-version X --torchvision-version Y --torchaudio-version Z --cuda-tag cuXXX Pin exact versions instead of auto-detecting
--install-cuda-python Installs cuda-python bindings
--install-nvidia-ml Installs nvidia-ml-py (GPU monitoring)
--no-deps Pass --no-deps to all pip installs
--retries N Retry failed installs (default 3)
--run-after <cmd...> Run a command (e.g. python main.py --source ...) after a successful install
--dry-run Show the planned install queue without installing anything
--verbose / --always-progress Show raw pip output

⚠️ Warning

  • Before running the application, download the required detection model from the HuggingFace repository and place the model file inside the models/ directory. The application does not automatically download model weights, so this step is required for successful inference.

  • Ensure that the model path specified in configs/config.yaml matches the model file you placed in the models/ directory. Incorrect paths or model names will prevent the application from starting correctly.

  • The default config.yaml is configured for beginners and is suitable for getting started quickly with the project. However, if you plan to use Deonar AI for a different deployment environment, camera setup, counting scenario, custom model, RTSP stream, or any other use case, you should review and update the configuration values according to your requirements.

  • Always verify settings such as model paths, video sources, counting lines, tracking parameters, output locations, and streaming options in configs/config.yaml before deployment to ensure the system behaves as expected in your environment.


Quick Start

Configure your model and video source in:

configs/config.yaml

Run:

python main.py

The application supports:

  • RTSP streams
  • CCTV cameras
  • Local video files

Generated Outputs

Every run generates structured outputs including:

  • Event Logs
  • Count Time Series
  • Decision Traces
  • Performance Metrics
  • Annotated Videos
  • Vendor Session Reports
  • Summary Reports

Output structure:

outputs/runs/<run_id>/

Contributors

🧑‍💼 Project Lead

Ubada Ghawte
Lead ML Developer & Full Stack Developer
👥 Team Members

➤ Adil
➤ Raafe
🎓 Academic Guide

Prof. Farhan
Rizvi College of Engineering
🏭 Industry Partner

MI Tradings &
General Suppliers

License

Licensed under the Apache License 2.0.

See the LICENSE file for details.

About

Real-time livestock detection & counting using YOLOv11 + ByteTrack on live CCTV. Built for Deonar abattoir, dual-line counting, slot management API, WebRTC live preview.

Topics

Resources

License

Stars

3 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors