MHAFF: Multihead Attention Feature Fusion of CNN and Transformer for Cattle Identification
Rabin Dulal, Lihong Zheng, Muhammad Ashad Kabir
Abstract
Convolutional neural networks (CNNs) have drawn researchers’ attention to identifying cattle using muzzle images. However, CNNs often fail to capture long-range dependencies within the complex patterns of the muzzle. The transformers handle these challenges, but they have limited ability to extract local features. This inspired us to combine or fuse the advantages of CNNs and transformers in muzzle-based cattle identification. Addition and concatenation have been the most commonly used techniques for feature fusion. However, addition fails to preserve discriminative information, while concatenation results in an increase in dimensionality. Both methods are simple operations and cannot discover the relationships or interactions between fused features. This research aims to overcome the issues faced by addition and concatenation. This research introduces a novel approach called multihead attention feature fusion (MHAFF) in cattle identification. MHAFF captures relations between the different types of fusing features while preserving their originality. The experiments show that MHAFF outperformed addition and concatenation techniques and the existing cattle identification methods in accuracy on two publicly available cattle datasets. MHAFF demonstrates excellent performance and quickly converges to achieve an optimum accuracy of 99.88% and 99.52% in two cattle datasets simultaneously.