Automated two-stage computer vision pipeline using YOLOv8 to count chicken heads at feeders from night-vision camera frames as a behavioural indicator of gut health in broiler chickens.
This project processes continuous IR camera footage from a broiler chicken farm to automatically count how many chickens are feeding at any given time. Feeding frequency is used as a non-invasive behavioural proxy for early gut health monitoring.
The pipeline runs in two stages:
- Feeder segmentation — locate the feeder regions in each frame
- Head detection — count chicken heads inside those feeder regions
Raw frame (IR camera)
↓
Stage 1 — Feeder Segmentation (YOLOv8n-seg)
↓ Top 2 feeders by bounding box area
Stage 2 — Feeder ROI Crop
↓
Stage 3 — Head Detection (YOLOv8s, conf = 0.50)
↓
Output — Head count per feeder per frame → CSV + time-series graph
| Notebook | Description |
|---|---|
01_train_feeder_seg.ipynb |
Train YOLOv8n-seg on 40 labeled feeder images |
02_extract_roi_crops.ipynb |
Use feeder model to crop top 2 feeder ROIs from raw images |
03_train_head_detection.ipynb |
Train YOLOv8s on 59 labeled feeder ROI crops |
04_run_count_pipeline.ipynb |
Run full pipeline on all 223 video frames, export CSV + graph |
| Model | Images | Split | Class |
|---|---|---|---|
| Feeder segmentation | 40 | 28 train / 8 valid / 4 test | Feeder |
| Head detection | 59 (after augmentation) | 59 train / 6 valid / 3 test | Head |
- Images sourced from a top-view IR night-vision camera (grayscale/BW)
- Labeled using Roboflow
- Frames extracted from continuous video at ~5-minute intervals (223 total frames)
| Metric | Score |
|---|---|
| mAP50 (box) | 0.9950 |
| mAP50 (mask) | 0.9950 |
| Precision | 0.9955 |
| Recall | 1.0000 |
| Metric | Score |
|---|---|
| mAP50 | 0.9950 |
| mAP50-95 | 0.5355 |
| Precision | 1.0000 |
| Recall | 0.9357 |
| Stat | Value |
|---|---|
| Average heads per frame | 0.37 |
| Max heads in one frame | 3 |
| Frames with 0 heads | 154 |
All notebooks run on Google Colab (T4 GPU). No local setup needed.
ultralytics
torch
PIL
matplotlib
numpy
PyYAML
Install in Colab:
!pip install ultralytics --quiet- Upload
PGH.zip(feeder dataset),PGH_head_labelled.zip(head dataset), andPoultryImage.zip(video frames) to your Google Drive root - Run notebooks in order:
01→02→03→04 - Each notebook saves outputs (model weights, crops, CSV, graph) directly to Google Drive
- Final outputs:
PGH_head_counts.csvandPGH_feeding_graph.png
PGH-Chicken-Feeding-Count/
├── 01_train_feeder_seg.ipynb
├── 02_extract_roi_crops.ipynb
├── 03_train_head_detection.ipynb
├── 04_run_count_pipeline.ipynb
└── README.md
Anas Bin Harun
Texas A&M University