# Intelligently Counting Agricultural Pests by Integrating SAM with FamNet
## 1 Introduction  
Agricultural pests and diseases have significant implications for the economic returns and long-term development of the agricultural industry. These pests not only hinder plant growth but also serve as a conduit for the spread of numerous diseases. The global farming community has expressed concerns about the prevalence of insect pests in modern agriculture. Insect pests, such as citrus psyllids, pose a significant problem as they are the primary carriers of citrus Huanglongbing, causing yellowing and defoliation of citrus leaves and ultimately leading to reduced yields [1]. Other crops, including lychees, are also plagued by pests and diseases, such as stink bugs [2], blackback beetles, aphids, scale insects, and ladybugs. By quantifying the pest population, the assessment of crop growth can be enhanced, and the correlation between pest abundance and factors such as pesticides, temperature, water, and fertilizer can be investigated. These efforts will contribute to the establishment of a comprehensive intelligent monitoring system for agricultural pests, which will provide guidance for effective crop pest management, ultimately reducing losses and increasing yields. Advancements in intelligent algorithms have notably improved the monitoring of plant pests and diseases, as discussed by [PERSON] et al. [3]. A significant contribution in thisfield was made by [PERSON] et al. [4], who proposed an enhanced deep learning network for the counting and localization of agricultural pests. Further, [PERSON] [5] demonstrated remarkable accuracy in disease identification by training a model on a vast open database that included 87,848 images of 25 different plants and diseases across 58 combinations, achieving a 99.53% accuracy rate. [PERSON] et al. [6] utilized deep learning techniques to quantify pest populations in agricultural settings, providing insights into the correlation between population dynamics and various factors such as seasonality, climate, and temperature over time. [PERSON] et al. [7] highlighted the effectiveness of Pest-YOLO, a model that has shown promising results in detecting and counting dense micro-pests on a large scale, addressing the challenge of micro-pest detection. [PERSON] et al. [8] developed an automated system for the early diagnosis of insect pest infestations in soybean fields, allowing for the assessment of infection levels and optimizing pesticide application, which in turn reduces costs and environmental impact. Despite the success of these studies with specific datasets, they are heavily dependent on extensive image data collection, which is resource intensive. Addressing this challenge, [PERSON] et al. [9] introduced FamNet in their CVPR2021 paper titled \"Learning To Count Everything\", offering a solution for object counting with limited data, or \"few shots\", and achieving excellent results. However, their approach was limited to counting within the same image and environmental context, not accounting for scenarios where the samples and instances to be counted differ in their environments or scenes. This research aims to capitalize on the robust generalization capabilities of large-scale models to enhance agricultural pest counting, overcoming the limitations of previous studies and reducing the reliance on extensive image datasets. The rapid advancement in computing power has made it possible to train language models with hundreds of billions of parameters using the Transformer architecture [10]. These models exhibit exceptional performance in various natural language processing tasks, such as inference, summarization, translation, and generating human-like text. Notably, companies like OpenAI have developed their own large-scale language models, such as the GPT series (GPT-4, GPT-3.5, and GPT-3) [11], which have gained widespread recognition in artificial intelligence fields, including medical care and pedagogy [12]. In previous research, an attempt was made to incorporate GPT into the generation of guidance for agricultural pest and disease management.