Skip to main page content
U.S. flag

An official website of the United States government

Dot gov

The .gov means it’s official.
Federal government websites often end in .gov or .mil. Before sharing sensitive information, make sure you’re on a federal government site.

Https

The site is secure.
The https:// ensures that you are connecting to the official website and that any information you provide is encrypted and transmitted securely.

Access keys NCBI Homepage MyNCBI Homepage Main Content Main Navigation
. 2024 Oct 19;14(20):3033.
doi: 10.3390/ani14203033.

CAMLLA-YOLOv8n: Cow Behavior Recognition Based on Improved YOLOv8n

Affiliations

CAMLLA-YOLOv8n: Cow Behavior Recognition Based on Improved YOLOv8n

Qingxiang Jia et al. Animals (Basel). .

Abstract

Cow behavior carries important health information. The timely and accurate detection of standing, grazing, lying, estrus, licking, fighting, and other behaviors is crucial for individual cow monitoring and understanding of their health status. In this study, a model called CAMLLA-YOLOv8n is proposed for Holstein cow behavior recognition. We use a hybrid data augmentation method to provide the model with rich Holstein cow behavior features and improve the YOLOV8n model to optimize the Holstein cow behavior detection results under challenging conditions. Specifically, we integrate the Coordinate Attention mechanism into the C2f module to form the C2f-CA module, which strengthens the expression of inter-channel feature information, enabling the model to more accurately identify and understand the spatial relationship between different Holstein cows' positions, thereby improving the sensitivity to key areas and the ability to filter background interference. Secondly, the MLLAttention mechanism is introduced in the P3, P4, and P5 layers of the Neck part of the model to better cope with the challenges of Holstein cow behavior recognition caused by large-scale changes. In addition, we also innovatively improve the SPPF module to form the SPPF-GPE module, which optimizes small target recognition by combining global average pooling and global maximum pooling processing and enhances the model's ability to capture the key parts of Holstein cow behavior in the environment. Given the limitations of traditional IoU loss in cow behavior detection, we replace CIoU loss with Shape-IoU loss, focusing on the shape and scale features of the Bounding Box, thereby improving the matching degree between the Prediction Box and the Ground Truth Box. In order to verify the effectiveness of the proposed CAMLLA-YOLOv8n algorithm, we conducted experiments on a self-constructed dataset containing 23,073 Holstein cow behavior instances. The experimental results show that, compared with models such as YOLOv3-tiny, YOLOv5n, YOLOv5s, YOLOv7-tiny, YOLOv8n, and YOLOv8s, the improved CAMLLA-YOLOv8n model achieved increases in Precision of 8.79%, 7.16%, 6.06%, 2.86%, 2.18%, and 2.69%, respectively, when detecting the states of Holstein cows grazing, standing, lying, licking, estrus, fighting, and empty bedding. Finally, although the Params and FLOPs of the CAMLLA-YOLOv8n model increased slightly compared with the YOLOv8n model, it achieved significant improvements of 2.18%, 1.62%, 1.84%, and 1.77% in the four key performance indicators of Precision, Recall, mAP@0.5, and mAP@0.5:0.95, respectively. This model, named CAMLLA-YOLOv8n, effectively meets the need for the accurate and rapid identification of Holstein cow behavior in actual agricultural environments. This research is significant for improving the economic benefits of farms and promoting the transformation of animal husbandry towards digitalization and intelligence.

Keywords: CAMLLA-YOLOv8n; Holstein cows; YOLOv8n; attention mechanism; cow behavior recognition.

PubMed Disclaimer

Conflict of interest statement

The authors declare no conflicts of interest.

Figures

Figure 1
Figure 1
Camera installation location diagram.
Figure 2
Figure 2
Example of sample images of cow behavior in the dataset.
Figure 3
Figure 3
Category distribution and annotation information of the dataset.
Figure 4
Figure 4
Sample images from the challenging dataset.
Figure 5
Figure 5
Example of augmented data.
Figure 6
Figure 6
CAMLLA-YOLOv8n cow behavior recognition network architecture diagram.
Figure 7
Figure 7
YOLOv8n overall network structure diagram.
Figure 8
Figure 8
CA attention module diagram.
Figure 9
Figure 9
Linear Attention Transformer architecture, Mamba architecture, and MLLAttention architecture.
Figure 10
Figure 10
Multi-level feature fusion and MLLAttention Mechanisms display of CAMLLA-YOLOv8n backbone network.
Figure 11
Figure 11
SPPF-GPE structure diagram.
Figure 12
Figure 12
IOU calculation formula diagram. A represents the ground truth bounding box, and B represents the predicted bounding box.
Figure 13
Figure 13
IOU comparisons for Anchor and Ground Truth Boxes. (a) Shows boxes with the same shape deviation but different scales. (b) Shows boxes with the same shape and scale, all with a shape deviation of 0.
Figure 14
Figure 14
Schematic diagram of Ground Truth Box and Anchor Box.
Figure 15
Figure 15
Comprehensive performance comparison of seven YOLO detection algorithms.
Figure 16
Figure 16
Comparative analysis of Precision, Recall, and Mean Average Precision across seven YOLO detection algorithms.
Figure 17
Figure 17
Training and validation loss profiles across seven YOLO detection algorithms.
Figure 18
Figure 18
Visualization of the ablation results of different optimization modules on Precision, Recall, mAP@0.5, and mAP@0.5:0.95.
Figure 19
Figure 19
Heatmap comparison between YOLOv8n and CAMLLA-YOLOv8n. Note: The comparison is shown in three scenarios. The first row is the original image, the second row is the YOLOv8n heatmap, and the third row is the optimized CAMLLA-YOLOv8n heatmap.
Figure 20
Figure 20
Comparison of test results between YOLOv8n and CAMLLA-YOLOv8n. Note: The first row shows the original image, the second row shows the manually annotated Ground Truth Box, the third row shows the detection results of YOLOv8n, and the fourth row shows the improved detection results of CAMLLA-YOLOv8n.
Figure 21
Figure 21
Visualization of CAMLLA-YOLOv8n detection results 1.
Figure 22
Figure 22
Visualization of CAMLLA-YOLOv8n detection results 2.

Similar articles

Cited by

References

    1. El-Sabrout K., Sherasiya A., Ahmad S., Aggag S., Nannoni E., Cavallini D., Buonaiuto G. Environmental Enrichment in Rabbit Husbandry: Comparative Impacts on Performance and Welfare. Animals. 2024;14:2367. doi: 10.3390/ani14162367. - DOI - PMC - PubMed
    1. King M.T., De Vries T.J. Production Diseases in Farm Animals: Pathophysiology, Prophylaxis and Health Management. Springer; Berlin/Heidelberg, Germany: 2024. Associations of Behavior and Production Disease in Dairy Cattle; pp. 453–467.
    1. Schweinzer V., Gusterer E., Kanz P., Krieger S., Süss D., Lidauer L., Berger A., Kickinger F., Öhlschuster M., Auer W., et al. Comparison of behavioral patterns of dairy cows with natural estrus and induced ovulation detected by an ear-tag based accelerometer. Theriogenology. 2020;157:33–41. doi: 10.1016/j.theriogenology.2020.05.050. - DOI - PubMed
    1. Sewalem A., Miglior F., Kistemaker G., Sullivan P.v., Van Doormaal B. Relationship between reproduction traits and functional longevity in Canadian dairy cattle. J. Dairy Sci. 2008;91:1660–1668. doi: 10.3168/jds.2007-0178. - DOI - PubMed
    1. Roelofs J., Lopez-Gatius F., Hunter R., Van Eerdenburg F., Hanzen C. When is a cow in estrus? Clinical and practical aspects. Theriogenology. 2010;74:327–344. doi: 10.1016/j.theriogenology.2010.02.016. - DOI - PubMed

LinkOut - more resources