Precise Crop Pest Detection Based on Co-Ordinate-Attention-Based Feature Pyramid Module

Chenrui Kang, Lin Jiao, Kang Liu, Zhigui Liu, Rujing WangInsects 2025 · DOI

TL;DR

This paper introduces a novel deep learning approach, CAFPN, for precise detection of small agricultural pests. By combining a co-ordinate attention mechanism with a feature pyramid network and a dynamic sample selection strategy, the method significantly improves accuracy in identifying these challenging targets, crucial for effective pest management.

What Problem Does This Paper Address?

Accurate and timely detection of crop pests is vital for integrated pest management (IPM), allowing for targeted pesticide application and minimizing crop damage. Traditional manual methods are labor-intensive, time-consuming, and prone to subjective errors. While deep learning has shown promise, detecting small, often camouflaged pests remains a significant challenge. Existing deep learning models struggle with extracting discriminative features from these tiny objects and effectively handling the selection of positive and negative training samples, leading to suboptimal recognition and localization.

Methods

The core of this work lies in two main innovations:

  • Co-Ordinate-Attention-Based Feature Pyramid Network (CAFPN): This module enhances the standard Feature Pyramid Network (FPN) by incorporating a co-ordinate attention mechanism. Unlike traditional FPNs that simply add feature maps, CAFPN captures not only cross-channel but also direction-aware and position-sensitive information. This allows the network to better distinguish subtle features of small pests and improve localization accuracy. The attention mechanism encodes spatial information along horizontal and vertical axes, generating attention weights that are then used to merge feature maps.
  • Dynamic Sample Selection Strategy: To address the issue of imbalanced positive and negative samples during training, the authors propose a dynamic strategy. This involves a category-specific Gaussian-shaped function to assign positive weights, prioritizing samples with more accurate predictions. For negative samples, a weight function based on Intersection over Union (IoU) is used to suppress false positives and provide a more informative gradient for regression tasks. This strategy aims to improve the network's ability to learn from challenging samples.

These components are integrated into an anchor-free, single-stage detection framework (FCOS) as the baseline.

Datasets

The proposed method was evaluated on two datasets:

  • AgriPest21: A large-scale, multi-class agricultural pest dataset constructed by the authors. It contains 21 types of crop pests with 24,412 images, split into training (22,000 images) and testing (2,412 images) sets. Images were resized to 800x600 pixels for training. This dataset is notable for its inclusion of many small-sized pests and instances of dense pest distribution.
  • IP102: A publicly available dataset collected from the internet, containing 102 types of pests. For this study, 18,983 images were used for object detection. The IP102 dataset is characterized by a serious class imbalance and a wide range of pest scales and complex backgrounds.

Key Insights and Ideas

  • The Importance of Positional and Directional Information: The paper highlights that simply fusing features in FPNs is insufficient for small object detection. Explicitly capturing positional and directional cues through co-ordinate attention significantly boosts feature discriminability.
  • Beyond Simple IoU for Sample Selection: The authors demonstrate that a more sophisticated dynamic sample selection strategy, considering both classification confidence and localization accuracy, is crucial for effective training, especially with imbalanced datasets.
  • Small Pest Detection is a Distinct Challenge: The research underscores that methods optimized for larger objects do not automatically translate to small pest detection. Specific architectural and training strategies are required.
  • Trade-offs in Network Depth: Deeper backbones (e.g., ResNet101) did not consistently improve small pest detection accuracy and could even degrade performance, suggesting that feature loss in deeper layers is a concern for tiny objects.

Key Results

  • On the AgriPest21 dataset, the proposed method achieved a mean Average Precision (mAP) of 77.2%, outperforming other state-of-the-art detectors.
  • On the IP102 dataset, the method achieved an mAP of 29.8% (for IoU [0.5:0.95]), also demonstrating superior performance compared to other detectors, despite the dataset's inherent challenges.
  • The CAFPN module alone improved the AP by 4.93% on the AgriPest21 dataset compared to a baseline FCOS with a traditional FPN.
  • The dynamic sample selection strategy further boosted performance by 2.3%, reaching an AP of 51.6%.
  • The method achieved competitive detection speed (25.8 FPS) with a reasonable number of parameters (32.19M), indicating a good balance between accuracy and efficiency.

Limitations and Future Work

The authors acknowledge that their proposed method still has limitations, particularly in few-shot pest detection (i.e., detecting pests with very few training examples). They suggest that future work should focus on:

  • Data Generation Strategies: Employing techniques like diffusion models and generative adversarial networks to create more training data for low-resource scenarios.
  • Further Optimization for Few-Shot Learning: Developing more specialized approaches to handle situations with limited annotated data.

Summary updated

Abstract

Insect pests strongly affect crop growth and value globally. Fast and precise pest detection and counting are crucial measures in the management and mitigation of pest infestations. In this area, deep learning technologies have come to represent the method with the most potential. However, for small-sized crop pests, recent deep-learning-based detection attempts have not accomplished accurate recognition and detection due to the challenges posed by feature extraction and positive and negative sample selection. Therefore, to overcome these limitations, we first designed a co-ordinate-attention-based feature pyramid network, termed CAFPN, to extract the salient visual features that distinguish small insects from each other. Subsequently, in the network training stage, a dynamic sample selection strategy using positive and negative weight functions, which considers both high classification scores and precise localization, was introduced. Finally, several experiments were conducted on our constructed large-scale crop pest datasets, the AgriPest 21 dataset and the IP102 dateset, achieving accuracy scores of 77.2% and 29.8% for mAP (mean average precision), demonstrating promising detection results when compared to other detectors.
BibTeX
@inproceedings{kang2025precise,
  author = {Chenrui Kang and Lin Jiao and Kang Liu and Zhigui Liu and Rujing Wang},
  title = {{Precise Crop Pest Detection Based on Co-Ordinate-Attention-Based Feature Pyramid Module}},
  booktitle = {Insects},
  year = {2025},
  doi = {10.3390/insects16010103},
}
Figure