Skip to content

Repository files navigation

README.md

PGH — Automated Chicken Feeding Count

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.


Overview

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:

  1. Feeder segmentation — locate the feeder regions in each frame
  2. Head detection — count chicken heads inside those feeder regions

Pipeline

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

Notebooks

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

Dataset

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)

Results

Feeder Segmentation (YOLOv8n-seg)

Metric Score
mAP50 (box) 0.9950
mAP50 (mask) 0.9950
Precision 0.9955
Recall 1.0000

Head Detection (YOLOv8s)

Metric Score
mAP50 0.9950
mAP50-95 0.5355
Precision 1.0000
Recall 0.9357

Full Pipeline Output (223 frames)

Stat Value
Average heads per frame 0.37
Max heads in one frame 3
Frames with 0 heads 154

Requirements

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

How to Run

  1. Upload PGH.zip (feeder dataset), PGH_head_labelled.zip (head dataset), and PoultryImage.zip (video frames) to your Google Drive root
  2. Run notebooks in order: 01020304
  3. Each notebook saves outputs (model weights, crops, CSV, graph) directly to Google Drive
  4. Final outputs: PGH_head_counts.csv and PGH_feeding_graph.png

Project Structure

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

Author

Anas Bin Harun
Texas A&M University

About

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.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages