# Lightweight Domestic Pig Behavior Detection Based on YOLOv8
## 5 Conclusions  
This study addresses the challenges of excessive model parameters and high computational complexity in pig behavior recognition by proposing a lightweight algorithm based on YOLOv8n, named YOLOv8-PigLite. The algorithm introduces optimized improvements to the original model's C2f module and convolution operations, and significantly reduces parameters in the neck network, thereby lowering overall computational cost while effectively maintaining detection accuracy. Additionally, a dual-branch structure and SE attention modules are incorporated to enhance the model's ability to capture behavioral features, further reducing misclassification rates. Experimental results demonstrate that YOLOv8-PigLite achieves a significant reduction in both parameter count and floating-point operations compared to the baseline and other classical detection models, while maintaining strong generalization ability and recognition accuracy on a public pig behavior dataset. The model performs comparably to the original YOLOv8 in terms of precision and recall, while offering improved efficiency and stability. With its lightweight design and ease of deployment, YOLOv8-PigLite is particularly suitable for small- and medium-sized farms with limited computing resources. It enables real-time recognition and early warning of abnormal pig behaviors, effectively alleviating the inefficiencies of traditional manual monitoring, and holds substantial practical value and application potential.  
Methodology, K.Z.; software, Y.Z.; formal analysis, Y.Z.; investigation, K.Z.; writing--original draft preparation, K.Z.; writing--review and editing, H.X.; project administration, Y.Z. All authors have read and agreed to the published version of the manuscript.  
This research was supported by funding from Shandong Agricultural University through a technical development contract titled \"Development of Machine Learning-Based Swine Growth Prediction Technology\" (Contract Registration No. 2024370901156798). All associated costs were fully covered by the funding provided under this contract.  
Not applicable.  
The data presented in this study are available from the first author upon request. The source codes generated are available in the repository [[[https://github.com/nnz1](https://github.com/nnz1)]([https://github.com/nnz1](https://github.com/nnz1)) 19/pig-lite] (accessed on 29 May 2025).  
\begin{table}
\begin{tabular}{c c c c c c c} \hline \multirow{2}{*}{**Dataset**} & \multicolumn{3}{c}{**YOLOv8n**} & \multicolumn{3}{c}{**YOLOv8-PigLite**} \\ \cline{2-7}  & **P \%** & **R \%** & **mAP@50** & **P \%** & **R \%** & **mAP@50** \\ \hline PBRD & 96.0 & 95.5 & 98.6 & 96.3 & 95.2 & 98.5 \\ Comp & 95.7 & 96.2 & 98.4 & 96.2 & 96.2 & 98.6 \\ \hline \end{tabular}
\end{table}
Table 5: External dataset testing.  
**Acknowledgments:** This research was conducted at Shandong Agricultural University. We express our sincere gratitude to Shandong Agricultural University for providing essential resources, including laboratory facilities and computational support, which greatly contributed to the completion of this study.  
**Conflicts of Interest:** The authors declare no conflicts of interest. This paper represents the opinions of the authors and does not mean to represent the position or opinions of the Shandong Agricultural University.