DGS-YOLO: A Detection Network for Rapid Pig Face Recognition
Simple Summary
Abstract
1. Introduction
- (1)
- We construct an indoor pig facial dataset covering faces at different times, angles, and with various occlusions. This dataset is used to train and evaluate all models presented in this paper. Addressing current challenges in facial feature detection, we propose the DGS-YOLO model based on YOLOv11n, which incorporates occlusion and texture detail features.
- (2)
- We propose the DMConv module, which combines the Mish function with the DynamicTanh module to enhance texture detail features while suppressing noise interference.
- (3)
- Using the C3k2-GBC module, features are mapped from high-dimensional to low-dimensional space, effectively capturing multi-scale information for precise target localization. Dynamic weighting adjustments for complex backgrounds and multi-morphological features reduce the impact of dirt and other obstructions on facial recognition. This achieves interaction and enhancement of detailed features.
- (4)
- Adding the SimAM attention mechanism before the detection head enables a final optimization of fine-grained features, achieving optimal accuracy.
- (5)
- We replace the original loss function with Shape-IoU to mitigate the impact of the inherent scale and shape of object boundaries on accuracy.
2. Materials and Methods
2.1. Data Collection and Processing
2.2. Method
2.2.1. YOLO Improvements
2.2.2. DMConv
2.2.3. GBC Model
2.2.4. SimAM Attention Mechanism
2.2.5. Shape-IoU Loss Function
3. Experimental Results and Analysis
3.1. Evaluation Criteria
3.2. Experimental Details
3.3. Comparative Experiments of Different Models
3.4. Ablation Experiment
3.5. Model Small-Sample Testing Experiment
3.6. Facial Recognition Analysis
3.7. Generalization Experiment
4. Discussion
5. Conclusions
- Compared to the original YOLOv11n model, the proposed DGS-YOLO achieves significant improvements across multiple core evaluation metrics, including detection accuracy, recall, and mean average precision (mAP50). Although ablation studies reveal that certain standalone improvement modules may cause temporary fluctuations in some metrics, the model achieves optimal overall performance when all optimization strategies are applied collectively, demonstrating effective synergistic interactions among the modules.
- In comparative experiments against other mainstream object detection models, DGS-YOLO demonstrated significant advantages. It outperformed SSD and Faster-RCNN models by approximately 10% in detection accuracy, superior to most competing models. Additionally, the network achieved a slight reduction in parameter count, effectively controlling overall model complexity. This facilitates deployment in real-world environments and helps address challenges in applying models within resource-constrained scenarios.
- In addressing key challenges encountered in real-world farming scenarios, DGS-YOLO demonstrates strong robustness. The model effectively handles facial recognition difficulties caused by occlusions, enhancing its ability to discern local features through deep detail feature extraction mechanisms. Simultaneously, in detection tasks with limited sample sizes, the model exhibits superior generalization performance and stability compared to the original YOLOv11n, indicating promising practical applications.
Author Contributions
Funding
Institutional Review Board Statement
Informed Consent Statement
Data Availability Statement
Conflicts of Interest
References
- Girshick, R.; Donahue, J.; Darrell, T.; Malik, J. Rich Feature Hierarchies for Accurate Object Detection and Semantic Segmentation. In Proceedings of the 2014 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), Columbus, OH, USA, 24–27 June 2014. [Google Scholar]
- Ren, S.; He, K.; Girshick, R.; Sun, J. Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks. IEEE Trans. Pattern Anal. Mach. Intell. 2016, 39, 1137–1149. [Google Scholar] [CrossRef] [PubMed]
- Liu, W.; Anguelov, D.; Erhan, D.; Szegedy, C.; Reed, S.; Fu, C.-Y.; Berg, A.C. SSD: Single Shot MultiBox Detector. In Computer Vision—ECCV 2016, Proceedings of the 14th European Conference, Amsterdam, The Netherlands, 11–14 October 2016; Springer: Cham, Switzerland, 2016. [Google Scholar] [CrossRef]
- Yan, H.; Wu, Y.; Bo, Y.; Han, Y.; Ren, G. Study on the Impact of LDA Preprocessing on Pig Face Identification with SVM. Animals 2025, 15, 231. [Google Scholar] [CrossRef] [PubMed]
- Luo, T.; Wang, C.; Wang, D.; Zhao, Z.; Huang, H.; Zhao, S.; Wang, X.; Xu, X. Cross Temporal Scale Pig Face Recognition Based on Deep Learning. J. Agric. Food Res. 2025, 21, 102002. [Google Scholar] [CrossRef]
- Liu, G.; Kang, L.; Dai, Y. Lightweight Sheep Face Recognition Model Combining Grouped Convolution and Parameter Fusion. Sensors 2025, 25, 4610. [Google Scholar] [CrossRef] [PubMed]
- Gao, G.; Ma, Y.; Wang, J.; Li, Z.; Wang, Y.; Bai, H. CFR-YOLO: A Novel Cow Face Detection Network Based on YOLOv7 Improvement. Sensors 2025, 25, 1084. [Google Scholar] [CrossRef] [PubMed]
- Chen, X.; Yang, T.; Mai, K.; Liu, C.; Xiong, J.; Kuang, Y.; Gao, Y. Holstein Cattle Face Re-Identification Unifying Global and Part Feature Deep Network with Attention Mechanism. Animals 2022, 12, 1047. [Google Scholar] [CrossRef] [PubMed]
- Weng, Z.; Liu, S.; Zheng, Z.; Zhang, Y.; Gong, C. Cattle Facial Matching Recognition Algorithm Based on Multi-View Feature Fusion. Electronics 2022, 12, 156. [Google Scholar] [CrossRef]
- Zhu, J.; Chen, X.; He, K.; Lecun, Y.; Liu, Z. Transformers without Normalization. In Proceedings of the 2025 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), Nashville, TN, USA, 11–15 June 2025. [Google Scholar]
- Misra, D. Mish: A Self Regularized Non-Monotonic Activation Function. arXiv 2020. [Google Scholar] [CrossRef]
- Liu, H.; Jia, C.; Shi, F.; Cheng, X.; Chen, S. SCSegamba: Lightweight Structure-Aware Vision Mamba for Crack Segmentation in Structures. In Proceedings of the 2025 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), Nashville, TN, USA, 11–15 June 2025. [Google Scholar]
- Yang, L.; Zhang, R.-Y.; Li, L.; Xie, X. SimAM: A Simple, Parameter-Free Attention Module for Convolutional Neural Networks. In Proceedings of the 38th International Conference on Machine Learning, Vienna, Austria, 18–24 July 2021. [Google Scholar]
- Yu, J.; Jiang, Y.; Wang, Z.; Cao, Z.; Huang, T. UnitBox: An Advanced Object Detection Network. In Proceedings of the 24th ACM International Conference on Multimedia, Amsterdam, The Netherlands, 15–19 October 2016. [Google Scholar] [CrossRef]
- Rezatofighi, H.; Tsoi, N.; Gwak, J.; Sadeghian, A.; Reid, I.; Savarese, S. Generalized Intersection over Union: A Metric and A Loss for Bounding Box Regression. In Proceedings of the 2019 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), Long Beach, CA, USA, 15–20 June 2019. [Google Scholar]
- Zheng, Z.; Wang, P.; Liu, W.; Li, J.; Ye, R.; Ren, D. Distance-IoU Loss: Faster and Better Learning for Bounding Box Regression. In Proceedings of the AAAI Conference on Artificial Intelligence (AAAI-20), New York, NY, USA, 7–12 February 2019. [Google Scholar]
- Gevorgyan, Z. SIOU LOSS: MORE POWERFUL LEARNING FOR BOUNDING BOX REGRESSION. arXiv 2022. [Google Scholar] [CrossRef]
- Zhang, H.; Zhang, S. Shape-IoU: More Accurate Metric Considering Bounding Box Shape and Scale. arXiv 2024. [Google Scholar] [CrossRef]
- Zhang, Y.-F.; Ren, W.; Zhang, Z.; Jia, Z.; Wang, L.; Tan, T. Focal and Efficient IOU Loss for Accurate Bounding Box Regression. Neurocomputing 2022, 506, 146–157. [Google Scholar] [CrossRef]
- Yang, B.; Zhang, X.; Zhang, J.; Luo, J.; Zhou, M.; Pi, Y. EFLNet: Enhancing Feature Learning for Infrared Small Target Detection. IEEE Trans. Geosci. Remote Sens. 2024, 62, 5906511. [Google Scholar] [CrossRef]
- Wang, C.-Y.; Yeh, I.-H.; Liao, H.-Y.M. YOLOv9: Learning What You Want to Learn Using Programmable Gradient Information. In Computer Vision—ECCV 2024, Proceedings of the 18th European Conference, Milan, Italy, 29 September–4 October 2024; Springer Nature: Cham, Switzerland, 2024. [Google Scholar]
- Wang, A.; Chen, H.; Liu, L.; Chen, K.; Lin, Z.; Han, J.; Ding, G. YOLOv10: Real-Time End-to-End Object Detection. Adv. Neural Inf. Process. Syst. 2024, 37, 107984–108011. [Google Scholar]
- Tian, Y.; Ye, Q.; Doermann, D. YOLOv12: Attention-Centric Real-Time Object Detectors. arXiv 2025. [Google Scholar] [CrossRef]
- Selvaraju, R.R.; Cogswell, M.; Das, A.; Vedantam, R.; Parikh, D.; Batra, D. Grad-CAM: Visual Explanations from Deep Networks via Gradient-Based Localization. In Proceedings of the IEEE International Conference on Computer Vision (ICCV 2017), Venice, Italy, 22–29 December 2017; Institute of Electrical and Electronics Engineers Inc.: Piscataway, NJ, USA, 2017; Volume 2017, pp. 618–626. [Google Scholar]











| Add Module Name | Precision | Recall | mAP50 |
|---|---|---|---|
| DynamicTanh | 0.844 | 0.847 | 0.882 |
| DMConv | 0.857 | 0.84 | 0.887 |
| Name | Precision | Recall | mAP50 |
|---|---|---|---|
| CIoU | 0.843 | 0.848 | 0.895 |
| GIoU | 0.840 | 0.884 | 0.912 |
| EIoU [19] | 0.847 | 0.865 | 0.905 |
| SIoU | 0.849 | 0.876 | 0.909 |
| ATFL [20] | 0.849 | 0.866 | 0.907 |
| Shape-IoU | 0.854 | 0.880 | 0.913 |
| Environment Configuration | Parameter |
|---|---|
| CPU | Intel(R) Core(TM) i9-10920X CPU @ 3.50 GHz |
| GPU | NVIDIA GeForce RTX 3080 |
| Development environment | PyCharm 2023.2.5 |
| Language | Python 3.8.18 |
| Framework | PyTorch 2.0.1 |
| Operating platform | CUDA 11.8 |
| Name | Precision | Recall | mAP50 | FLOPs (G) |
|---|---|---|---|---|
| SSD300 | 0.779 | 0.725 | 0.787 | 30.8 |
| Faster R-CNN | 0.815 | 0.748 | 0.814 | 37.6 |
| YOLOv5n | 0.847 | 0.845 | 0.865 | 7.1 |
| YOLOv8-nano | 0.855 | 0.813 | 0.876 | 8.1 |
| YOLOv9-tiny [21] | 0.841 | 0.864 | 0.902 | 7.7 |
| YOLOv10n [22] | 0.839 | 0.854 | 0.899 | 8.3 |
| YOLOv11n | 0.843 | 0.848 | 0.895 | 6.4 |
| YOLOv11s | 0.868 | 0.852 | 0.904 | 21.5 |
| YOLOv11m | 0.872 | 0.841 | 0.905 | 68.1 |
| YOLOv12 [23] | 0.82 | 0.838 | 0.873 | 6.5 |
| DGS-YOLO | 0.883 | 0.869 | 0.918 | 5.9 |
| DMConv | C3K2-GBC | SimAM | Shape-IOU | Precision | Recall | mAP50 | FLOPs | |
|---|---|---|---|---|---|---|---|---|
| 1 | 0.843 | 0.848 | 0.895 | 6.4 | ||||
| 2 | √ | 0.855 | 0.84 | 0.887 | 6.4 | |||
| 3 | √ | 0.867 | 0.84 | 0.906 | 5.9 | |||
| 4 | √ | 0.842 | 0.848 | 0.895 | 6.4 | |||
| 5 | √ | √ | 0.869 | 0.844 | 0.903 | 5.9 | ||
| 6 | √ | √ | 0.857 | 0.848 | 0.898 | 5.9 | ||
| 7 | √ | √ | 0.847 | 0.86 | 0.896 | 6.4 | ||
| 8 | √ | √ | √ | 0.878 | 0.854 | 0.911 | 5.9 | |
| Ours | √ | √ | √ | √ | 0.883 | 0.869 | 0.918 | 5.9 |
| Name | Precision | Recall | mAP50 |
|---|---|---|---|
| YOLOv11n | 0.561 | 0.744 | 0.705 |
| DGS-YOLO | 0.763 | 0.747 | 0.808 |
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. |
© 2026 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.
Share and Cite
Chao, H.; Tu, W.; Liu, T.; Zhu, H.; Hu, J.; Hu, T.; Sun, Y.; Mu, Y.; Fan, J.; Gong, H. DGS-YOLO: A Detection Network for Rapid Pig Face Recognition. Animals 2026, 16, 187. https://doi.org/10.3390/ani16020187
Chao H, Tu W, Liu T, Zhu H, Hu J, Hu T, Sun Y, Mu Y, Fan J, Gong H. DGS-YOLO: A Detection Network for Rapid Pig Face Recognition. Animals. 2026; 16(2):187. https://doi.org/10.3390/ani16020187
Chicago/Turabian StyleChao, Hongli, Wenshuang Tu, Tonghe Liu, Hang Zhu, Jinghuan Hu, Tianli Hu, Yu Sun, Ye Mu, Juanjuan Fan, and He Gong. 2026. "DGS-YOLO: A Detection Network for Rapid Pig Face Recognition" Animals 16, no. 2: 187. https://doi.org/10.3390/ani16020187
APA StyleChao, H., Tu, W., Liu, T., Zhu, H., Hu, J., Hu, T., Sun, Y., Mu, Y., Fan, J., & Gong, H. (2026). DGS-YOLO: A Detection Network for Rapid Pig Face Recognition. Animals, 16(2), 187. https://doi.org/10.3390/ani16020187

