A Parallel Attention Network For Cattle Face Recognition

Jiayu Li, Xuechao Zou, Shiying Wang, Ben Chen, Junliang Xing, Pin Tao

Abstract

Individual cattle identification is a cornerstone of modern livestock management and behavioral research. However, existing biometric methods often struggle in "wild" environments characterized by uncontrolled lighting and varying animal poses. This paper introduces the Parallel Attention Network (PANet) and the Initial Cattle Recognition in Wild Environments (ICRWE) dataset. By employing a parallel architecture that simultaneously processes positional and feature-based information, PANet achieves a state-of-the-art accuracy of 88.03% on the ICRWE dataset, significantly outperforming standard vision architectures while maintaining a lightweight parameter footprint.

Introduction

Traditional cattle identification relies on invasive physical markers like ear tags or RFID chips, which are prone to loss and tampering. Computer vision offers a non-contact alternative, yet most current research focuses on controlled environments. In natural ranching settings, factors such as inconsistent lighting, cluttered backgrounds, and non-frontal head orientations pose significant hurdles for standard recognition algorithms. To address these challenges, we propose a robust parallel attention mechanism and provide a comprehensive dataset to benchmark performance in realistic scenarios.

The ICRWE Dataset

A primary contribution of this work is the ICRWE dataset, the first large-scale collection specifically designed for cattle face recognition in the wild. It comprises 9,816 high-resolution images of 483 individual cattle.

Examples of cattle face images in the ICRWE dataset illustrating variations in lighting (a-d) and orientation (1-3).

The dataset is meticulously annotated to reflect real-world variability, including four lighting conditions (Dark, Normal, Exposure, Non-uniform) and three primary face orientations (Left, Front, Right). To minimize noise, a YOLOv5-based preprocessing step was implemented to detect and crop cattle faces, which proved critical for improving recognition accuracy across all tested models.

Methods: Parallel Attention Network (PANet)

The proposed PANet architecture departs from the serial processing typical of standard Transformer blocks. Instead, it utilizes two parallel modules to capture diverse feature representations:

  • Position Attention Module (PAM): This module identifies spatial feature locations using depth-wise separable convolutions and a Parallel Channel Attention (PCA) mechanism. PCA utilizes both Global Max Pooling (GMP) to highlight salient details and Global Average Pooling (GAP) to maintain global context.
  • Feature Mapping Module (FMM): This component performs non-linear mapping to extract intricate patterns within the feature space.

The outputs of PAM and FMM are fused using learnable parameters ($\alpha$ and $\beta$), allowing the network to dynamically weight the importance of spatial versus feature-based information. The model is optimized using a triplet loss function to ensure high discriminative power in the feature space.

Results and Discussion

PANet demonstrates superior performance compared to established architectures. It achieved a top accuracy of 88.03%, surpassing ConvNeXt (80.57%), ShuffleNetv2 (82.56%), and Swin Transformer (74.41%).

Key findings include:

  • Robustness to Lighting: PANet maintained high performance across all lighting categories, particularly excelling in "Normal" conditions.
  • Efficiency: With only 19.61M parameters, PANet is significantly more efficient than larger models like ViT (86.23M), making it a viable candidate for future deployment on edge devices.
  • Impact of Preprocessing: Cropping faces to remove background interference resulted in a substantial accuracy boost, highlighting the sensitivity of recognition models to environmental noise.

Conclusion

PANet and the ICRWE dataset represent a significant advancement in non-invasive cattle identification. By prioritizing parallel feature processing, the model effectively handles the complexities of wild environments. Future work will focus on integrating temporal data from video streams and optimizing the architecture for real-time deployment on mobile ranching hardware.

Summary updated

BibTeX
@inproceedings{li2024parallel,
  author = {Jiayu Li and Xuechao Zou and Shiying Wang and Ben Chen and Junliang Xing and Pin Tao},
  title = {{A Parallel Attention Network For Cattle Face Recognition}},
  booktitle = {ICME},
  year = {2024},
  url = {https://openreview.net/forum?id=SHaD7ULKA0},
}
Figure