A leafy vegetable disease detection method based on few-shot learning and prototype attention

Through detection methods based on few-sample learning and prototype attention, the complex background and few-sample problems in leafy vegetable disease detection are solved, efficient and real-time disease detection is achieved, and the robustness and accuracy of the model is improved, and it is suitable for multiple diseases and complex environments.

CN120107791BActive Publication Date: 2025-09-02CHINA AGRI UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510175105.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-02-18
Publication Date
2025-09-02
Estimated Expiration
2045-02-18

AI Technical Summary

Technical Problem

The prior art has problems of insufficient adaptability, robustness and accuracy in complex backgrounds and small sample scenarios in the detection of leafy vegetable diseases, making it difficult to achieve real-time and efficient disease detection.

Method used

The detection method based on few-sample learning and prototype attention is adopted, and the model's adaptability and generalization ability to new categories is optimized through data preprocessing, multi-scale feature extraction, global feature modeling, object detection and semantic segmentation, combined with prototype attention mechanism and knowledge distillation.

Benefits of technology

It realizes high robustness and high-precision disease detection under complex environments and small samples, supports real-time disease detection and control applied to vegetable planting areas, and improves the applicability and real-timeness of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120107791B_ABST
    Figure CN120107791B_ABST
Patent Text Reader

Abstract

The present invention discloses a leafy vegetable disease detection method based on few-shot learning and prototype attention, comprising the following steps: S1, preprocessing and enhancing data; S2, performing multi-scale feature extraction on images; S3, global feature modeling; S4, target detection and semantic segmentation; S5, few-shot optimization and fine-tuning. The present invention adopts the above-mentioned leafy vegetable disease detection method based on few-shot learning and prototype attention. Aiming at the problem of scarcity of agricultural disease data samples, the few-shot learning network architecture is introduced. It can realize fast and accurate disease area identification and segmentation under limited data conditions, combines target detection and semantic segmentation tasks, performs disease location and fine-grained segmentation, improves detection accuracy and segmentation performance, integrates prototype extraction with attention mechanism, effectively improves the learning ability of the model under low-sample conditions, can be applied in real time to disease detection and control in vegetable planting areas, and supports farmers in efficient disease management.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the fields of computer vision, deep learning, and target detection technology, and in particular to a leafy vegetable disease detection method based on few-sample learning and prototype attention. Background Art

[0002] Feature extraction technology based on deep learning: This method of identifying plant diseases by extracting global and local features of the diseased area can reduce feature redundancy and has higher performance, but it relies heavily on feature extraction. The growing environment of leafy vegetables is usually more complex and the types of diseases are diverse. This method cannot adapt well to complex backgrounds or small sample problems.

[0003] Automated leaf disease detection technology based on image processing: extracts statistical features and combines them with support vector machine classification, with an accuracy rate of 85%. However, the technology's statistical process relies on manual definition, which has limited applicability and poor disease recognition in complex scenarios.

[0004] Improved vegetable disease detection algorithm based on YOLOv5s: Improved CSP, FPN and NMS modules, enhanced multi-scale feature extraction capabilities and detection performance, and the mAP can reach 93.1%; but it is not robust enough in scenarios with few sample data, and its ability to perform fine-grained disease segmentation is limited; in the production process of leafy vegetables, there is often a shortage of rare disease samples, which means that the algorithm's adaptability is still not wide enough.

[0005] A disease detection model that uses transfer learning to extract relevant features. Transfer learning can effectively improve the model's accuracy, reaching 97.8%. However, the model still relies on a large amount of data, and transfer learning is still limited in scenarios with few samples.

[0006] A two-stage model combining DeepLabV3+ and U-Net: Combining DeepLabV3+ and U-Net, a two-stage classification of the severity of leaf diseases can be implemented, which can achieve high segmentation precision and high accuracy of severity classification (92.85%); however, the model has problems such as complex structure, large computational complexity, and difficulty in real-time application; at the same time, it also lacks specificity for small sample problems.

[0007] Leaf disease classification method based on CNN and SVM: This method uses CNN to extract features and combines it with SVM classification, with an average accuracy of 96.8%; however, due to the relatively independent nature of the feature extraction and classification steps in this method, the model's integration and real-time performance are poor.

[0008] Traditional image processing technologies, including threshold segmentation, edge detection, and texture analysis, rely on manually defined features and are unable to automatically adapt to diverse disease characteristics. This fundamentally does not meet the requirements of future automated agricultural production. They also suffer from poor adaptability to complex backgrounds and environmental changes. Furthermore, under conditions with multiple diseases or multiple crops, traditional image processing technologies exhibit low detection accuracy and poor robustness. Summary of the Invention

[0009] The purpose of the present invention is to provide a leafy vegetable disease detection method based on few-sample learning and prototype attention, which can be applied in real time to disease detection and control in vegetable-growing areas, support farmers in efficient disease management, and has wide applicability; compared with traditional methods and existing deep learning technologies, it has higher robustness, accuracy and efficiency in low-sample data scenarios, and can provide a more effective solution for agricultural disease detection.

[0010] To achieve the above objectives, the present invention provides a leafy vegetable disease detection method based on few-shot learning and prototype attention, comprising the following steps:

[0011] S1. Preprocess and enhance the data;

[0012] S2, extract multi-scale features from the image;

[0013] S3, global feature modeling;

[0014] S4, object detection and semantic segmentation;

[0015] S5. Few-shot optimization and fine-tuning.

[0016] Preferably, in S1, preprocessing and enhancing the data includes performing shear blending, blending enhancement, and random occlusion operations on the image;

[0017] Among them, shear blending is performed by pasting a local rectangular area in one image into another image, blending enhancement is performed by blending two images and their corresponding labels in a specific proportion, and random occlusion is performed by randomly occluding a rectangular area in the image to simulate the occlusion scene.

[0018] Preferably, in S2, ResNet-50 is used as the backbone network for feature extraction in the ProtoVegNet model to perform multi-scale feature extraction. The specific process is as follows:

[0019] ResNet-50 uses multiple layers of 3×3 convolution kernels and stride 2 convolution operations to gradually downsample the image and generate multi-level feature maps. The resolution of the feature maps is gradually reduced to H / 32×W / 32, H / 32×W / 32, H / 16×W / 16, H / 16×W / 16, H / 8×W / 8, and H / 4×W / 4, and the number of channels is fixed at 256.

[0020] Finally, a multi-scale feature map is generated to capture the diversity and complexity of leafy vegetable diseases, including lesions of different sizes, shapes, and colors.

[0021] Preferably, in S3, a Transformer encoder is used for global semantic modeling. The specific process is as follows:

[0022] The multi-scale features extracted from S2 are fed into the Transformer encoder, which captures the global features of the input image and uses the self-attention mechanism to model the long-distance dependencies between features. The encoder consists of N stacked layers, each of which uses the attention mechanism and feedforward network to model the global context information of the input features.

[0023] The decoder generates features rich in global context information and outputs a globally perceived feature map containing deep semantic information and spatial relationships of the diseased area.

[0024] Preferably, in S3, position embedding information is added to each layer of feature map to retain spatial position information to ensure correct positioning of disease features. After multi-scale feature extraction, the prototype extraction module in the ProtoVegNet model is used to extract category prototypes from the feature map, and the category prototypes are used as the global representation of the category.

[0025] Preferably, the prototype extraction module extracts the category prototype from the feature map, and the specific process is as follows:

[0026] The multi-scale feature maps output by the ResNet-50 backbone network and the Transformer encoder are used as input to perform dimensionality reduction on the input high-dimensional feature maps;

[0027] Calculate the attention weight matrix based on the category prototype: Use the category prototype and the embedding of each pixel or feature point in the input feature map to calculate the similarity. The correlation result is normalized by the Softmax operation to generate the attention weight matrix, which represents the response strength of each feature point to each category.

[0028] The prototype attention mechanism is used to weight the original feature map. Feature areas with high similarity to the category prototype are given higher weights, which enhances the response while suppressing background interference.

[0029] The features belonging to the same category in the feature map are grouped by a clustering algorithm, and then output as a low-dimensional, global representation vector. This vector is used to summarize the core features of the category, that is, the category prototype. The center of each group, that is, the mean vector, is calculated as the category prototype of the category;

[0030] The prototype extraction module generates a corresponding prototype vector for each category. The prototype vector serves as the input of the attention mechanism, and the enhanced feature map is input into the target detection and semantic segmentation submodule.

[0031] Preferably, in S4, target detection and semantic segmentation are performed using a target detection submodule and a semantic segmentation submodule, wherein the target detection submodule includes a foreground predictor, a classifier, and a bounding box predictor, which are respectively used to determine which areas in the image contain diseases, classify the foreground areas, and extract the bounding boxes of the diseased areas; the semantic segmentation submodule includes a mask predictor, which is used to generate a segmentation mask for the diseased area.

[0032] Preferably, S4 specifically includes the following steps:

[0033] S41. In the global features, the foreground predictor in the object detection submodule selects the top k most significant feature points. These feature points represent potential disease areas. The classifier then predicts the category of the selected significant feature points to identify the disease type. The bounding box predictor regresses the bounding box coordinates of the disease area.

[0034] S42. In the semantic segmentation submodule, the mask predictor generates pixel-level segmentation masks for the diseased area based on multi-scale features;

[0035] S43, upsampling the segmentation mask back to the resolution of the original image through an upsampling module to accurately locate the diseased area;

[0036] S44: Output the detection and classification results, pixel-level segmentation mask, and bounding box of the diseased area.

[0037] Preferably, the specific process of S5 is as follows:

[0038] First, train the base model, train the backbone network and dual-task module on the enhanced dataset, and process standard categories;

[0039] Then, we fine-tune the new categories and use the ProtoVegNet model to generate pseudo labels through the attention mechanism to provide additional supervision signals for the few-shot data.

[0040] The ProtoVegNet model introduces knowledge distillation during the fine-tuning process to extract knowledge from the base model to guide the training of the current model to optimize the feature expression of new category data while maintaining the detection performance of the base model for the original category.

[0041] Therefore, the present invention adopts the above-mentioned leafy vegetable disease detection method based on few-sample learning and prototype attention, and the beneficial effects are as follows:

[0042] (1) The ProtoVegNet of the present invention enhances the robustness of the model and its ability to express fine-grained features by introducing the prototype attention mechanism of the few-shot learning method.

[0043] (2) The model provided by the present invention introduces a prototype loss function to optimize the distance relationship between samples and category prototypes, thereby improving the category discrimination ability of the model.

[0044] (3) The model provided by the present invention can be applied in real time to disease detection and control in vegetable growing areas. The design of ProtoVegNet takes into account the needs of various scenarios and complex backgrounds. It has strong robustness and generalization ability and is suitable for detection tasks of multiple diseases and complex environments.

[0045] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] Figure 1 This is an overall flow chart of the ProtoVegNet model of an embodiment of a leafy vegetable disease detection method based on few-shot learning and prototype attention of the present invention;

[0047] Figure 2 is a dataset sample of an embodiment of a leafy vegetable disease detection method based on few-shot learning and prototype attention of the present invention, wherein a is spinach downy mildew, b is spinach white rust, c is spinach anthracnose, d is spinach virus disease, e is romaine lettuce downy mildew, f is romaine lettuce gray mold, g is romaine lettuce soft rot, h is romaine lettuce virus disease, i is Chinese cabbage downy mildew, j is Chinese cabbage black rot, k is Chinese cabbage soft rot, l is Chinese cabbage black spot, m is cabbage downy mildew, n is cabbage black spot, o is cabbage sclerotinia, p is cabbage black rot, q is leaf lettuce downy mildew, r is leaf lettuce brown spot, s is leaf lettuce sclerotinia, and t is leaf lettuce powdery mildew;

[0048] Figure 3 2. It is a schematic diagram of a multi-scale feature extraction process of an embodiment of a leafy vegetable disease detection method based on few-shot learning and prototype attention of the present invention;

[0049] Figure 4 This is a flowchart of the prototype extraction module of an embodiment of a leafy vegetable disease detection method based on few-sample learning and prototype attention of the present invention. DETAILED DESCRIPTION

[0050] The technical solution of the present invention is further described below with reference to the accompanying drawings and embodiments.

[0051] Unless otherwise defined, the technical or scientific terms used in the present invention shall have the usual meanings understood by persons of ordinary skill in the field to which the present invention belongs. The words "first", "second" and similar terms used in the present invention do not indicate any order, quantity or importance, but are only used to distinguish different components. Words such as "include" or "comprise" mean that the elements or objects preceding the word include the elements or objects listed after the word and their equivalents, without excluding other elements or objects. Words such as "connect" or "connected" are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the object being described changes, the relative positional relationship may also change accordingly.

[0052] In actual production, to solve the problems of complex leafy vegetable disease detection environment and small sample size, the ProtoVegNet model of the present invention needs to address the following major technical challenges:

[0053] 1. Small sample size: Need to be able to cope with the detection needs of some rare diseases with small sample sizes

[0054] 2. Real-time performance: In order to reduce losses in the actual production process, decisions should be made as quickly and promptly as possible, which requires the model to have good real-time performance.

[0055] 3. Overcoming environmental interference: The actual detection environment contains interference from complex backgrounds, which leads to a decrease in the accuracy of disease recognition. The model should be able to shield or suppress the interference of irrelevant features as much as possible.

[0056] 4. High robustness: Image data in the application process usually contains noise and defects, and the model needs good robustness to maintain stable operation.

[0057] A leafy vegetable disease detection method based on few-shot learning and prototype attention includes the following steps:

[0058] S1, choose Figure 2 The data set samples shown in the figure have three preprocessing and enhancement methods, including image shear blending, blending enhancement, and random occlusion operations.

[0059] Among them, shear blending enhances the model's ability to learn local features by pasting a local rectangular area in one image into another image; blending enhancement blends two images and their corresponding labels in a specific proportion to improve the model's robustness to blurred boundaries and incorrectly labeled samples; random occlusion randomly occludes a rectangular area in the image to simulate an occlusion scene, thereby enhancing the model's ability to learn multi-region features.

[0060] Data augmentation is used to preprocess image data, improve the generalization ability of the model, reduce overfitting, and solve the problem of data scarcity.

[0061] S2, extract multi-scale features from the image;

[0062] like Figure 3 As shown in the figure, ResNet-50 is used as the backbone network for feature extraction in the ProtoVegNet model to perform multi-scale feature extraction. The features extracted by ResNet-50 retain the detailed information and high-level semantic information in the image, ensuring that the model can process diseased areas of different scales. The specific process is as follows:

[0063] The preprocessed image is fed into the ProtoVegNet model, which includes input image processing, multi-scale feature extraction, feature projection, positional embedding, Transformer encoder, class-agnostic foreground prediction, token selection and prediction, and final prediction.

[0064] ResNet-50 uses multiple layers of 3×3 convolution kernels and stride 2 convolution operations to gradually downsample the image and generate multi-level feature maps. The resolution of the feature maps is gradually reduced to H / 32×W / 32, H / 32×W / 32, H / 16×W / 16, H / 16×W / 16, H / 8×W / 8, and H / 4×W / 4, while the number of channels is fixed at 256.

[0065] Finally, a multi-scale feature map is generated to capture the diversity and complexity of leafy vegetable diseases, including lesions of different sizes, shapes, and colors.

[0066] S3. Use the Transformer encoder for global semantic modeling. The specific process is as follows:

[0067] The multi-scale features extracted from S2 are fed into the Transformer encoder, which captures the global features of the input image and uses the self-attention mechanism to model the long-distance dependencies between features. The encoder consists of N stacked layers, each of which uses the attention mechanism and feedforward network to model the global context information of the input features.

[0068] The decoder generates features rich in global context information and outputs a globally perceived feature map containing deep semantic information and spatial relationships of the diseased area.

[0069] Positional embedding information is added to each layer of feature maps to preserve spatial location information, ensuring accurate localization of disease features for subsequent tasks. After multi-scale feature extraction, the prototype extraction module in the ProtoVegNet model is used to extract category prototypes from the feature maps. These category prototypes serve as global representations of the categories, helping the model focus on the core features of the diseased area.

[0070] like Figure 4 As shown in Figure 2, the prototype extraction module extracts the category prototype from the feature map. The specific process is as follows:

[0071] The multi-scale feature maps output from the ResNet-50 backbone network and the Transformer encoder are used as input to perform dimensionality reduction on the input high-dimensional feature maps, reducing the feature dimensions while retaining important semantic information, simplifying calculations and reducing redundant features.

[0072] Calculate the attention weight matrix in combination with the category prototype: Use the category prototype and the embedding of each pixel or feature point in the input feature map to calculate the similarity. The correlation result is normalized by the Softmax operation to generate the attention weight matrix, which represents the response strength of each feature point to each category.

[0073] The prototype attention mechanism is used to weight the original feature map, and the feature areas with high similarity to the category prototype (i.e., diseased areas) are given higher weights to enhance the response while suppressing background interference.

[0074] A clustering algorithm is used to group features belonging to the same category in the feature map. The resulting vector is then output as a low-dimensional, global representation that summarizes the core features of the category, known as the category prototype. The center of each group, or the mean vector, is calculated as the category prototype for that category.

[0075] The prototype extraction module generates corresponding prototype vectors for each category. These prototype vectors serve as the input of the subsequent attention mechanism, and the enhanced feature maps are input into the target detection and semantic segmentation submodules.

[0076] S4. Perform target detection and semantic segmentation using the target detection submodule and the semantic segmentation submodule. The target detection submodule includes a foreground predictor, a classifier, and a bounding box predictor, which are respectively used to determine which areas in the image contain diseases, classify the foreground areas, and extract the bounding boxes of the diseased areas. The semantic segmentation submodule includes a mask predictor, which is used to generate a segmentation mask for the diseased area.

[0077] S4 specifically includes the following steps:

[0078] S41. In the global features, the foreground predictor in the object detection submodule selects the top k most significant feature points. These feature points represent potential disease areas. The classifier then predicts the category of the selected significant feature points to identify the disease type. The bounding box predictor regresses the bounding box coordinates of the disease area.

[0079] S42. In the semantic segmentation submodule, the mask predictor generates a pixel-level segmentation mask for the diseased area based on multi-scale features;

[0080] S43, upsampling the segmentation mask back to the resolution of the original image through the upsampling module to accurately locate the diseased area;

[0081] S44: Output the detection and classification results, pixel-level segmentation mask, and bounding box of the diseased area.

[0082] S5. Few-shot optimization and fine-tuning. The specific process is as follows:

[0083] like Figure 1 As shown in the figure, the specific flow chart of the ProtoVegNet model includes two stages: basic model training stage (stage 1) and new category fine-tuning stage (stage 2);

[0084] Phase 1:

[0085] First, train the base model, train the backbone network and dual-task module on the enhanced dataset, and process standard categories;

[0086] That is, a ResNet-50 backbone is used to extract multi-scale features from the input image and generate global context features. The object detection submodule and semantic segmentation submodule consist of a foreground predictor, a classifier, a mask predictor, and a bounding box predictor.

[0087] Phase 2:

[0088] Then, we fine-tune the new categories and use the ProtoVegNet model to generate pseudo labels through the attention mechanism to provide additional supervision signals for the few-shot data.

[0089] The ProtoVegNet model introduces knowledge distillation during the fine-tuning process to extract knowledge from the base model to guide the training of the current model to optimize the feature expression of new category data while maintaining the detection performance of the base model for the original category.

[0090] Specifically, the model is further optimized under the condition of few sample data to improve its adaptability and generalization ability to new categories. The present invention uses attention-guided pseudo-label generation (Attention-Guided Pseudo-Label Generation), utilizes the existing feature extraction capability of the model, and generates high-quality pseudo-labels through the attention mechanism to provide additional supervision signals for few-sample data. The ProtoVegNet model introduces knowledge distillation (Knowledge Distillation) during the fine-tuning process. Knowledge is extracted from the base model (teacher model) to guide the training of the current model (student model) to optimize the feature expression of new category data while maintaining the detection performance of the base model for the original category. Fine-tune the new category: The ProtoVegNet model uses a small amount of sample data of the new category to fine-tune the model through pseudo-labels and knowledge distillation methods. Strengthen the model's adaptability and generalization ability to new categories, so that it can still maintain high accuracy in few-sample scenarios. At the same time, the global representation ability of the category prototype enables the model to accurately capture disease characteristics even in few-sample situations, thereby improving the robustness and generalization of the model.

[0091] Outputs the disease category and its corresponding bounding box for localization. Outputs a fine-grained segmentation mask of the diseased area. Deployment considerations optimize real-time inference capabilities for practical agricultural applications. Enable efficient disease management in resource-constrained environments with diverse planting conditions.

[0092] Therefore, the present invention adopts the above-mentioned leafy vegetable disease detection method based on few-sample learning and prototype attention. By introducing the few-sample learning and prototype attention mechanism, it meets the urgent needs of modern agriculture for efficient, accurate and intelligent disease detection methods. Through the above steps, it effectively solves the problems of few samples and complex background in leafy vegetable disease detection, broadens the scope of application of the model, and at the same time ensures high detection accuracy and high robustness.

[0093] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit the same. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that they can still modify or replace the technical solutions of the present invention with equivalents, and these modifications or equivalent replacements cannot cause the modified technical solutions to deviate from the spirit and scope of the technical solutions of the present invention.

Claims

1. A leafy vegetable disease detection method based on few-shot learning and prototype attention, characterized in that: The following steps are involved: S1. Preprocess and enhance the data; S2. In the ProtoVegNet model, ResNet-50 is used as the backbone network for feature extraction to perform multi-scale feature extraction; S3, using Transformer encoder for global semantic modeling; S4, object detection and semantic segmentation; S5, few-shot optimization and fine-tuning; In S3, position embedding information is added to each layer of feature maps to retain spatial location information and ensure the correct positioning of disease features. After multi-scale feature extraction, the prototype extraction module in the ProtoVegNet model is used to extract category prototypes from the feature maps. The category prototypes serve as the global representation of the category. The prototype extraction module extracts the category prototype from the feature map. The specific process is as follows: The multi-scale feature maps output by the ResNet-50 backbone network and the Transformer encoder are used as input to perform dimensionality reduction on the input high-dimensional feature maps; Calculate the attention weight matrix based on the category prototype: Use the category prototype and the embedding of each pixel or feature point in the input feature map to calculate the similarity. The correlation result is normalized by the Softmax operation to generate the attention weight matrix, which represents the response strength of each feature point to each category. The prototype attention mechanism is used to weight the original feature map. Feature areas with high similarity to the category prototype are given higher weights, which enhances the response while suppressing background interference. The features belonging to the same category in the feature map are grouped by a clustering algorithm, and then output as a low-dimensional, global representation vector. This vector is used to summarize the core features of the category, that is, the category prototype. The center of each group, that is, the mean vector is calculated as the category prototype of the category; The prototype extraction module generates a corresponding prototype vector for each category. The prototype vector serves as the input of the attention mechanism. The enhanced feature map is input into the object detection and semantic segmentation submodules. In S4, target detection and semantic segmentation are performed using the target detection submodule and the semantic segmentation submodule. The target detection submodule includes a foreground predictor, a classifier, and a bounding box predictor, which are respectively used to determine which areas in the image contain diseases, classify the foreground areas, and extract the bounding boxes of the diseased areas. The semantic segmentation submodule includes a mask predictor, which is used to generate a segmentation mask for the diseased area. The specific process of S5 is as follows: First, train the base model, train the backbone network and dual-task module on the enhanced dataset, and process standard categories; Then, we fine-tune the new categories and use the ProtoVegNet model to generate pseudo labels through the attention mechanism to provide additional supervision signals for the few-shot data. The ProtoVegNet model introduces knowledge distillation during the fine-tuning process to extract knowledge from the base model to guide the training of the current model to optimize the feature expression of new category data while maintaining the detection performance of the base model for the original category.

2. The leafy vegetable disease detection method based on few-shot learning and prototype attention according to claim 1, characterized in that: In S1, data preprocessing and enhancement include shear blending, blending enhancement, and random occlusion operations on the image; Among them, shear blending is performed by pasting a local rectangular area in one image into another image, blending enhancement is performed by blending two images and their corresponding labels in a specific proportion, and random occlusion is performed by randomly occluding a rectangular area in the image to simulate the occlusion scene.

3. The leafy vegetable disease detection method based on few-shot learning and prototype attention according to claim 2, characterized in that: The specific process of S2 is as follows: ResNet-50 uses multiple layers of 3×3 convolution kernels and stride 2 convolution operations to gradually downsample the image and generate multi-level feature maps. The resolution of the feature maps is gradually reduced to H / 32×W / 32, H / 32×W / 32, H / 16×W / 16, H / 16×W / 16, H / 8×W / 8, and H / 4×W / 4, and the number of channels is fixed at 256. Finally, a multi-scale feature map is generated to capture the diversity and complexity of leafy vegetable diseases, including lesions of different sizes, shapes, and colors.

4. The leafy vegetable disease detection method based on few-shot learning and prototype attention according to claim 3, characterized in that: The specific process of S3 is: The multi-scale features extracted from S2 are fed into the Transformer encoder, which captures the global features of the input image and uses the self-attention mechanism to model the long-distance dependencies between features. N It is composed of stacked layers, and each layer uses attention mechanism and feedforward network to model the global context information of input features; The decoder generates features rich in global context information and outputs a globally perceived feature map containing deep semantic information and spatial relationships of the diseased area.

5. The leafy vegetable disease detection method based on few-shot learning and prototype attention according to claim 4, characterized in that: S4 specifically includes the following steps: S41. In the global features, the foreground predictor in the target detection submodule selects the foreground The most significant feature points represent potential disease areas. The classifier then predicts the category of the selected significant feature points to identify the disease type, and the bounding box predictor regresses the bounding box coordinates of the disease area. S42. In the semantic segmentation submodule, the mask predictor generates a pixel-level segmentation mask for the diseased area based on multi-scale features; S43, upsampling the segmentation mask back to the resolution of the original image through an upsampling module to accurately locate the diseased area; S44: Output the detection and classification results, pixel-level segmentation mask, and bounding box of the diseased area.