A Lightweight Cow Face Identification Method Based on Improved DenseNet121
-
Graphical Abstract
-
Abstract
To effectively address the limitations associated with traditional contact-based cattle identification methods, specifically their substantial maintenance costs and the high tendency to induce stress reactions in livestock that can compromise animal welfare, and to overcome the persistent technical bottleneck where existing machine vision models struggle to simultaneously achieve high recognition precision and maintain a lightweight architectural profile suitable for complex breeding environments, this study proposes a novel Lightweight Cow Face Identification Network, designated as LCFI-Net. This innovative model is constructed based on an improved and optimized version of the DenseNet121 architecture. The methodological framework involves a multi-stage optimization process designed to balance efficiency with performance. First, the backbone network of the original DenseNet121 model is structurally pruned and refined to create a more efficient variant named DenseNet_Lite, which serves as the foundation for reducing computational redundancy. Following this structural refinement, a Multi-Scale Attention Dense Layer (MSAD-Layer) is introduced into the network architecture. This specific layer is designed to realize the seamless integration of multi-scale feature fusion with advanced attention mechanisms, significantly enhancing the model's capability to perceive, capture, and focus on key fine-grained features while effectively suppressing irrelevant background noise, even when the cattle are situated in scenarios characterized by complex environmental interference. Furthermore, to optimize the efficient transmission of information across different layers of the network, an Inverted Residual Bottleneck Transition Layer (IRB-TLayer) is utilized; this specialized transition layer is engineered to facilitate efficient dimensionality reduction while simultaneously maximizing the preservation of the integrity and completeness of image feature information, thereby preventing the loss of critical details during the feature extraction process. The training and evaluation of the model were subsequently conducted within a metric learning framework to optimize the feature space. The proposed model was rigorously tested using a high-quality dataset of visible light images of cow faces, which were specifically collected from natural, unconstrained, and complex breeding environments to ensure real-world applicability. The experimental results demonstrate the superior performance and efficiency of the proposed method: on the test set, LCFI-Net achieved a recognition accuracy of 93.54%, representing a significant improvement of 2.04 percentage points over the baseline DenseNet121 model. Crucially, regarding model efficiency, the parameter count of LCFI-Net is extremely low, standing at only 1.02 M, which constitutes a massive reduction in model size by lowering the parameter volume by 6.07 M compared to the original DenseNet121. When benchmarked against other mainstream deep learning models, LCFI-Net demonstrated consistent and substantial advantages, with accuracy improvements of 4.50, 4.46, 4.08, 2.75, and 2.29 percentage points over MobileNetv2, ShuffleNetv2, MobileFaceNet, ResNet50, and ResNet18, respectively. In addition to these quantitative metrics, qualitative feature visualization analysis results indicate that the features extracted by LCFI-Net possess significantly better properties in terms of intra-class compactness and inter-class separability, implying that the model can effectively overcome common environmental challenges, such as uneven lighting conditions and large-angle pose deviations, to demonstrate stronger robustness. Consequently, this research provides vital theoretical and technical support for precise machine vision-based cattle identity recognition in scenarios with limited computational resources, such as mobile robots or intelligent agricultural equipment.
-
-