## 2 Methods
### Data Augmentation Model Based on Multiple Factors  
The classification and detection of pest and disease image is frequently affected by a variety of external factors in practical applications. Current datasets fall short of providing comprehensive coverage of these influences, resulting in an inability to fully acquire and recognize these diverse interference features during the model learning process. Collecting images through field photography is exceedingly challenging, owing to the impacts of varying climatic conditions, the diversity of pest and disease types, and the unpredictability of outbreak timings. Consequently, the data augmentation model based on multiple factors is proposed to address this issue, as depicted in Figure 2.  
The external factors affecting classification and detection can be primarily categorized into environmental factors, growth factors, and filming factors through systematic analysis and organization. Environmental factors necessitate that images should incorporate more background elements, such as crops, soil, and water sources, as disturbances, while also possessing effective target occlusion interference. Growth factors demand that images establish the relationship between different stages of disease progression and pest growth phases (e.g., eggs, larvae, adult insects), thereby mitigating the impact of significant intra-class variability and minimal inter-class differences within the pest and disease datasets. Filming factors refer to the clarity, brightness, and shooting angle of the images.  
The three factors are addressed by the data augmentation model proposed in this paper. Random regional cropping to the original images is applied in the model regarding environmental factors. The cropped area is 20% of the original image (it has been experimentally shown that the effect of the shape of the cropping region has less influence on the data augmentation, hence the rectangular cropping is used in this work), and the cropped segments are subsequently completed using DeepFill [27; 28] to generate new image data. The new background information will be generated by the process of completing images, and the 20% random cropping mitigates the possibility of extensive coverage over critical information while also facilitating the production of an occlusion effect on the target.  
Figure 1: Overview of SFA-ViT, which includes three key sub-models: a data augmentation model based on multiple factors, a classification model based on multi-scale ViT, and a detection model based on multi-scale attention.  
The principle of the mixup algorithm [29] is borrowed by the model for growth factors, where two or three images, randomly selected from within the class of the dataset, will be fused (when two images are fused, each image's fusion weight is 0.5; when three images are fused, the weight for each is 1/3), and the fused labels will remain as labels of that class. This methodology is conducive to enhancing the degree of information correlation between intra-class images, facilitating the establishment of connections between stages of disease progression and growth phases. The model will randomly select two or three combinations of basic transformations (e.g., angle transformations with a random range of 1-360\({}^{\circ}\); brightness, saturation, and contrast transformations with a random range of 0.5-1.5; blurring transformations with a random range of 1-2; scaling transformations with a random range of 0.5-2) for the filming factors and apply them to the original image to generate new image data. The construction of new data containing various variants is facilitated by the combination of image transformations, which drives the robustness of the model.