An end-to-end, edge-optimized computer vision pipeline designed to track and classify cattle behavior in real-time from farm surveillance feeds.
Instead of relying on a single heavy network, BoviTrack uses a decoupled dual-stage architecture to maintain high throughput and lightweight memory overhead suitable for edge deployment:
- Target Localization & Tracking: A lightweight YOLO model detects cattle in the frame, paired with ByteTrack to maintain persistent IDs across frames despite occlusions and low-light transitions.
- Behavior Classification: High-confidence detections are cropped and dynamically routed to a specialized YOLO classification head to identify target behaviors (
eat,drink,stand,lie,ruminate).
- Dataset Source: Beef Cattle Behavior Dataset (Kaggle)
- Training Pipeline: All data auditing, video frame extraction (with strict video-level splits to eliminate data leakage), and model training were conducted on Kaggle using NVIDIA T4 GPU acceleration.
- Pretrained Weights: Both optimized Nano-scale models are pre-packaged in the
final_models/directory for plug-and-play inference.
BoviTrack-RealTime-Behavior-Tracking/
├── data/
│ └── bovine_data.yaml # Dataset configuration
├── final_models/
│ ├── detector_best.pt # Trained YOLO cattle detector
│ └── classifier_best.pt # Trained YOLO behavior classifier
├── notebooks/
│ └── notebook58828f625d.ipynb # Kaggle training & validation pipeline
├── scripts/
│ └── main.py # Real-time inference & video processing script
├── videos/ # Directory for input and output videos
└── README.md
git clone [https://github.com/Faissal-00/BoviTrack-RealTime-Behavior-Tracking.git](https://github.com/Faissal-00/BoviTrack-RealTime-Behavior-Tracking.git)
cd BoviTrack-RealTime-Behavior-Trackingpip install ultralytics opencv-python numpyCreate a videos directory in the project root if it does not already exist, and place your target .mp4 video files inside it:
mkdir -p videos
# Copy your test video (e.g., day_video.mp4 / night_video.mp4) into the videos/ folderExecute the main deployment script:
python scripts/main.pyThe script will automatically load the models from final_models/, process your video frame-by-frame with active ByteTrack ID persistence and behavior overlay badges, and export the final annotated video directly into the videos/ folder.