###### Abstract  
Fruit fly species classification is a fine-grained task as there is a small gap between species. In order to effectively identify and improve the recognition of fruit flies, a fine-grained image-recognition method based on a multi-channel self-attention mechanism was studied and a network framework for fine-grained image recognition based on deep learning was designed in this paper. In this framework, long-term and short-term memory networks are used to extract the underlying features in fruit fly fine-grained images. By inputting the underlying features in the multi-channel self-attention mechanism module, the global and local attention feature maps can be obtained.The weighted attention feature map can also be obtained by multiplying the weight of each channel and the attention feature map. The fine-grained image features of fruit flies were obtained by summing the weighted attention feature map. A softmax classifier was used to process the features and complete the recognition of the fruit fly fine-grained images. Two fine-grained image datasets of fruit flies were applied as experimental objects. Dataset 1 and Dataset 2 contain 11,778 images and 20,580 images from 46 different categories of fruit flies, respectively. The Kappa coefficient was used as the evaluation index to identify fruit fly images with different targets using the method proposed herein. The experimental results showed that, as the number of attention channels increased, the Kappa coefficient gradually increased, suggesting an improvement in the accuracy of fine-grained image recognition. The fine-grained image features extracted by introducing a multi-channel self-attention mechanism exhibited more distinct boundaries with a small amount of overlap, demonstrating strong feature extraction capabilities. When dealing with fine-grained images with either simple or complex backgrounds, the method proposed in this paper has good performance and generalization ability. Even if the target is small and varied in shape, it can still achieve highly accurate recognition. multi-channel self-attention mechanism; fine-grained image recognition; long-term and short-term memory network; softmax classification +
Footnote †: journal:  
case of the fruit fly, there are small differences between the species of Drosophila, which increase the difficulty in distinguishing them by traditional fine-grained image-recognition methods. More effective fine-grained image-recognition methods need to be developed to improve the recognition accuracy [5]. By studying effective fine-grained image-recognition methods, we can promote the control and monitoring of agricultural pests, help agricultural departments find fruit fly hazards in a timely manner, and guide agricultural departments to take scientific control measures to deal with fruit fly hazards, improve the control ability of agricultural pests, and improve the management level of agricultural production. Fine-grained image recognition, especially in distinguishing closely related species like Drosophila (fruit flies), presents a significant challenge for computer vision. Traditional methods struggle with intricate details, prompting the exploration into advanced techniques such as convolutional neural networks (CNNs) and attention mechanisms. Successful fine-grained image recognition holds key implications for agriculture, enabling accurate pest identification like fruit flies. This facilitates targeted and efficient pest control, reducing pesticide use and the environmental impact. Future research should refine specialized models for agricultural pest challenges, fostering collaboration between computer vision and agriculture experts for practical solutions. In conclusion, addressing fine-grained image-recognition challenges in agriculture, particularly fruit fly identification, is crucial for sustainable pest management. Ongoing research and advanced technologies, like deep learning, enhance precision, benefiting global food production and ecosystem health.