Precision Livestock Farming: YOLOv12-Based Automated Detection of Keel Bone Lesions in Laying Hens
Abstract
1. Introduction
2. Materials and Methods
2.1. Data Collection and Annotation Protocol
2.1.1. Preliminary Phase
2.1.2. Revised Annotation Criteria
2.2. Dataset Preparation
2.2.1. Postprocessing: NC Class Removal
2.2.2. Data Augmentation Strategy
- Original frames were augmented by a factor of 3;
- Class 0 specimens were augmented by a factor of 3;
- Class 1 specimens were augmented by a factor of 9.
2.3. Model Architecture and Training
2.4. Tracking Implementation
- Watch the entire five-minute video (without predictions to avoid any bias) and count the occurrences of class 0 and class 1.
- Watch the entire five-minute video (with predictions) and verify the agreement between their own predictions and the predictions of the tracker.
- Individual classification section: for each detected ID, the class label was extracted, along with the mean class prediction across all frames in which the ID was detected, the mean confidence of the predictions and its standard deviation, and the total number of frames in which the ID was detected;
- Final statistics section: the total number of detected specimens was obtained, together with the class distribution of the detected specimens (determined as the mode of the class predictions across all frames) and a modified class distribution excluding “uncertain” predictions. Specifically, predictions for which the mean class prediction () fell within the range were considered uncertain. This threshold was selected a posteriori to match the uncertainty rate reported by the human annotator, who, during the validation phase, indicated the proportion of “borderline” sterna.
2.5. Evaluation Metrics
- Absolute and normalized confusion matrices;
- F1 score for each class;
- Precision–recall curves for each class;
- Mean average precision at IoU threshold 0.5 (mAP@50), which was deemed sufficient since the primary focus was on classification accuracy rather than precise localization [19].
- Number of stable IDs: the number of IDs that were consistently tracked across multiple frames, as described in Section 2.4;
- Confusion matrices obtained comparing the tracker predictions with the human annotations, using the latter as ground truth and filtering out uncertain predictions as defined in Section 2.4;
- F1 scores for each class and overall F1 score by considering the human annotator as the ground truth (GT).
3. Results
3.1. Inter-Annotator Agreement
3.2. YOLO Model Detection and Classification Performance
3.3. Tracking Performance
3.3.1. BoTSORT Tracking Performance
- Class 0: 207 specimens (77.8%);
- Class 1: 59 specimens (22.2%);
- Total number of detections: 266.
3.3.2. Comparison with Manual Tracking and Postprocessing Adjustment
4. Discussion
5. Conclusions
Author Contributions
Funding
Institutional Review Board Statement
Informed Consent Statement
Data Availability Statement
Acknowledgments
Conflicts of Interest
Appendix A. Inter-Annotator Agreement Results for the Preliminary Phase


References
- Kollenda, E.; Baldock, D.; Hiller, N.; Lorant, A. Transitioning towards Cage-Free Farming in the EU: Assessment of Environmental and Socio-Economic Impacts of Increased Animal Welfare Standards; Institute for European Environmental Policy (IEEP): Brussels, Belgium, 2020. [Google Scholar]
- Welfare Quality®. Welfare Quality® Assessment Protocol for Poultry (Broilers, Laying Hens); Welfare Quality® Consortium: Lelystad, The Netherlands, 2009. [Google Scholar]
- Directive—2007/43—EN—EUR-Lex. Available online: https://eur-lex.europa.eu/eli/dir/2007/43/oj/eng (accessed on 17 September 2025).
- EURCAW-Poultry-SFA. Indicators at Slaughter to Assess Broiler Welfare on Farm; EURCAW-Poultry-SFA: Maisons-Alfort, France, 2023. [Google Scholar]
- EFSA Panel on Animal Health and Animal Welfare (AHAW); Nielsen, S.S.; Alvarez, J.; Bicout, D.J.; Calistri, P.; Canali, E.; Drewe, J.A.; Garin-Bastuji, B.; Gonzales Rojas, J.L.; Gortázar Schmidt, C.; et al. Welfare of Laying Hens on Farm. EFSA J. 2023, 21, e07789. [Google Scholar] [CrossRef]
- Petrik, M.T.; Guerin, M.T.; Widowski, T.M. On-Farm Comparison of Keel Fracture Prevalence and Other Welfare Indicators in Conventional Cage and Floor-Housed Laying Hens in Ontario, Canada. Poult. Sci. 2015, 94, 579–585. [Google Scholar] [CrossRef] [PubMed]
- Rufener, C.; Makagon, M.M. Keel Bone Fractures in Laying Hens: A Systematic Review of Prevalence across Age, Housing Systems, and Strains. J. Anim. Sci. 2020, 98, S36–S51. [Google Scholar] [CrossRef] [PubMed]
- Toscano, M.J.; Dunn, I.C.; Christensen, J.P.; Petow, S.; Kittelsen, K.; Ulrich, R. Explanations for Keel Bone Fractures in Laying Hens: Are There Explanations in Addition to Elevated Egg Production? Poult. Sci. 2020, 99, 4183–4194. [Google Scholar] [CrossRef] [PubMed]
- Blatchford, R.A.; Fulton, R.M.; Mench, J.A. The Utilization of the Welfare Quality® Assessment for Determining Laying Hen Condition across Three Housing Systems. Poult. Sci. 2016, 95, 154–163. [Google Scholar] [CrossRef] [PubMed]
- Wilkins, L.J.; McKinstry, J.L.; Avery, N.C.; Knowles, T.G.; Brown, S.N.; Tarlton, J.; Nicol, C.J. Influence of Housing System and Design on Bone Strength and Keel Bone Fractures in Laying Hens. Vet. Rec. 2011, 169, 414. [Google Scholar] [CrossRef] [PubMed]
- Nalesso, G.; Ciarelli, C.; Menegon, F.; Bordignon, F.; Urbani, R.; Di Martino, G.; Polo, P.; Sparesato, S.; Xiccato, G.; Trocino, A. On-Farm Welfare of Laying Hens: Animal-Based Measures at Slaughterhouse and Risk Factors in Italian Farms. Poult. Sci. 2025, 104, 105152. [Google Scholar] [CrossRef] [PubMed]
- Çavuşoğlu, E.; Toscano, M.J.; Gebhardt-Henrich, S.G. Reliability of Palpation Using Three-Dimensional Keel Bone Models. J. Appl. Poult. Res. 2025, 34, 100579. [Google Scholar] [CrossRef]
- Vanderhasselt, R.F.; Sprenger, M.; Duchateau, L.; Tuyttens, F.A.M. Automated Assessment of Footpad Dermatitis in Broiler Chickens at the Slaughter-Line: Evaluation and Correspondence with Human Expert Scores. Poult. Sci. 2013, 92, 12–18. [Google Scholar] [CrossRef] [PubMed]
- Sozzi, M.; Pillan, G.; Ciarelli, C.; Marinello, F.; Pirrone, F.; Bordignon, F.; Bordignon, A.; Xiccato, G.; Trocino, A. Measuring Comfort Behaviours in Laying Hens Using Deep-Learning Tools. Animals 2023, 13, 33. [Google Scholar] [CrossRef]
- Dwyer, B.; Nelson, J.; Hansen, T. Roboflow. Available online: https://roboflow.com/ (accessed on 17 September 2025).
- Buslaev, A.; Iglovikov, V.I.; Khvedchenya, E.; Parinov, A.; Druzhinin, M.; Kalinin, A.A. Albumentations: Fast and Flexible Image Augmentations. Inf.-Int. Interdiscip. J. 2020, 11, 125. [Google Scholar] [CrossRef]
- Tian, Y.; Ye, Q.; Doermann, D. YOLOv12: Attention-Centric Real-Time Object Detectors. arXiv 2025, arXiv:2502.12524. [Google Scholar] [CrossRef]
- Aharon, N.; Orfaig, R.; Bobrovsky, B.Z. BoT-SORT: Robust Associations Multi-Pedestrian Tracking. arXiv 2022, arXiv:2206.14651. [Google Scholar] [CrossRef]
- Saito, T.; Rehmsmeier, M. The Precision-Recall Plot Is More Informative than the ROC Plot When Evaluating Binary Classifiers on Imbalanced Datasets. PLoS ONE 2015, 10, e0118432. [Google Scholar] [CrossRef] [PubMed]
- Landis, J.R.; Koch, G.G. The Measurement of Observer Agreement for Categorical Data. Biometrics 1977, 33, 159–174. [Google Scholar] [CrossRef] [PubMed]
- Marzi, G.; Balzano, M.; Marchiori, D. K-Alpha Calculator–Krippendorff’s Alpha Calculator: A User-Friendly Tool for Computing Krippendorff’s Alpha Inter-Rater Reliability Coefficient. MethodsX 2024, 12, 102545. [Google Scholar] [CrossRef] [PubMed]
- Marino, R.; Petrera, F.; Abeni, F. Scientific Productions on Precision Livestock Farming: An Overview of the Evolution and Current State of Research Based on a Bibliometric Analysis. Animals 2023, 13, 2280. [Google Scholar] [CrossRef] [PubMed]
- Ben Sassi, N.; Averós, X.; Estevez, I. Technology and Poultry Welfare. Animals 2016, 6, 62. [Google Scholar] [CrossRef] [PubMed]
- Caldas-Cueva, J.P.; Mauromoustakos, A.; Sun, X.; Owens, C.M. Detection of Woody Breast Condition in Commercial Broiler Carcasses Using Image Analysis. Poult. Sci. 2021, 100, 100977. [Google Scholar] [CrossRef] [PubMed]
- Jung, L.; Nasirahmadi, A.; Schulte-Landwehr, J.; Knierim, U. Automatic Assessment of Keel Bone Damage in Laying Hens at the Slaughter Line. Animals 2021, 11, 163. [Google Scholar] [CrossRef] [PubMed]
- Welfare of Laying Hens on Farm—2023—EFSA Journal—Wiley Online Library. Available online: https://efsa.onlinelibrary.wiley.com/doi/full/10.2903/j.efsa.2023.7789 (accessed on 17 September 2025).







| Transformation | Albumentations Functions |
|---|---|
| RandomResizedCrop | A.RandomResizedCrop() |
| HorizontalFlip | A.HorizontalFlip() |
| VerticalFlip | A.VerticalFlip() |
| RandomBrightnessContrast | A.RandomBrightnessContrast() |
| ColorJitter | A.ColorJitter() |
| GaussianBlur | A.GaussianBlur() |
| MotionBlur | A.MotionBlur() |
| ElasticTransform | A.ElasticTransform() |
| GridDistortion | A.GridDistortion() |
| CoarseDropout | A.CoarseDropout() |
| ShiftScaleRotate | A.ShiftScaleRotate() |
| Rotate | A.Rotate() |
| HueSaturationValue | A.HueSaturationValue() |
| Blur | A.Blur() |
| GaussNoise (Noise) | A.GaussNoise() |
| Parameter | Value |
|---|---|
| Model architecture | YOLOv12 |
| Pretrained weights | True |
| Input image size | 640 |
| Batch size | 0.8 (auto) |
| Epochs | 250 |
| Patience (early stopping) | 100 |
| Mosaic augmentation | 0.5 |
| IoU threshold (NMS) | 0.7 |
| Parameter | Value |
|---|---|
| Tracker type | botsort |
| Track high threshold | 0.25 |
| Track low threshold | 0.1 |
| New track threshold | 0.7 |
| Track buffer | 120 |
| Match threshold | 0.8 |
| Fuse score | True |
| GMC method | none |
| Proximity threshold (ReID) | 0.5 |
| Appearance threshold (ReID) | 0.5 |
| With ReID | True |
| ReID model | auto |
| G (GT) | R (GT) | F (GT) | |
|---|---|---|---|
| G | – | 0.809 | 0.816 |
| R | 0.809 | – | 0.822 |
| F | 0.816 | 0.822 | – |
| Class 0 | Class 1 | Uncertain | Total | |
|---|---|---|---|---|
| Operator (ground truth) | 196 (78.1%) | 47 (18.7%) | 8 (3.2%) | 251 |
| Tracker (including uncertain predictions) | 203 (76.3%) | 53 (19.9%) | 10 (3.8%) | 266 |
| F1 score | 0.955 | 0.809 | – | 0.882 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Bergamasco, T.; Ambrosi, A.; Tregnaghi, V.; Urbani, R.; Nalesso, G.; Menegon, F.; Trocino, A.; Pravato, M.; Bordignon, F.; Sparesato, S.; et al. Precision Livestock Farming: YOLOv12-Based Automated Detection of Keel Bone Lesions in Laying Hens. Poultry 2025, 4, 43. https://doi.org/10.3390/poultry4040043
Bergamasco T, Ambrosi A, Tregnaghi V, Urbani R, Nalesso G, Menegon F, Trocino A, Pravato M, Bordignon F, Sparesato S, et al. Precision Livestock Farming: YOLOv12-Based Automated Detection of Keel Bone Lesions in Laying Hens. Poultry. 2025; 4(4):43. https://doi.org/10.3390/poultry4040043
Chicago/Turabian StyleBergamasco, Tommaso, Aurora Ambrosi, Vittoria Tregnaghi, Rachele Urbani, Giacomo Nalesso, Francesca Menegon, Angela Trocino, Mattia Pravato, Francesco Bordignon, Stefania Sparesato, and et al. 2025. "Precision Livestock Farming: YOLOv12-Based Automated Detection of Keel Bone Lesions in Laying Hens" Poultry 4, no. 4: 43. https://doi.org/10.3390/poultry4040043
APA StyleBergamasco, T., Ambrosi, A., Tregnaghi, V., Urbani, R., Nalesso, G., Menegon, F., Trocino, A., Pravato, M., Bordignon, F., Sparesato, S., Manca, G., & Di Martino, G. (2025). Precision Livestock Farming: YOLOv12-Based Automated Detection of Keel Bone Lesions in Laying Hens. Poultry, 4(4), 43. https://doi.org/10.3390/poultry4040043

