Vegetable leaf lesion image labeling method based on meta-transfer small sample learning
By employing a meta-transfer few-shot learning method, combining transfer learning and meta-learning, separating network weights and using a task memory for training, the problems of overfitting and lesion localization bias in vegetable leaf lesion image annotation are solved, achieving high-quality automatic pre-annotation and continuous iterative optimization.
Patent Information
- Application Number
- CN202611338407.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-31
- Publication Date
- 2026-11-24
AI Technical Summary
Existing technologies lack high-quality automatic pre-labeling schemes suitable for a small number of initial labeled samples in the annotation of vegetable leaf lesion images. Conventional model automatic annotation is prone to overfitting, large deviation in lesion localization, and confusion of similar diseases, and lacks a continuous iterative optimization mechanism.
The meta-transfer few-shot learning method combines transfer learning with meta-learning. By pre-training the backbone network on the source domain dataset, separating the generalization weights and task-sensitive weights, and using the task memory for meta-transfer learning training, the automatic pre-labeling of vegetable leaf lesion images is achieved. The model knowledge is updated through manual verification and sample feedback, forming a closed-loop iterative optimization.
High-quality automatic annotation of vegetable leaf lesion images was achieved with a small number of labeled samples, reducing overfitting and lesion localization bias, improving the model's generalization ability and disease identification accuracy, and supporting the continuous iterative construction of the dataset.
Smart Images

Figure CN123160852A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of computer vision and smart agriculture technology, and in particular to a method for annotating vegetable leaf lesion images based on meta-transfer few-shot learning. Background Technology
[0002] In greenhouse vegetable cultivation, the high incidence of foliar diseases directly impacts vegetable yield and quality. Deep learning-based intelligent identification technology for vegetable diseases is a crucial means of achieving precision plant protection management; however, training deep learning models heavily relies on a large dataset of precisely labeled lesion images.
[0003] Conventional automatic annotation schemes rely on sufficient labeled samples. Object detection and instance segmentation models require a large number of labeled samples for stable training. In the early stages of a new project, only a small number of labeled vegetable disease samples can be obtained. Directly training the model is prone to severe overfitting, and the automatic annotation results show significant mislabeling and omissions, failing to meet the requirements for dataset construction.
[0004] Existing research in the agricultural field largely focuses on disease image recognition or classification, failing to establish a complete annotation workflow for dataset construction. The few existing automatic agricultural image annotation solutions mostly employ a combination of ordinary transfer learning and active learning frameworks, reusing only general visual features. When the target task involves small sample sizes, spans multiple vegetable varieties, or covers multiple disease types, domain shift issues become significant, the model's generalization ability is insufficient, and it is highly prone to confusing lesions from different diseases with similar features.
[0005] Classic meta-learning algorithms, such as Model-Agnostic Meta-Learning (MAML), employ a globally uniform parameter initialization strategy, failing to fully utilize the domain prior knowledge of publicly available crop disease datasets. Using meta-learning alone for lesion identification tasks results in insufficient stability for fine-tuning under small sample conditions.
[0006] In summary, existing technologies lack a technical solution that is adapted to the scenario of leaf lesions on vegetables and can achieve high-quality automatic pre-labeling under the condition of a small number of initial labeled samples. Summary of the Invention
[0007] This invention provides a method for labeling vegetable leaf lesion images based on meta-transfer few-shot learning, which solves the technical problems of overfitting of conventional models, large deviation in lesion localization, and easy confusion of similar diseases in scenarios where the number of initial labeled samples is scarce.
[0008] This invention provides a method for annotating vegetable leaf lesion images based on meta-transfer few-shot learning, comprising the following steps: The vegetable leaf image set is divided into a support set and a sample set to be labeled. The support set contains manually labeled images, and the sample set to be labeled contains unlabeled vegetable leaf images. Based on the source domain dataset, the backbone network is pre-trained by transfer learning to obtain the pre-trained network parameters, which include generalization weights and task-sensitive weights. Multiple simulated subtasks are constructed based on the support set, and meta-transfer learning training is performed on the backbone network based on the multiple simulated subtasks to obtain a meta-transfer basic model; the meta-transfer learning training includes: under the condition that the generalization weights are frozen, using the task memory to retrieve the matching task-sensitive weights as the initialization parameters of the backbone network, updating the task-sensitive weights, and storing the updated task-sensitive weights in the task memory. The meta-transfer model is used to perform first-level inference on the sample set to be labeled to obtain vegetable category discrimination results; based on the vegetable category discrimination results, the corresponding task-sensitive weights are retrieved from the task memory and loaded onto the meta-transfer model to perform second-level inference to obtain pre-labeling results.
[0009] In one embodiment, the meta-transfer learning training includes: For each simulation subtask, perform the following steps, and after iterating through all simulation subtasks, obtain the meta-transfer base model: Extract the current task representation vector of the current simulation subtask; A task memory bank is constructed, which stores multiple historical task data. Each historical task data includes a historical task representation vector and a corresponding historical task sensitivity weight. The task memory is retrieved using the current task representation vector, and the matching historical task sensitivity weights are used as initialization parameters for the backbone network. Under the condition of freezing the generalization weights, update the task-sensitive weights and store the current task representation vector and the updated task-sensitive weights into the task memory.
[0010] In one embodiment, the update task-sensitive weights include: The samples obtained from the current simulated subtask are input into the backbone network to obtain the predicted classification result and predicted localization result for each sample. The classification loss of lesion and disease category is calculated based on the predicted classification results and the actual classification labels of each sample, and the location loss of lesion bounding box is calculated based on the predicted location results and the actual location labels of each sample. The total loss is determined based on the loss from the classification of lesion and disease categories and the loss from the location of lesion bounding boxes. The task-sensitive weights are updated based on backpropagation of the total loss.
[0011] In one embodiment, the overall optimization objective of the meta-transfer learning training is to minimize the expected loss of the simulated subtasks sampled from the task distribution.
[0012] In one embodiment, the method further includes: For samples in the pre-labeling results that meet preset conditions, a manual correction instruction is received, and the samples are corrected according to the manual correction instruction to obtain manually verified labeled samples. The manually verified labeled samples are incorporated into the support set to obtain an updated support set. The meta-transfer learning training is then re-executed based on the updated support set, and the task-sensitive weights stored in the task memory are updated.
[0013] In one embodiment, the method further includes: The vegetable leaf image set was subjected to size normalization and noise reduction processing to obtain a preprocessed image set; The preprocessed image set is divided into the support set and the unlabeled sample set, and online data augmentation is performed on the images in the support set and the unlabeled sample set. The online data augmentation includes at least one of random flipping, color perturbation and contrast adjustment.
[0014] In one embodiment, the method further includes, before inputting the image into the backbone network: The edge feature map of the image is extracted, and the edge feature map is fused with the RGB three-channel data of the image to obtain fused image data. The fused image data is used as the input of the backbone network.
[0015] The present invention also provides a vegetable leaf lesion image annotation device based on meta-transfer few-shot learning, comprising the following modules: The image acquisition and processing module is used to divide the vegetable leaf image set into a support set and a sample set to be labeled. The support set contains manually labeled images, and the sample set to be labeled contains unlabeled vegetable leaf images. The transfer pre-training module is used to perform transfer pre-training on the backbone network based on the source domain dataset to obtain the pre-trained network parameters, which include generalization weights and task-sensitive weights. The meta-transfer learning training module is used to construct multiple simulated subtasks based on the support set, and perform meta-transfer learning training on the backbone network based on the multiple simulated subtasks to obtain a meta-transfer basic model; the meta-transfer learning training includes: under the condition that the generalization weights are frozen, using the task memory to retrieve the matching task-sensitive weights as the initialization parameters of the backbone network, updating the task-sensitive weights, and storing the updated task-sensitive weights into the task memory. The step-by-step lesion labeling and reasoning module is used to perform first-level reasoning on the sample set to be labeled using the meta-transfer basic model to obtain vegetable category discrimination results; based on the vegetable category discrimination results, the corresponding task-sensitive weights are retrieved from the task memory and loaded onto the meta-transfer basic model to perform second-level reasoning to obtain pre-labeling results.
[0016] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the vegetable leaf lesion image annotation method based on meta-transfer few-shot learning as described above.
[0017] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the vegetable leaf lesion image annotation method based on meta-transfer few-shot learning as described above.
[0018] The present invention provides a method for labeling vegetable leaf lesion images based on meta-transfer few-shot learning. First, the backbone network is pre-trained on the source domain dataset, enabling it to learn general visual features in advance. After pre-training, the network parameters are split into generalization weights and task-sensitive weights, with the generalization weights permanently frozen. Subsequent meta-transfer learning training only optimizes the task-sensitive weights. Since the generalization weights do not participate in target domain training, only a small number of labeled samples in the target domain need to learn disease-specific lesion features, reducing the actual number of parameters optimized and thus suppressing overfitting.
[0019] In meta-transfer learning training, this invention utilizes task-sensitive weights retrieved from the task memory as initialization parameters for the backbone network, ensuring the model has a good initial state when adapting to new diseases. Under the condition of frozen generalization weights, the task-sensitive weights are updated to ensure that lesion feature learning focuses on task-sensitive parameters. By updating the task-sensitive weights, the output includes pre-labeled results containing bounding boxes, thus improving lesion localization bias.
[0020] This invention uses a meta-transfer model to determine the vegetable category of the current image through first-level inference, limiting the recognition scope to a specific vegetable category. The second-level inference retrieves the corresponding task-sensitive weights from the task memory based on the vegetable category determination result and loads them onto the meta-transfer model to perform lesion detection. This ensures that the model only makes distinctions in the disease feature space of the same vegetable category, avoiding mutual interference of leaf texture features of different vegetable categories and reducing confusion between lesions of different diseases with similar features.
[0021] Furthermore, this invention utilizes a task memory storage and retrieval mechanism to allow the optimal weights of historical disease tasks to be reused in subsequent tasks. In the second-level inference, based on the vegetable category discrimination results, the corresponding task-sensitive weights are retrieved from the task memory and loaded onto the meta-transfer model. This enables the model to leverage knowledge from historically similar tasks during inference, allowing for labeling without retraining and further alleviating the problem of insufficient discrimination criteria under small sample conditions. Attached Figure Description
[0022] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0023] Figure 1 This is a flowchart illustrating the method for annotating vegetable leaf lesion images based on meta-transfer few-shot learning provided by the present invention.
[0024] Figure 2 This is a schematic diagram of the backbone network weight decomposition provided by the present invention.
[0025] Figure 3 This is a schematic diagram of the meta-transfer learning training process provided by the present invention.
[0026] Figure 4 This is a flowchart of the multi-level step-by-step automatic pre-labeling reasoning process for lesions provided by the present invention.
[0027] Figure 5 This is a schematic diagram of the structure of the vegetable leaf lesion image annotation device based on meta-transfer few-shot learning provided by the present invention.
[0028] Figure 6 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0029] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0030] There are currently many practical challenges in the annotation of images of lesions on vegetable leaves.
[0031] First, traditional manual annotation methods are costly and inefficient. Vegetables are diverse, and diseases are complex. Leaves often have multiple diseases coexisting, lesion sizes vary greatly, and there is uneven lighting in the field and interference from background weeds. Annotators need to have agricultural expertise to distinguish lesions that look similar. Manually selecting and classifying each image is extremely time-consuming, and the construction of large-scale datasets takes a long time.
[0032] Secondly, conventional automatic annotation schemes rely on sufficient labeled samples. Object detection and instance segmentation models require a large number of labeled samples for stable training. In the early stages of a new project, only a small number of labeled vegetable disease samples can be obtained. Directly training the model is prone to severe overfitting, and the automatic annotation results show significant mislabeling and omissions, failing to meet the requirements for dataset construction.
[0033] Furthermore, existing research in the agricultural field exhibits a clear technological fragmentation: while numerous publications disclose transfer learning, meta-learning, weight decomposition, and task-memory few-sample algorithms, the current research largely remains at the level of disease image recognition or classification, failing to establish a complete annotation workflow for dataset construction. Existing automatic agricultural image annotation solutions mostly employ ordinary transfer learning combined with active learning frameworks, merely reusing general visual features. When the target task involves small sample scenarios, spans multiple vegetable varieties, or crosses different disease types, domain shift issues become significant, model generalization ability is insufficient, and it is highly prone to confusing lesions from different diseases with similar features.
[0034] Finally, classic meta-learning algorithms such as MAML employ a globally uniform parameter initialization strategy, failing to fully utilize the domain prior knowledge of publicly available crop disease datasets. Using meta-learning alone for lesion identification tasks results in slow model convergence and insufficient stability for fine-tuning under small sample conditions. Existing technologies typically use transfer learning and meta-learning independently, lacking a meta-transfer framework that organically integrates the two; furthermore, they lack a mechanism for the continuous reuse of task knowledge for vegetable lesion tasks, requiring retraining from scratch each time a new vegetable disease category is added.
[0035] Furthermore, existing small-sample image recognition schemes generally use a single model to identify all vegetable types and disease types at once, which leads to cross-crop feature interference and further exacerbates the problem of misidentification of similar lesions; and there is no continuous learning closed loop of "model prediction and pre-labeling - manual verification - labeled sample feedback to update model knowledge", which cannot meet the long-term iterative construction needs of agricultural datasets.
[0036] In summary, existing technologies lack an integrated technical solution that is adapted to the scenario of leaf lesions on vegetables, can achieve high-quality automatic pre-labeling with a small number of initial labeled samples, and supports continuous iterative optimization.
[0037] Based on this, the present invention proposes a method for annotating vegetable leaf lesion images based on meta-transfer few-shot learning.
[0038] Meta-transfer learning refers to a training method that combines transfer learning and meta-learning. Transfer learning pre-trains the backbone network on the source domain dataset, enabling the backbone network to acquire general leaf visual features; meta-learning trains the backbone network by constructing a large number of simulated small-sample tasks, enabling the backbone network to quickly adapt to new disease tasks. The combination of the two constitutes meta-transfer learning training, giving the model both prior visual knowledge of agricultural disease images and the ability to quickly adapt to new diseases under small-sample conditions.
[0039] Few-shot learning refers to a learning method that trains and optimizes a model under conditions with only a small number of labeled samples. In this invention, the support set contains only a small number of manually labeled images. Meta-transfer learning training simulates real-world few-shot scenarios by constructing an N-way K-shot simulated subtask, enabling the model to quickly adapt to new diseases under conditions with a small number of samples.
[0040] Vegetable leaf lesion image annotation refers to labeling lesion regions in vegetable leaf images, including lesion location bounding boxes and disease category labels. The annotation results are used to construct a vegetable disease image dataset, providing labeled training samples for deep learning models.
[0041] The method of this invention refers to obtaining a meta-transfer base model through meta-transfer learning under the condition of only a small number of initially labeled samples. This model is then used to automatically pre-label a large number of unlabeled vegetable leaf images, outputting pre-labeled results including bounding boxes of lesion locations and disease category labels, thus achieving automatic labeling of vegetable leaf lesion images. After manual verification, the labeled samples are fed back to update the model, gradually improving the labeling effect.
[0042] like Figure 1 As shown, the method includes the following: S110. Divide the vegetable leaf image set into a support set and a sample set to be labeled, wherein the support set contains manually labeled images and the sample set to be labeled contains unlabeled vegetable leaf images. A set of vegetable leaf images is acquired, comprising images of healthy leaves, images of leaves with a single disease, and images of leaves with multiple coexisting diseases. Specifically, healthy leaf images refer to leaves without any lesions on their surface; images of leaves with a single disease refer to leaves with only one type of disease lesion on their surface; and images of leaves with multiple coexisting diseases refer to leaves with two or more types of disease lesions on the same surface. These three types of images together constitute a raw image set covering the diversity of actual field scenes.
[0043] A subset of images is selected from the vegetable leaf image set. Annotators precisely label the lesion areas in these images, including bounding boxes for the lesion locations and disease category labels. These manually annotated images constitute the support set. The support set provides labeled training samples for subsequent meta-transfer learning training (S130). The remaining unlabeled images in the vegetable leaf image set constitute the unlabeled sample set, which is the target of the automatic pre-labeling process of this invention (S140).
[0044] S120. Based on the source domain dataset, perform transfer pre-training on the backbone network to obtain the pre-trained network parameters, which include generalization weights and task-sensitive weights.
[0045] A lightweight feature extraction backbone network is selected, which can be any of MobileNetV3, EfficientNet-B3, or DenseNet201. The backbone network extracts features from the input image, and its output is a high-dimensional feature map of the image. The input image refers to a preprocessed image of vegetable leaves. During the meta-transfer learning training stage, the input image is from the support set; during the multi-level step-by-step inference stage, the input image is from the unlabeled sample set.
[0046] Reference Figure 2 As shown, the network parameters of the backbone network Includes generalization weights and task-sensitive weights , Generalization weights These parameters, corresponding to the backbone network's functions of extracting general visual features, are used to store common visual features such as leaf edges, textures, and colors, and correspond to the shallow convolutional layers of the backbone network. Task-sensitive weights. The parameters in the backbone network responsible for extracting disease-specific lesion features, along with all parameters in the task head, are used to learn the disease-specific lesion features of different vegetables. These correspond to the deep feature fusion layer of the backbone network and the task head connected to it. Disease-specific lesion features refer to the visual characteristics of different vegetable diseases, such as lesion shape, and are the core criterion for distinguishing different diseases. The task head contains a classification branch and a localization branch, used to output the disease category and bounding box location, respectively. The parameters in the task head are task-sensitive weights. Part of it.
[0047] The source domain dataset mentioned above can be the publicly available crop disease dataset from PlantVillage. The backbone network is then pre-trained on this publicly available crop disease dataset using transfer learning. The optimal parameter combination is solved during the pre-training phase. ; in, The source domain image is used as the input to the backbone network. for Corresponding actual disease category labels; Indicates and Backbone network pairs with parameters The prediction results; This is the loss function used in the pre-training phase to measure the error between the prediction results of the backbone network and the true disease category labels. Indicates the search for Minimized and , respectively denoted as .
[0048] After pre-training, generalization weights Permanently frozen and will not participate in any subsequent parameter updates; task-sensitive weight. Its value is retained, allowing iterative updates in subsequent meta-transfer learning training.
[0049] S130. Construct multiple simulated subtasks based on the support set, and perform meta-transfer learning training on the backbone network based on the multiple simulated subtasks to obtain a meta-transfer basic model; the meta-transfer learning training includes: under the condition that the generalization weights are frozen, using the task memory to retrieve the matching task-sensitive weights as the initialization parameters of the backbone network, updating the task-sensitive weights, and storing the updated task-sensitive weights in the task memory.
[0050] The purpose of meta-transfer learning training is to enable the backbone network to quickly adapt to new diseases using a small number of labeled samples. Under the condition of frozen generalization weights, matching task-sensitive weights are retrieved from the task memory and used as the initialization parameters of the backbone network. Meta-transfer learning training is then performed on the backbone network based on multiple simulated sub-tasks constructed from the support set. The task-sensitive weights are updated and stored in the task memory. After iterative training through multiple simulated sub-tasks, the meta-transfer base model is obtained. The meta-transfer base model consists of the backbone network and the task head. The task head contains a classification branch and a localization branch, used to output the disease category and bounding box location, respectively. The simulated sub-tasks, specifically vegetable disease sub-tasks, refer to small-sample learning tasks constructed from random samples of the support set to simulate real-world disease identification scenarios.
[0051] In this step, the task memory is used to store historical task data. Each historical task data includes a task representation vector and the corresponding task-sensitive weights. The simulated subtasks are training tasks constructed from support set sampling to simulate real disease identification scenarios. Meta-transfer learning training enables the backbone network to quickly adapt to new diseases through the iterative iteration of a large number of simulated subtasks. The task-sensitive weights are updated and stored in the task memory in each iteration for reuse in subsequent task retrieval.
[0052] S140. The meta-transfer model is used to perform first-level inference on the sample set to be labeled to obtain vegetable category discrimination results; based on the vegetable category discrimination results, the corresponding task-sensitive weights are retrieved from the task memory and loaded onto the meta-transfer model to perform second-level inference to obtain pre-labeling results.
[0053] The multi-level step-by-step inference employs a two-level inference strategy to reduce feature interference across vegetable categories. The first level of inference is a coarse classification of vegetable categories. The meta-transfer base model can include a vegetable classifier. After the images in the sample set to be labeled are input into the model, the vegetable classifier in the model performs the first level of inference and outputs the vegetable category to which the current image belongs, such as tomato, cucumber, and pepper, thus obtaining the vegetable category discrimination result. The vegetable classifier can be implemented using any existing image classification model, such as a classification model based on a convolutional neural network. This invention does not limit the specific structure of the vegetable classifier, as long as it can achieve the discrimination of vegetable categories in the images in the sample set to be labeled.
[0054] The second level of inference is lesion detection. Based on the vegetable category classification results obtained from the first level of inference, the task-sensitive weights corresponding to that vegetable category are retrieved from the task memory. These retrieved task-sensitive weights are then loaded onto the meta-transfer base model, specifically onto the deep feature fusion layer and task head of the backbone network, replacing the task-sensitive weights in the model, while the generalization weights remain frozen. After loading, the meta-transfer base model performs the second level of inference on the images in the unlabeled sample set, outputting lesion location bounding boxes and disease category labels, generating pre-labeled results. A confidence threshold is set during the automatic pre-labeling inference process. When the confidence of the pre-labeled results is higher than the threshold, they are directly saved into the database; otherwise, they are prioritized for manual review.
[0055] In one embodiment, the method further includes: S150. Receive manual correction instructions for samples that meet preset conditions in the pre-labeled results, correct the samples according to the manual correction instructions, and obtain manually verified labeled samples; merge the manually verified labeled samples into the support set to obtain an updated support set, re-execute the meta-transfer learning training based on the updated support set, and update the task-sensitive weights stored in the task memory.
[0056] Specifically, a visual interface displays the original image of vegetable leaves and automatically generated pre-annotated bounding boxes, which are then manually verified by operators. The visual interface overlays the pre-annotation results output in step S140 onto the original vegetable leaf image. Based on this visual display, operators review the pre-annotation results output by the meta-transfer model. For missing targets, operators use the interface tools to add annotation boxes and specify the disease category; for incorrectly labeled categories, operators use the interface tools to correct the incorrect categories to the correct disease categories; for inaccurately located bounding boxes, operators use the interface tools to adjust the position and size of the bounding boxes to align them with the edges of the actual lesions. After these manual correction operations are completed, manually verified annotated samples are obtained.
[0057] The manually verified labeled samples are incorporated into the support set to obtain an updated support set. Since the support set is the set of labeled images constructed in step S110 for meta-transfer learning training, incorporating the manually verified labeled samples expands both the number of samples and the coverage of disease categories in the support set. A new simulation subtask is constructed based on the updated support set, and the meta-transfer learning training in step S130 is re-executed. The task-sensitive weights stored in the task memory are updated using the new simulation subtask, enabling subsequent inference to reuse the knowledge from the newly added high-quality labeled samples.
[0058] Steps S130 to S150 are executed repeatedly. As high-quality labeled samples are continuously accumulated, the scale of the support set continues to expand, the task-sensitive weights stored in the task memory are continuously updated and optimized, and the accuracy of automatic pre-labeling of the meta-transfer base model in the subsequent step S140 gradually improves. The verification workload of operators continues to decrease until the dataset size and labeling accuracy meet the preset requirements.
[0059] This invention incorporates manually verified labeled samples into the support set, resulting in an updated support set. The updated support set includes images from the original support set as well as manually verified labeled samples, expanding both the number of samples and the coverage of disease categories. Meta-transfer learning training is then re-executed based on the updated support set. New simulated subtasks are used to update the task-sensitive weights stored in the task memory, transforming operator corrections to pre-labeling results into changes in these weights. The updated task-sensitive weights stored in the task memory are retrieved and loaded into the meta-transfer base model during subsequent inference, reducing the recurrence of similar errors in subsequent automatic pre-labeling and achieving a continuous improvement in labeling accuracy.
[0060] This invention employs a closed-loop process of pre-annotation, manual verification, sample re-implementation, and model updating, enabling the meta-transfer learning model to gradually approach a better parameter state in each iteration. Errors in the pre-annotation results directly reflect the current insufficient discriminative ability of the meta-transfer learning model. Reusing manually corrected samples for meta-transfer learning training directly compensates for the model's discriminative deficiencies on these types of samples. The task-sensitive weights stored in the task memory are continuously updated with each iteration, accumulating historical task knowledge and gradually enhancing the meta-transfer learning model's disease discrimination ability. Through this process, as annotation work continues, the workload of operators decreases while the annotation quality increases, making this invention suitable for constructing large-scale vegetable disease image datasets requiring long-term iterative development.
[0061] In one embodiment, the method further includes: S1101. Perform size normalization and noise reduction processing on the vegetable leaf image set to obtain a preprocessed image set.
[0062] Size normalization adjusts vegetable leaf images of different resolutions to the same size, eliminating image size differences caused by different acquisition devices or acquisition distances. Noise reduction employs Gaussian filtering to suppress noise interference in the images.
[0063] S1102. Divide the preprocessed image set into the support set and the unlabeled sample set, and perform online data augmentation on the images in the support set and the unlabeled sample set.
[0064] The preprocessed image set is divided into a support set and a sample set to be labeled. The support set consists of manually annotated images selected from the preprocessed image set, each image containing bounding boxes of lesion locations and disease category labels. The sample set to be labeled consists of unlabeled images from the preprocessed image set, excluding the support set. Online data augmentation is performed on the images in both the support set and the sample set to be labeled, resulting in augmented support and augmented sample sets. Online data augmentation includes at least one of random flipping, color perturbation, and contrast adjustment. Random flipping involves horizontally or vertically flipping the image. Color perturbation involves randomly shifting the hue, saturation, and brightness in the image's color space. Contrast adjustment involves randomly scaling the image's contrast value. Online data augmentation is performed dynamically during model training and inference; each image may undergo different augmentation transformations each time it is input, in order to expand the diversity of training samples and improve the model's generalization ability. The enhanced support set is used as the image input for the subsequent meta-transfer learning training step (S130), and the enhanced labeled sample set is used as the image input for the subsequent multi-level step-by-step inference step (S140).
[0065] This invention performs size normalization and noise reduction processing on vegetable leaf images to obtain a preprocessed image set. Size normalization ensures that images acquired from different acquisition devices or distances have uniform size specifications, eliminating the impact of image size differences on backbone network feature extraction and enabling the backbone network to process image data from different sources. Noise reduction uses Gaussian filtering to suppress noise interference in the images, allowing the backbone network to focus on the visual features of the lesions themselves rather than noise, thus improving the stability of backbone network feature extraction. This invention divides the preprocessed image set into a support set and a sample set to be labeled, and performs online data augmentation on the images in both sets. Online data augmentation includes at least one of random flipping, color perturbation, and contrast adjustment. Random flipping allows the backbone network to learn lesion features from different orientations, color perturbation allows the backbone network to adapt to lesion color changes under different lighting conditions, and contrast adjustment allows the backbone network to adapt to lesion boundary features under different image contrasts. Through online data augmentation, the diversity of training samples can be expanded without additional image acquisition, enabling the backbone network to learn richer lesion feature variation patterns with a small number of original samples. The enhanced support set serves as the image input for the meta-transfer learning training step, and the enhanced unlabeled sample set serves as the image input for the multi-level step-by-step inference step. This provides subsequent steps with training data and unlabeled data that have been enriched with diversity, thereby improving the generalization ability of the backbone network under small sample conditions.
[0066] In one embodiment, the method further includes, before inputting the image into the backbone network: The edge feature map of the image is extracted, and the edge feature map is fused with the RGB three-channel data of the image to obtain fused image data. The fused image data is used as the input of the backbone network.
[0067] Specifically, for each image to be input into the backbone network, the Canny edge detection algorithm is used to extract the edge feature map of that image. The Canny edge detection algorithm identifies pixels with drastic grayscale changes by calculating the gradient magnitude and direction at each pixel location in the image, forming continuous edge contours. The edge feature map has the same size as the original image, and each pixel value represents the intensity at which that pixel location belongs to an edge. The edge feature map is presented in grayscale form, where edge regions have higher pixel values and non-edge regions have lower pixel values.
[0068] The edge feature map is fused with the RGB three-channel data of the image to obtain the fused image data. The fused image data consists of the three RGB color channels and one edge feature channel, meaning each pixel location contains red, green, and blue component values, as well as an edge intensity value. The fused image data maintains the spatial resolution of the original image, only expanding the number of channels from 3 to 4. The fused image data is used as input to the backbone network. The first operation of the backbone network for each input image is to receive the fused image data containing RGB color information and edge intensity information; all subsequent feature extraction is performed based on the fused image data.
[0069] This invention extracts edge feature maps from the image before inputting it into the backbone network. The edge feature maps are then fused with the image's RGB three-channel data to obtain fused image data, which is used as the input to the backbone network. The edge detection algorithm identifies pixels with drastic grayscale changes in the image by calculating pixel gradient magnitude and direction, accurately locating the edge contours at the boundary between lesions and healthy tissue. The edge feature maps carry edge intensity information at the lesion boundaries in the image. After fusing the edge feature maps with the RGB three-channel data, the input to the backbone network includes not only color information but also explicit edge information. This allows the backbone network to simultaneously utilize both color and edge channels for feature learning during the shallow feature extraction stage, with the edge feature channels providing the backbone network with location guidance for the lesion contours. With pure RGB input, the backbone network relies solely on color changes to identify lesions. However, in actual field images, the color difference between lesions and healthy leaves may not be significant, especially when the lesions are in the early stages or when lighting conditions are not ideal. Edge feature channels exist independently of color information. Even if the color difference is weak, there are still geometric abrupt changes at the lesion boundary. Edge detection algorithms can capture this abrupt change information and input it into the backbone network as an independent channel. This allows the backbone network to identify lesion boundaries based on edge information even when color information is insufficient, thereby improving lesion localization bias.
[0070] In one embodiment, the formula for constructing multiple simulated subtasks from a support set is as follows: Simulated subtasks are constructed by sampling from the support set according to the N-way K-shot rule. The support set contains images of multiple disease categories, and each disease category contains several images with precise annotations. Each simulated subtask is constructed as follows: N disease categories are randomly selected from all disease categories in the support set, and K samples are randomly selected from each selected disease category. The N selected disease categories and N×K samples constitute the training sample set for a simulated subtask. Here, N and K are preset positive integers, where N represents the number of disease categories in the simulated subtask, and K represents the number of samples selected from each disease category. For example, when N=6 and K=5, each simulated subtask contains 6 disease categories, each disease category contains 5 samples, for a total of 30 samples. Different simulated subtasks are independent of each other, and each simulated subtask is resampled randomly from the support set; therefore, the combinations of disease categories and samples contained in different simulated subtasks are different. This sampling and construction process is repeated to obtain multiple simulated subtasks for meta-transfer learning training.
[0071] The meta-transfer learning training includes: For each simulation subtask, perform the following steps, and after iterating through all simulation subtasks, obtain the meta-transfer base model: S211. Construct the task memory.
[0072] The task memory is initially empty. It stores multiple historical task data entries, specifically historical task data for simulated subtasks that have already been trained. Each historical task data entry contains a historical task representation vector and its corresponding historical task sensitivity weights. The task memory supports fast retrieval based on similarity.
[0073] S212. Extract the current task representation vector of the current simulation subtask.
[0074] The task representation vector is a high-dimensional vector describing the overall characteristics of the simulated subtask. It is generated by inputting images from the current simulated subtask into a backbone network, which outputs a feature map for each image. Global average pooling is performed on each image's feature map to obtain an image-level feature vector. The image-level feature vectors of the same disease category are averaged to obtain the category prototype vector for that disease category. All category prototype vectors are concatenated to form the current task representation vector. Because this vector integrates information from all categories and all samples in the current simulated subtask, it is called the global task representation vector.
[0075] S213. Retrieve the task memory using the current task representation vector, and use the matched historical task sensitivity weights as the initialization parameters of the backbone network.
[0076] Calculate the current task representation vector Compared to each historical task representation vector stored in the task memory. The historical task sensitivity weights corresponding to the historical task representation vectors corresponding to the highest cosine similarity between the two vectors are selected based on the cosine similarity between them. These parameters serve as the initialization parameters for the backbone network in the current simulation subtask.
[0077] ; in, Represents the current task representation vector Compared with historical task representation vectors Cosine similarity between them. Represents the first in the task memory. Historical task data.
[0078] S214. Update the task-sensitive weights under the condition that the generalization weights are frozen.
[0079] The generalization weights remain frozen and do not participate in parameter updates. The image of the current simulation subtask is used as input, and the retrieved historical task-sensitive weights are used as the initial values of the task-sensitive weights. A few gradient descent steps are performed on the current simulation subtask to update the task-sensitive weights.
[0080] S215. Store the current task representation vector and the updated task sensitivity weights into the task memory. After storage, the historical task data in the task memory is increased by one entry, and the representation vector of the current simulated subtask and the trained task sensitivity weights become the historical task data that can be retrieved for subsequent simulated subtasks.
[0081] For each simulation subtask, S212 to S215 are executed repeatedly. After iterating through all simulation subtasks, the meta-transfer base model is obtained.
[0082] This invention constructs a task memory, extracts the current task representation vector of the current simulated subtask, retrieves the task memory using the current task representation vector, and uses the matched historical task-sensitive weights as the initialization parameters of the backbone network. Under the condition of generalization weight freezing, the task-sensitive weights are updated, and the current task representation vector and the updated task-sensitive weights are stored in the task memory. The task representation vector is obtained by inputting images from the current simulated subtask into the backbone network and aggregating features, enabling a compact representation of the disease category combinations and image feature distribution of the current simulated subtask. Compared with a globally unified initialization strategy, retrieving matched historical task-sensitive weights based on the task representation vector as initialization parameters allows the backbone network to be in a parameter state closer to the current simulated subtask at the start of training, avoiding the drawback of requiring multiple iterations to approach the optimal parameters from a fixed initial value. The retrieved historical task-sensitive weights have been trained on similar tasks, and their parameter distribution is similar to the optimization direction of the current task. Convergence can be achieved with only a few gradient updates on a small number of samples from the current simulated subtask, improving the fine-tuning stability of the task-sensitive weights under small sample conditions.
[0083] This invention stores the current task representation vector and the updated task-sensitive weights in a task memory, making the parameters obtained through training for the current simulated subtask valuable historical knowledge for subsequent simulated subtasks. The task memory continuously expands during meta-transfer learning training, allowing subsequent simulated subtasks to retrieve richer collections of similar historical tasks, and the initialized task-sensitive weights gradually approach the optimization direction of the new task. As historical task data accumulates in the task memory, the quality of the backbone network's initial parameters for new simulated subtasks gradually improves. Ultimately, this enables the backbone network to quickly adapt to real-world disease identification tasks with only a small number of labeled samples, reducing missed lesion labeling and misclassification.
[0084] In one embodiment, the update task-sensitive weights include: The samples obtained from the current simulated subtask are input into the backbone network to obtain the predicted classification result and predicted localization result for each sample. The classification loss of lesion and disease category is calculated based on the predicted classification results and the actual classification labels of each sample, and the location loss of lesion bounding box is calculated based on the predicted location results and the actual location labels of each sample. The total loss is determined based on the loss from the classification of lesion and disease categories and the loss from the location of lesion bounding boxes. The task-sensitive weights are updated based on backpropagation of the total loss.
[0085] Specifically, during the meta-transfer learning training process, the generalization weights remain frozen, and only the task-sensitive weights undergo inner-loop fine-tuning. The inner-loop fine-tuning employs a joint loss function for classification and localization. Samples obtained from the current simulated subtask are input into the backbone network to obtain the predicted classification and localization results for each sample. After extracting features from the input image, the backbone network feeds the feature maps into the classification and localization branches in the task head. The classification branch outputs the predicted classification result for each sample, and the localization branch outputs the predicted localization result for each sample.
[0086] The classification loss of lesion and disease categories is calculated based on the predicted classification results and actual classification labels of each sample. , This is used to measure the accuracy of the model's prediction of disease categories for each sample. The lesion bounding box localization loss is calculated based on the predicted localization results and the actual localization annotations for each sample. , Used to measure the accuracy of the model's prediction of the location of lesion boundaries for each sample.
[0087] The total loss is calculated using the following formula: ; in, For loss function, This is a loss balancing hyperparameter used to adjust the relative weights of lesion / disease category classification loss and lesion bounding box localization loss in the total loss. The value is set according to the actual application scenario; it is increased when high positioning accuracy is required. The value of should be reduced when high classification accuracy is required. The value of .
[0088] Calculate the gradient of the total loss with respect to the task-sensitive weights, and update the values of the task-sensitive weights along the gradient descent direction to gradually reduce the total loss of the model on the current simulated subtask.
[0089] This invention inputs samples obtained from the current simulated subtask into the backbone network to obtain the predicted classification and predicted localization results for each sample. Based on the predicted classification results and the actual classification labels for each sample, the lesion / disease category classification loss is calculated. Based on the predicted localization results and the actual localization labels for each sample, the lesion / disease bounding box localization loss is calculated. The total loss is determined based on the lesion / disease category classification loss and the lesion / disease bounding box localization loss. The task-sensitive weights are then updated using backpropagation based on the total loss. The lesion / disease category classification loss measures the accuracy of the model's prediction of the disease category and drives the adjustment of the task-sensitive weights to make the disease category output by the classification branch closer to the true category. The lesion / disease bounding box localization loss measures the accuracy of the model's prediction of the lesion / disease bounding box position and drives the adjustment of the task-sensitive weights to make the bounding box position output by the localization branch closer to the true position. By determining the total loss through a weighted sum of the two and backpropagating it to update the task-sensitive weights, the update of the task-sensitive weights is constrained by both classification accuracy and localization accuracy. This avoids the problems of localization offset caused by optimizing only the classification loss or classification error caused by optimizing only the localization loss, thus improving the technical shortcomings of large lesion localization deviations and easy confusion of similar diseases.
[0090] In one embodiment, the overall optimization objective of the meta-transfer learning training is to minimize the expected loss of the simulated subtasks sampled from the task distribution.
[0091] Task distribution This refers to the probability distribution of all possible sampled simulated subtasks when constructing simulated subtasks from a support set. During meta-transfer learning training, this probability distribution is used to determine the probability of obtaining simulated subtasks. The process involves sampling multiple simulation subtasks, each containing several disease categories and corresponding samples. The overall optimization objective is expressed as: ; in, To ensure generalization, the weights remain fixed throughout the entire training process; This represents the set of task-sensitive weights corresponding to all simulated subtasks, where each simulated subtask... Corresponding to a task sensitivity weight . Represents a simulated subtask randomly sampled from the task distribution; For task distribution; Indicates and the current Corresponding task sensitivity weight The output of the backbone network with parameters is the input image. Indicates the distribution of tasks All simulation subtasks in the middle sampling Seeking expectations.
[0092] Simulation subtask for each sample Perform task sensitivity weight update for the current simulation subtask to obtain the updated task sensitivity weight. The current simulation subtask The corresponding current task representation vector and the updated task sensitivity weights Stored in the task memory, this adds a new historical task record to the task memory, representing the current simulated subtask. Task representation vector and updated task sensitivity weights This becomes historical task data that can be retrieved for subsequent simulation subtasks.
[0093] Through multiple simulation sub-tasks The iterative loop minimizes the distribution of tasks. The expected loss of the sampled simulated subtasks is used to obtain the meta-transfer base model. The overall optimization objective of this invention is not designed for a single simulated subtask, but rather considers the average performance of all possible sampled simulated subtasks. This ensures that the model does not favor any single class combination during training, but rather has good adaptability to all possible class combinations.
[0094] Taking the annotation of leaf disease images of greenhouse tomatoes, cucumbers, and peppers as examples, the method of the present invention will be described in detail. The vegetable leaf lesion image annotation method based on meta-transfer few-shot learning of the present invention performs the following steps: S1. Image preprocessing and sample segmentation. Images of vegetable leaves from greenhouse tomatoes, cucumbers, and peppers were collected. The vegetable leaf image set included images of healthy leaves, leaves with a single disease, and leaves with multiple diseases. The image resolution in the vegetable leaf image set was uniformly adjusted to 256×256. Noise reduction was performed using a 5×5 Gaussian kernel to obtain the preprocessed image set. Several images were manually selected from the preprocessed image set for precise labeling as the support set. The remaining large number of unlabeled images in the preprocessed image set served as the unlabeled sample set. During training, online data augmentation was performed by randomly flipping and brightness perturbing the images in the support set and the unlabeled sample set.
[0095] S2. MobileNetV3-Small was selected as the backbone network. Transfer pre-training was conducted based on the publicly available PlantVillage crop disease dataset. After pre-training, all network parameters of the backbone network were decomposed into generalization weights and task-sensitive weights: the parameters of the shallow convolutional layers in the backbone network responsible for extracting general visual features were defined as generalization weights and permanently frozen; the parameters of the deep feature fusion layers in the backbone network responsible for extracting disease-specific lesion features and the task head parameters connected to the backbone network were defined as task-sensitive weights. In the network input stage, the Canny edge feature map of the image was extracted, and the Canny edge feature map was fused with the RGB three-channel data of the image. The fused image data was used as the input of the backbone network.
[0096] S3. Perform meta-transfer learning training. Specifically, initialize the task memory, which stores historical task data. Each historical task data entry contains a historical task representation vector and its corresponding historical task sensitivity weights. (Refer to...) Figure 3 As shown, multiple simulated subtasks are constructed from the support set according to the N-way K-shot small sample sampling rule. In this embodiment, N-way=6 and K-shot=5, that is, each simulated subtask randomly selects 6 disease categories from the support set, and randomly selects 5 samples from each disease category, for a total of 30 samples to form the training sample set of the simulated subtask. For each simulated subtask, the current task representation vector of the current simulated subtask is extracted. The task memory is retrieved using the current task representation vector. The cosine similarity between the current task representation vector and each historical task representation vector stored in the task memory is calculated. The historical task sensitive weight corresponding to the historical task representation vector with the highest cosine similarity is selected as the initialization parameter of the backbone network. The generalization weights are frozen, and only the task sensitive weights are fine-tuned in the inner loop. The inner loop fine-tuning uses the weighted sum of the lesion disease category classification loss and the lesion bounding box localization loss as the total loss. The task sensitive weights are updated by backpropagation based on the total loss. The current task representation vector and the updated task sensitive weights are stored in the task memory. After multiple simulated subtasks are iterated, the meta-transfer learning training is completed, and the meta-transfer base model is obtained.
[0097] S4. Perform multi-level step-by-step reasoning. Specifically, refer to... Figure 4As shown, the image of the vegetable leaf to be labeled is input into the meta-transfer model. The meta-transfer model performs the first level of inference, namely vegetable type identification, and outputs the vegetable category (tomato, cucumber, or pepper) to which the current image belongs. Based on the vegetable category identification result, the current image is routed to the corresponding category branch. The tomato category branch calls the task-sensitive weights corresponding to the tomato category to load onto the meta-transfer model for the second level of inference; the cucumber category branch calls the task-sensitive weights corresponding to the cucumber category to load onto the meta-transfer model for the second level of inference; and the pepper category branch calls the task-sensitive weights corresponding to the pepper category to load onto the meta-transfer model for the second level of inference. The second level of inference is the detection of leaf lesions, and outputs the lesion location coordinates and disease category label as the prediction result. The confidence level of the prediction result output by the second level of inference is determined. When the confidence level of the prediction result is greater than a preset threshold, it is directly stored in the database, generating a pre-labeled file in the COCO or VOC standard format; when the confidence level of the prediction result is not greater than the preset threshold, it is pushed for manual review.
[0098] S5. Display the original image of vegetable leaves and automatically generated pre-annotated boxes through a human-computer interaction interface. Receive manual correction instructions from operators, correct mislabeled disease categories, supplement missing lesion targets, and adjust inaccurately positioned bounding boxes to obtain manually verified labeled samples. Incorporate the manually verified labeled samples into the support set to obtain an updated support set. Re-execute the meta-transfer learning training in step S3 based on the updated support set, and update the task-sensitive weights stored in the task memory. After multiple rounds of iterative optimization, the quality of automatic pre-annotation of the meta-transfer basic model is continuously improved, effectively reducing the workload of manual modification.
[0099] It should be noted that the vegetable classifier can be part of the meta-transfer base model, with the meta-transfer base model directly outputting the vegetable category discrimination result; alternatively, the vegetable classifier can be a classification model trained independently of the meta-transfer base model. Both implementations can achieve the function of the first-level inference in this invention, that is, performing coarse classification of vegetable categories on images in the labeled sample set to obtain the vegetable category discrimination result. Those skilled in the art can choose the appropriate implementation method according to the actual application scenario and deployment requirements.
[0100] This invention enables an automatic pre-labeling process using only a small number of initial manually labeled samples. It supports datasets containing a small number of manually labeled images, while the dataset contains a large number of unlabeled images. After the meta-transfer model generates pre-labeling results for the dataset, staff only need to verify and correct samples with confidence levels below a threshold. Pre-labeling results with confidence levels above the threshold are directly saved to the database. This eliminates the need for manual labeling of every single image, reducing the workload for agronomic professionals and significantly shortening the construction cycle of large-scale disease image datasets.
[0101] This invention decomposes the backbone network parameters into generalization weights and task-sensitive weights. Generalization weights are obtained through transfer pre-training on the source domain dataset, storing common visual features such as leaf edges, texture, and color. After pre-training, these weights are permanently frozen and do not participate in subsequent meta-transfer learning parameter updates. Task-sensitive weights are used to learn specific lesion features for different vegetable diseases and are updated during meta-transfer learning training. Because a large number of parameters contained in the generalization weights do not participate in target domain training, only a small number of labeled samples in the target domain need to be optimized for the task-sensitive weights. This significantly reduces the number of parameters actually involved in optimization, effectively lowering the risk of overfitting in small-sample training. During meta-transfer learning training, historical task-sensitive weights retrieved from the task memory are used as initialization parameters for the backbone network. These retrieved historical task-sensitive weights have already been trained on similar tasks, and their parameter distribution is closer to the optimization direction of the current task. They have a stronger adaptability to new vegetable diseases and diseases of niche varieties, helping to reduce lesion omissions and misclassifications.
[0102] This invention first performs transfer pre-training on the backbone network on the source domain dataset, enabling the backbone network to possess good general feature extraction capabilities before learning vegetable disease tasks. Then, through meta-transfer learning training, it uses historical task-sensitive weights retrieved from the task memory as initialization parameters for the backbone network, achieving rapid fine-tuning for new disease tasks. Transfer pre-training provides the backbone network with visual prior knowledge of agricultural disease images, while meta-transfer learning training enables the backbone network to quickly adapt to new disease tasks. This overcomes the shortcomings of single transfer pre-training in terms of insufficient generalization ability across vegetable varieties and disease types, and also overcomes the shortcomings of meta-learning alone in terms of insufficient fine-tuning stability due to the lack of prior knowledge in the agricultural domain.
[0103] This invention achieves continuous learning through a closed-loop process of pre-labeling, manual verification, sample feedback, and task memory updates. Samples meeting preset conditions in the pre-labeling results become manually verified labeled samples after manual verification. These manually verified labeled samples are then incorporated into the support set, and meta-transfer learning training is re-executed to update the task sensitivity weights stored in the task memory. As labeling continues, the task sensitivity weights corresponding to various vegetable disease tasks are continuously stored in the task memory, accumulating historical disease knowledge. Subsequent new disease tasks can retrieve matching historical task sensitivity weights from the task memory as initialization parameters for the backbone network, reusing historical similar disease knowledge. This iterative process continuously improves the labeling effect, making it suitable for long-term construction of multi-category vegetable disease image databases.
[0104] This invention employs a two-stage inference strategy to reduce feature interference across vegetable categories. The first stage of inference performs a coarse classification of vegetable categories for images in the unlabeled sample set, determining the vegetable category to which the current image belongs and limiting the recognition scope to a specific vegetable category. The second stage of inference retrieves the corresponding task-sensitive weights from the task memory based on the vegetable category classification result and loads them onto the meta-transfer model to perform lesion detection, ensuring that the model only makes discriminations within the disease feature space of the same vegetable category. This approach eliminates interference from leaf texture, color, and other features of different vegetable categories, helping to reduce the probability of confusion between different disease labels in scenarios involving the identification of leaves with multiple coexisting diseases, and improving the annotation quality of complex field images.
[0105] The following describes the vegetable leaf lesion image annotation device based on meta-transfer few-shot learning provided by the present invention. The vegetable leaf lesion image annotation device based on meta-transfer few-shot learning described below can be referred to in correspondence with the vegetable leaf lesion image annotation method based on meta-transfer few-shot learning described above.
[0106] This invention also provides a device for annotating vegetable leaf lesion images based on meta-transfer few-shot learning, referring to... Figure 5 As shown, it includes the following modules: The image acquisition and processing module 310 is used to divide the vegetable leaf image set into a support set and a sample set to be labeled, wherein the support set contains manually labeled images and the sample set to be labeled contains unlabeled vegetable leaf images. The transfer pre-training module 320 is used to perform transfer pre-training on the backbone network based on the source domain dataset to obtain the pre-trained network parameters, which include generalization weights and task-sensitive weights. The meta-transfer learning training module 330 is used to construct multiple simulated sub-tasks based on the support set, and perform meta-transfer learning training on the backbone network based on the multiple simulated sub-tasks to obtain a meta-transfer basic model; the meta-transfer learning training includes: under the condition that the generalization weights are frozen, using the task memory to retrieve the matching task-sensitive weights as the initialization parameters of the backbone network, updating the task-sensitive weights, and storing the updated task-sensitive weights in the task memory. The step-by-step lesion labeling and reasoning module 340 is used to perform first-level reasoning on the sample set to be labeled using the meta-transfer basic model to obtain vegetable category discrimination results; and to retrieve the corresponding task-sensitive weights from the task memory based on the vegetable category discrimination results, load them onto the meta-transfer basic model to perform second-level reasoning, and obtain pre-labeling results.
[0107] The device also includes a human-computer interaction annotation verification module 350 and a sample iteration update module 360. The human-computer interaction annotation verification module is used to display the pre-annotation results and receive manual correction instructions, and output manually verified annotated samples. The sample iteration update module is used to incorporate the manually verified annotated samples into the support set, trigger the meta-transfer learning training module to re-execute the meta-transfer learning training, and update the task-sensitive weights stored in the task memory.
[0108] The specific functions of each module have been described in detail in the steps of the above method embodiments. The image acquisition and processing module receives vegetable leaf images from the camera and local folder, and performs normalization and noise reduction; the transfer learning pre-training module loads the MobileNetV3 network and completes source domain pre-training, separating and freezing the generalization weights; the meta-transfer learning training module calls the disease task memory to complete parameter retrieval and inner loop fine-tuning, and continuously iteratively updates the memory; the step-by-step lesion labeling and inference module performs two-level recognition and outputs pre-labeled files in batches; the human-computer interaction labeling and verification module provides a visual interface and supports label editing; the sample iterative update module verifies the sample backflow training link, forming a closed loop for continuous optimization. The device can be deployed on local industrial control edge devices, without continuously relying on cloud computing power, and is suitable for on-site image labeling work in facility agriculture parks.
[0109] Figure 6 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 6 As shown, the electronic device may include: a processor 410, a communications interface 420, a memory 430, and a communication bus 440, wherein the processor 410, the communications interface 420, and the memory 430 communicate with each other via the communication bus 440. The processor 410 can call logical instructions in the memory 430 to execute a vegetable leaf lesion image annotation method based on meta-transfer few-shot learning, the method including: The vegetable leaf image set is divided into a support set and a sample set to be labeled. The support set contains manually labeled images, and the sample set to be labeled contains unlabeled vegetable leaf images. Based on the source domain dataset, the backbone network is pre-trained by transfer learning to obtain the pre-trained network parameters, which include generalization weights and task-sensitive weights. Multiple simulated subtasks are constructed based on the support set, and meta-transfer learning training is performed on the backbone network based on the multiple simulated subtasks to obtain a meta-transfer basic model; the meta-transfer learning training includes: under the condition that the generalization weights are frozen, using the task memory to retrieve the matching task-sensitive weights as the initialization parameters of the backbone network, updating the task-sensitive weights, and storing the updated task-sensitive weights in the task memory. The meta-transfer model is used to perform first-level inference on the sample set to be labeled to obtain vegetable category discrimination results; based on the vegetable category discrimination results, the corresponding task-sensitive weights are retrieved from the task memory and loaded onto the meta-transfer model to perform second-level inference to obtain pre-labeling results.
[0110] Furthermore, the logical instructions in the aforementioned memory 430 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0111] In another aspect, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the vegetable leaf lesion image annotation method based on meta-transfer few-shot learning provided by the above methods, the method comprising: The vegetable leaf image set is divided into a support set and a sample set to be labeled. The support set contains manually labeled images, and the sample set to be labeled contains unlabeled vegetable leaf images. Based on the source domain dataset, the backbone network is pre-trained by transfer learning to obtain the pre-trained network parameters, which include generalization weights and task-sensitive weights. Multiple simulated subtasks are constructed based on the support set, and meta-transfer learning training is performed on the backbone network based on the multiple simulated subtasks to obtain a meta-transfer basic model; the meta-transfer learning training includes: under the condition that the generalization weights are frozen, using the task memory to retrieve the matching task-sensitive weights as the initialization parameters of the backbone network, updating the task-sensitive weights, and storing the updated task-sensitive weights in the task memory. The meta-transfer model is used to perform first-level inference on the sample set to be labeled to obtain vegetable category discrimination results; based on the vegetable category discrimination results, the corresponding task-sensitive weights are retrieved from the task memory and loaded onto the meta-transfer model to perform second-level inference to obtain pre-labeling results.
[0112] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0113] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0114] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for annotating vegetable leaf lesion images based on meta-transfer few-shot learning, characterized in that, include: The vegetable leaf image set is divided into a support set and a sample set to be labeled. The support set contains manually labeled images, and the sample set to be labeled contains unlabeled vegetable leaf images. Based on the source domain dataset, the backbone network is pre-trained by transfer learning to obtain the pre-trained network parameters, which include generalization weights and task-sensitive weights. Multiple simulated subtasks are constructed based on the support set, and meta-transfer learning training is performed on the backbone network based on the multiple simulated subtasks to obtain the meta-transfer basic model. The meta-transfer learning training includes: under the condition that the generalization weights are frozen, using the task memory to retrieve the matching task-sensitive weights as the initialization parameters of the backbone network, updating the task-sensitive weights, and storing the updated task-sensitive weights in the task memory. The meta-transfer model is used to perform first-level inference on the sample set to be labeled to obtain vegetable category discrimination results; based on the vegetable category discrimination results, the corresponding task-sensitive weights are retrieved from the task memory and loaded onto the meta-transfer model to perform second-level inference to obtain pre-labeling results.
2. The method for annotating vegetable leaf lesion images based on meta-transfer few-shot learning according to claim 1, characterized in that, The meta-transfer learning training includes: For each simulation subtask, perform the following steps, and after iterating through all simulation subtasks, obtain the meta-transfer base model: Extract the current task representation vector of the current simulation subtask; A task memory bank is constructed, which stores multiple historical task data. Each historical task data includes a historical task representation vector and a corresponding historical task sensitivity weight. The task memory is retrieved using the current task representation vector, and the matching historical task sensitivity weights are used as initialization parameters for the backbone network. Under the condition of freezing the generalization weights, update the task-sensitive weights and store the current task representation vector and the updated task-sensitive weights into the task memory.
3. The method for annotating vegetable leaf lesion images based on meta-transfer few-shot learning according to claim 2, characterized in that, The update task sensitivity weights include: The samples obtained from the current simulated subtask are input into the backbone network to obtain the predicted classification result and predicted localization result for each sample. The classification loss of lesion and disease category is calculated based on the predicted classification results and the actual classification labels of each sample, and the location loss of lesion bounding box is calculated based on the predicted location results and the actual location labels of each sample. The total loss is determined based on the loss from the classification of lesion and disease categories and the loss from the location of lesion bounding boxes. The task-sensitive weights are updated based on backpropagation of the total loss.
4. The method for annotating vegetable leaf lesion images based on meta-transfer few-shot learning according to claim 1, characterized in that, The overall optimization objective of the meta-transfer learning training is to minimize the expected loss of the simulated subtasks sampled from the task distribution.
5. The method for annotating vegetable leaf lesion images based on meta-transfer few-shot learning according to claim 1, characterized in that, The method further includes: For samples in the pre-labeling results that meet preset conditions, a manual correction instruction is received, and the samples are corrected according to the manual correction instruction to obtain manually verified labeled samples. The manually verified labeled samples are incorporated into the support set to obtain an updated support set. The meta-transfer learning training is then re-executed based on the updated support set, and the task-sensitive weights stored in the task memory are updated.
6. The method for annotating vegetable leaf lesion images based on meta-transfer few-shot learning according to claim 1, characterized in that, The method further includes: The vegetable leaf image set was subjected to size normalization and noise reduction processing to obtain a preprocessed image set; The preprocessed image set is divided into the support set and the unlabeled sample set, and online data augmentation is performed on the images in the support set and the unlabeled sample set. The online data augmentation includes at least one of random flipping, color perturbation and contrast adjustment.
7. The method for annotating vegetable leaf lesion images based on meta-transfer few-shot learning according to claim 1, characterized in that, Before inputting the image into the backbone network, the method further includes: The edge feature map of the image is extracted, and the edge feature map is fused with the RGB three-channel data of the image to obtain fused image data. The fused image data is used as the input of the backbone network.
8. A device for annotating vegetable leaf lesion images based on meta-transfer few-shot learning, characterized in that, include: The image acquisition and processing module is used to divide the vegetable leaf image set into a support set and a sample set to be labeled. The support set contains manually labeled images, and the sample set to be labeled contains unlabeled vegetable leaf images. The transfer pre-training module is used to perform transfer pre-training on the backbone network based on the source domain dataset to obtain the pre-trained network parameters, which include generalization weights and task-sensitive weights. The meta-transfer learning training module is used to construct multiple simulated subtasks based on the support set, and perform meta-transfer learning training on the backbone network based on the multiple simulated subtasks to obtain a meta-transfer basic model. The meta-transfer learning training includes: under the condition that the generalization weights are frozen, using the task memory to retrieve the matching task-sensitive weights as the initialization parameters of the backbone network, updating the task-sensitive weights, and storing the updated task-sensitive weights in the task memory. The step-by-step lesion labeling and reasoning module is used to perform first-level reasoning on the sample set to be labeled using the meta-transfer basic model to obtain vegetable category discrimination results; based on the vegetable category discrimination results, the corresponding task-sensitive weights are retrieved from the task memory and loaded onto the meta-transfer basic model to perform second-level reasoning to obtain pre-labeling results.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the vegetable leaf lesion image annotation method based on meta-transfer few-shot learning as described in any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the vegetable leaf lesion image annotation method based on meta-transfer few-shot learning as described in any one of claims 1 to 7.
