DEVELOPMENT OF A PYTHON PROGRAM FOR DETECTING MISSING EGGS IN FARM EGG TRAYS
Abstract
The global poultry industry is a cornerstone of food security and economic activity, with egg production representing one of its most labour-intensive components. A critical but frequently overlooked stage in the egg production chain is the inspection of egg trays to verify that all slots are occupied prior to packaging and dispatch. This process is currently carried out manually on most farms, making it inherently slow, inconsistent, and prone to human error — particularly at high production volumes. This project addressed this operational inefficiency by developing an automated, computer vision-based solution using the YOLOv8 deep learning framework. The primary objective was to design, implement, and evaluate a robust Python program capable of accurately detecting missing eggs in digital images of farm egg trays. The methodology employed a transfer learning approach, fine-tuning pre-trained YOLOv8 models on a custom dataset of 117 annotated egg tray images collected under real farm conditions. The dataset was annotated with two classes — egg and no_egg — and expanded to over 2,000 images through systematic data augmentation techniques including horizontal flipping, random rotation, and HSV colour adjustments. Three models were trained and evaluated iteratively: a baseline YOLOv8 nano model on the original dataset, a YOLOv8 nano model on the expanded 2,093-image dataset, and a YOLOv8 small model with optimised class loss weighting. The best-performing model achieved a precision of 48.1%, a recall of 90.2%, and a mean Average Precision at IoU threshold 0.50 (mAP@50) of 62.2%. The most significant finding was the dramatic improvement in no_egg class detection accuracy from 24.6% in the baseline model to 93.6% following dataset expansion, confirming that the system reliably detects missing egg slots. The trained model was deployed as a publicly accessible web application using the Gradio framework, enabling real-time tray inspection via smartphone camera without the need for any specialised hardware. In conclusion, this project successfully developed a functional, cost-effective prototype that demonstrates the viability of YOLOv8-based automation in poultry farm quality control. The system offers a tangible contribution to precision livestock farming, with clear potential to enhance operational efficiency and reduce economic losses from undetected missing eggs.
Keywords: YOLOv8, Object Detection, Missing Egg Detection, Computer Vision, Deep Learning, Poultry Farming, Data Augmentation, Transfer Learning, Gradio, Precision Livestock Farming.
Full-Text Access Notice
In accordance with the NERD Policy on promoting peer-reviewed publication, public access to the full text of a project, thesis or dissertation is restricted for three years, allowing the author and supervisors sufficient time to pursue peer-reviewed publication.
During this period, researchers with legitimate academic or research purposes may request authorisation directly from the author to enable NERD to release the indexed full texts of the work using the form below.