Metalearning-based small sample target detection method
By using meta-learning methods in small-sample target detection, combining ResNet50 and the meta-learning layer of the convolutional network to output categories and coordinates, the problem of reduced detection speed in the existing technology is solved, and more efficient target detection is achieved.
Patent Information
- Application Number
- CN202310322905.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-29
- Publication Date
- 2024-10-01
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
When the number of target detections in existing small-sample target detection methods increases, the matching operation causes the detection speed to decrease, especially when using the Faster R-CNN model, which requires all candidate regions in each image and all supporting images of each category. Matching is performed, causing detection speed issues.
Adopt a small sample target detection method based on meta-learning, use ResNet50 as the backbone network, and add 4 layers of convolutional networks as the meta-learning layer to output categories and coordinates, and optimize the parameters of the meta-learning layer through regression and classification loss functions to avoid complexity The image matching operation improves the detection speed.
It improves the speed of small sample target detection, reduces the number of matching operations, and reduces the detection delay. It is suitable for situations where there is only one or several training images for each object category to be recognized.
Smart Images

Figure CN118736370A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a small sample target detection method based on meta-learning, and belongs to the field of computer vision. Background Art
[0002] The purpose of the target detection task is to determine the location of the target object of interest in the image and to identify the category to which the target object belongs. It is one of the core issues in the field of computer vision. With the rapid development of deep learning technology, several detection algorithms based on convolutional network models have been proposed, which greatly promoted the development of target detection algorithms. Typical models include the two-stage Faster R-CNN and the one-stage YOLO. These algorithms often require a large amount of accurate annotations on the target location and category to complete the model training. In order to save the economic cost of manual annotation, small sample target detection methods have been proposed one after another. For example, Karlinsky et al. [Karlinsky L, Shtok J, Harary S, et al. RepMet: Representative-Based Metric Learning for Classification and Few-Shot Object Detection [C] / / 2019 IEEE / CVF Conference on Computer Vision and Pattern Recognition (CVPR). IEEE, 2019.] proposed Repmet, in which the target object of each category is represented by a mixed model with multiple patterns, and the center of these patterns is considered as the representative vector of the class. The meta-metric method is used for classification and recognition, and the Faster R-CNN variant FPN is used as the backbone network to complete the detection of the target. Fan et al. (Fan Q, Zhuo W, Tang CK, et al. Few-Shot Object Detection With Attention-RPN and Multi-Relation Detector [C] / / 2020 IEEE / CVF Conference on Computer Vision and Pattern Recognition (CVPR). IEEE, 2020.) also used Faster R-CNN combined with a meta-metric classifier to complete small sample target detection. However, these methods replace the Faster R-CNN classifier with a meta-metric classifier, and need to match all candidate regions in each image with all supporting images in each category. As the number of target detections increases linearly, the number of matches required also increases exponentially, which further exacerbates the problem of Faster R-CNN detection speed.In order to solve the above technical problems, the present invention discloses a small sample target detection method based on meta-learning. It uses ResNet5O as the backbone network and adds a 4-layer convolutional network as the meta-learning layer. The meta-learning layer simultaneously outputs the category and coordinates of the detected target, and optimizes the optimal initialization parameters of the meta-learning layer network based on the regression and classification loss functions and using the meta-learning algorithm. Summary of the invention
[0003] In order to improve the speed of small sample target detection, the present invention discloses a small sample target detection method based on meta-learning, and the technical scheme adopted is as follows:
[0004] Step 1, processing of the meta-training dataset in the target detection dataset. The target detection dataset is divided into a meta-training dataset and a meta-testing dataset. The meta-training dataset is used to construct a small sample target detection task. Each task contains a support sample set and a test sample set. The former is formed by randomly extracting N types of target images from the meta-training dataset and then randomly extracting K images from the N types of target images. The latter is formed by randomly extracting Q images from the remaining N types of target images.
[0005] Step 2: Construction of small sample target detection model. The target detection model consists of a feature extraction subnetwork and an output subnetwork, where the former consists of 9 convolutional layers and the latter consists of 2 fully connected layers;
[0006] Step 3: Training of small sample target detection model. Input the support sample images and query sample images in the meta-training set into the backbone network of the target detection model to extract features. The meta-learning layer converts the image features into the target category and position coordinate output values. The loss function is calculated by comparing the target category and position coordinate output values with the true category label value and position annotation value. A gradient update is performed on the support set and a secondary gradient update is performed on the query set. The secondary updated gradient value is applied to the original model for network optimization.
[0007] Step 4: Processing of the meta-test dataset in the target detection dataset. Use the meta-training dataset to construct a small sample target detection task. Each task contains a support sample set and a test sample set. The former is formed by randomly extracting N types of target images from the meta-training dataset and then randomly extracting K images from the N types of target images. The latter is formed by randomly extracting Q images from the remaining N types of target images.
[0008] Step 5: Testing of small sample target detection model. Fine-tune the parameters in the target detection model using the support samples in the meta-test dataset, input the query sample into the target detection model, and obtain the target category of the query image sample as the position coordinate output value.
[0009] Compared with the existing technical solutions, the above technical solutions adopted by the present invention have the following technical effects: the small sample target detection method based on meta-learning disclosed by the present invention can improve the speed of small sample target detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] The present invention will be further described below in conjunction with the accompanying drawings:
[0011] Figure 1 This is a flow chart of the small sample target detection method based on meta-learning of the present invention. DETAILED DESCRIPTION
[0012] Figure 1 is a flow chart of the small sample target detection method based on meta-learning of the present invention. Figure 1 The specific steps are as follows:
[0013] Step 1, processing of the meta-training dataset in the target detection dataset. The target detection dataset is divided into a meta-training dataset and a meta-testing dataset. The meta-training dataset is used to construct a small sample target detection task. Each task contains a support sample set and a test sample set. The former is formed by randomly extracting N types of target images from the meta-training dataset and then randomly extracting K images from the N types of target images. The latter is formed by randomly extracting Q images from the remaining N types of target images.
[0014] Step 2: Construction of small sample target detection model. The target detection model consists of a feature extraction subnetwork and an output subnetwork, where the former consists of 9 convolutional layers and the latter consists of 2 fully connected layers;
[0015] Step 3: Training of small sample target detection model. Input the support sample images and query sample images in the meta-training set into the backbone network of the target detection model to extract features. The meta-learning layer converts the image features into the target category and position coordinate output values. The loss function is calculated by comparing the target category and position coordinate output values with the true category label value and position annotation value. A gradient update is performed on the support set and a secondary gradient update is performed on the query set. The secondary updated gradient value is applied to the original model for network optimization.
[0016] Step 4: Processing of the meta-test dataset in the target detection dataset. Use the meta-training dataset to construct a small sample target detection task. Each task contains a support sample set and a test sample set. The former is formed by randomly extracting N types of target images from the meta-training dataset and then randomly extracting K images from the N types of target images. The latter is formed by randomly extracting Q images from the remaining N types of target images.
[0017] Step 5: Testing of small sample target detection model. Fine-tune the parameters in the target detection model using the support samples in the meta-test dataset, input the query sample into the target detection model, and obtain the target category of the query image sample as the position coordinate output value.
[0018] Furthermore, the specific process of step 1 includes:
[0019] 1.1 The target detection dataset is divided into a meta-training dataset and a meta-testing dataset, the former is denoted as O train , the latter is denoted as O test ;
[0020] 1.2 In O train A series of small sample target detection tasks are constructed on the basis of t , each task contains a support sample set and a query sample set, and the i-th support sample is represented as I i , and its corresponding target position label value is expressed as The label value of the target's credibility value is expressed as The target category label value is in Indicates the center point of the target. represents the width and height of the target; the qth query sample is represented by I q , and its corresponding target position label value is expressed as The label value of the target's credibility value is expressed as The target category label value is
[0021] Furthermore, the specific process of step 2 includes:
[0022] 2.1 The feature extraction subnetwork in the target detection model is represented by d θ (·), θ represents the parameters in the feature extraction subnetwork;
[0023] 2.2 The output subnetwork in the target detection model is represented as Represents the parameters in the output subnetwork;
[0024] Furthermore, the specific process of step 3 is as follows:
[0025] 3.1 Input the support samples in the meta-training set into the target detection model, and the convolution feature of the i-th support sample is represented as I i , after inputting the feature extraction subnetwork, we get d θ (I i )∈R C×W×H , C represents the number of channels of the convolution feature, H and W represent the spatial size of the convolution feature, and the output value of the network obtained after the convolution feature passes through the output subnetwork is expressed as Where S×S represents the number of grids into which the image is divided. In the inference stage, the image is divided into S×S grids. If the center of the target object falls into the grid, the grid is responsible for predicting the object. Each grid predicts B bounding boxes, each of which contains four position information (x, y, w, h) and a confidence information C. Therefore, L=5*B represents the coordinate prediction value of each bounding box and the credibility value of the target respectively. During the training process, the network selects the bounding box with the largest IOU value with the true label in the grid to be responsible for the regression of the coordinate position and credibility and calculate the loss. Here, its coordinate prediction value is expressed as (x i ,y i , w i ,h i ), the credibility value of the target is expressed as C i , N represents the number of target categories. Each grid has multiple bounding boxes but only predicts the category probability value of the target once. The category prediction value corresponding to the grid is represented as p i (c);
[0026] 3.2 The calculation formula of the loss function for optimizing training for the tth task is:
[0027]
[0028] Among them, when the target falls into the i-th grid, The value of is 1, otherwise it is 0; when the target falls into the i-th grid and is predicted by the j-th bounding box with the largest IOU value, The value of is 1, otherwise it is 0. α1 and α2 are scalars used to control the size of each term in the loss function.
[0029] 3.3 Record the parameters θ and For each task, the initial parameters in the network are optimized using the gradient descent method on the support set. The calculation formula for the parameter update of the tth task is:
[0030]
[0031]
[0032] in represents the gradient of the loss function with respect to the θ parameter, Represents the loss function The gradient of the parameter, α represents the learning rate;
[0033] 3.4 Based on the updated parameters, recalculate the loss on the query set and calculate its gradient with respect to the initial parameters. After calculating the gradient of the query set in all tasks, update the parameters of the initial network using the following formula:
[0034]
[0035]
[0036] Where β represents the learning rate.
[0037] Furthermore, the specific process of step 4 includes:
[0038] 4.1 In O test A series of small sample target detection test tasks are constructed on the basis of t ,Each task contains a support sample set and a query sample set;
[0039] 4.2 The i-th support sample is represented as I i , and its corresponding target position label value is expressed as The label value of the target's credibility value is expressed as The target category label value is The qth query sample is represented as I q , and its corresponding target position label value is expressed as The label value of the target's credibility value is expressed as The target category label value is
[0040] Furthermore, the specific process of step 5 is as follows:
[0041] 5.1 Input the support samples in the meta-training set into the target detection model to obtain the output f of the image sample θ (I i )∈R S×S×(L+N) , where the coordinate prediction value of the corresponding bounding box is expressed as (x i ,y i , w i ,h i ), the credibility value of the target is expressed as C i , the class prediction value is denoted as p i (c);
[0042] 5.2 The calculation formula of the loss function of the tth task is:
[0043]
[0044] 5.3 Use the gradient descent method to fine-tune the parameters in the network;
[0045] 5.4 Input the query sample into the target detection model and obtain the target category of the query image sample as the position coordinate output value.
[0046] The present invention is applicable to a small sample target detection method in which each category of an object to be identified has only one or a few training images.
[0047] Example 1
[0048] The embodiments of the present invention are described in detail below, and examples of the embodiments are shown in the accompanying drawings. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and cannot be interpreted as limiting the present invention.
[0049] The commonly used small sample target detection method based on meta-metric classifier requires matching all candidate regions in each image with all supporting images in each category. As the number of target detections increases linearly, the number of required matches also increases exponentially, which aggravates the delay of network detection. In order to solve the above problem, this embodiment does not use the general meta-metric classifier method, but proposes a small sample target detection method based on meta-learning, which adopts a two-level optimization method to avoid complex image matching.
[0050] Combination Figure 1 As shown, the small sample target detection method based on meta-learning of the present invention includes the following steps:
[0051] The specific steps for processing the meta-training dataset in the target detection dataset are as follows:
[0052] (1) The target detection dataset is divided into a meta-training dataset and a meta-testing dataset. The former is denoted as train , the latter is denoted as O test ;
[0053] (2) In O train A series of small sample target detection tasks are constructed on the basis of t , each task contains a support sample set and a query sample set, and the i-th support sample is represented as I i , and its corresponding target position label value is expressed as The label value of the target's credibility value is expressed as The target category label value is in Indicates the center point of the target. represents the width and height of the target; the qth query sample is represented by I q , and its corresponding target position label value is expressed as The label value of the target's credibility value is expressed as The target category label value is
[0054] The specific steps for building a small sample target detection model are as follows:
[0055] (1) The feature extraction subnetwork in the target detection model is represented by d θ (·), θ represents the parameters in the feature extraction subnetwork;
[0056] (2) The output subnetwork in the target detection model is expressed as Represents the parameters in the output subnetwork;
[0057] The specific steps for training a small sample target detection model are as follows:
[0058] (1) Input the support samples in the meta-training set into the target detection model, and the convolutional features of the i-th support sample are represented as I i , after inputting the feature extraction subnetwork, we get d θ (I i )∈R C×W×H , C represents the number of channels of the convolution feature, H and W represent the spatial size of the convolution feature, and the output value of the network obtained after the convolution feature passes through the output subnetwork is expressed as Where S×S represents the number of grids into which the image is divided. In the inference stage, the image is divided into S×S grids. If the center of the target object falls into the grid, the grid is responsible for predicting the object. Each grid predicts B bounding boxes, each of which contains four position information (x, y, w, h) and a confidence information C. Therefore, L=5*B represents the coordinate prediction value of each bounding box and the credibility value of the target respectively. During the training process, the network selects the bounding box with the largest IOU value with the true label in the grid to be responsible for the regression of the coordinate position and credibility and calculate the loss. Here, its coordinate prediction value is expressed as (x i ,y i , w i ,h i ), the credibility value of the target is expressed as C i , N represents the number of target categories. Each grid has multiple bounding boxes but only predicts the category probability value of the target once. The category prediction value corresponding to the grid is represented as p i (c);
[0059] (2) The calculation formula of the loss function for optimizing the training of the tth task is:
[0060]
[0061] Among them, when the target falls into the i-th grid, The value of is 1, otherwise it is 0; when the target falls into the i-th grid and is predicted by the j-th bounding box with the largest IOU value, The value of is 1, otherwise it is 0. α1 and α2 are scalars used to control the size of each term in the loss function.
[0062] (3) Record the parameters θ and For each task, the initial parameters in the network are optimized using the gradient descent method on the support set. The calculation formula for the parameter update of the tth task is:
[0063]
[0064]
[0065] in represents the gradient of the loss function with respect to the θ parameter, Represents the loss function The gradient of the parameter, α represents the learning rate;
[0066] (4) Based on the updated parameters, recalculate the loss on the query set and calculate its gradient with respect to the initial parameters. After calculating the gradient of the query set in all tasks, update the parameters of the initial network using the following formula:
[0067]
[0068]
[0069] Where β represents the learning rate.
[0070] The specific steps for processing the meta-test dataset in the target detection dataset are as follows:
[0071] (1) In O test A series of small sample target detection test tasks are constructed on the basis of t ,Each task contains a support sample set and a query sample set;
[0072] (2) The i-th support sample is represented by I i , and its corresponding target position label value is expressed as The label value of the target's credibility value is expressed as The target category label value is The qth query sample is represented as I q , and its corresponding target position label value is expressed as The label value of the target's credibility value is expressed as The target category label value is
[0073] 5. Testing of small sample target detection model. The specific steps are as follows:
[0074] (1) Input the support samples in the meta-training set into the target detection model to obtain the output f of the image sample θ (I i )∈RS×S×(L+N) , where the coordinate prediction value of the corresponding bounding box is expressed as (x i ,y i , w i ,h i ), the credibility value of the target is expressed as C i , the class prediction value is denoted as p i (c);
[0075] (2) The calculation formula of the loss function of the tth task is:
[0076]
[0077] (3) Use gradient descent method to fine-tune the parameters in the network;
[0078] (4) Input the query sample into the target detection model and obtain the target category of the query image sample as the position coordinate output value.
Claims
1. A small sample target detection method based on meta-learning, characterized in that: The steps include: Step 1, processing of the meta-training dataset in the target detection dataset. The target detection dataset is divided into a meta-training dataset and a meta-testing dataset. The meta-training dataset is used to construct a small sample target detection task. Each task contains a support sample set and a test sample set. The former is formed by randomly extracting N types of target images from the meta-training dataset and then randomly extracting K images from the N types of target images. The latter is formed by randomly extracting Q images from the remaining N types of target images. Step 2: Construction of small sample target detection model. The target detection model consists of a feature extraction subnetwork and an output subnetwork, where the former consists of 9 convolutional layers and the latter consists of 2 fully connected layers; Step 3: Training of small sample target detection model. Input the support sample images and query sample images in the meta-training set into the backbone network of the target detection model to extract features. The meta-learning layer converts the image features into target category and position coordinate output values. The loss function is calculated by comparing the target category and position coordinate output values with the actual category label value and position annotation value. A gradient update is performed on the support set and a secondary gradient update is performed on the query set. The secondary updated gradient value is applied to the original model for network optimization. Step 4: Processing of the meta-test dataset in the target detection dataset. Use the meta-training dataset to construct a small sample target detection task. Each task contains a support sample set and a test sample set. The former is formed by randomly extracting N types of target images from the meta-training dataset and then randomly extracting K images from the N types of target images. The latter is formed by randomly extracting Q images from the remaining N types of target images. Step 5: Testing of small sample target detection model. Fine-tune the parameters in the target detection model using the support samples in the meta-test dataset, input the query sample into the target detection model, and obtain the target category of the query image sample as the position coordinate output value.
2. According to the small sample target detection method based on meta-learning according to claim 1, it is characterized in that: The specific process of step 1 is as follows: (1.1) The target detection dataset is divided into a meta-training dataset and a meta-testing dataset, the former is denoted as train , the latter is denoted as O test ; (1.2) In O train A series of small sample target detection tasks are constructed on the basis of t , each task contains a support sample set and a query sample set, and the i-th support sample is represented as I i , and its corresponding target position label value is expressed as The label value of the target's credibility value is expressed as The target category label value is in Indicates the center point of the target. represents the width and height of the target; the qth query sample is represented by I q , and its corresponding target position label value is expressed as The label value of the target's credibility value is expressed as The target category label value is 3. The small sample target detection method based on meta-learning according to claim 1, characterized in that: The specific process of step 2 is: (2.1) The feature extraction subnetwork in the target detection model is represented by d θ (·), θ represents the parameters in the feature extraction subnetwork; (2.2) The output subnetwork in the target detection model is expressed as Represents the parameters in the output subnetwork.
4. The small sample target detection method based on meta-learning according to claim 1, characterized in that: The specific process described in step 3 is: (3.1) Input the support samples in the meta-training set into the target detection model, and the convolutional feature of the i-th support sample is represented as I i , after inputting the feature extraction subnetwork, we get d θ (I i )∈R C×W×H , C represents the number of channels of the convolution feature, H and W represent the spatial size of the convolution feature, and the output value of the network obtained after the convolution feature passes through the output subnetwork is expressed as Where S×S represents the number of grids into which the image is divided. In the inference stage, the image is divided into S×S grids. If the center of the target object falls into the grid, the grid is responsible for predicting the object. Each grid predicts B bounding boxes, each of which contains four position information (x, y, w, h) and a confidence information C. Therefore, L=5*B represents the coordinate prediction value of each bounding box and the credibility value of the target respectively. During the training process, the network selects the bounding box with the largest IOU value with the true label in the grid to be responsible for the regression of the coordinate position and credibility and calculate the loss. Here, its coordinate prediction value is expressed as (x i ,y i , w i ,h i ), the credibility value of the target is expressed as C i , N represents the number of target categories. Each grid has multiple bounding boxes but only predicts the category probability value of the target once. The category prediction value corresponding to the grid is represented as p i (c); (3.2) The calculation formula of the loss function for optimizing the training of the tth task is: Among them, when the target falls into the i-th grid, The value of is 1, otherwise it is 0; when the target falls into the i-th grid and is predicted by the j-th bounding box with the largest IOU value, The value of is 1, otherwise it is 0. α1 and α2 are scalars used to control the size of each term in the loss function. (3.3) Record the parameters θ and For each task, the initial parameters in the network are optimized using the gradient descent method on the support set. The calculation formula for the parameter update of the tth task is: in represents the gradient of the loss function with respect to the θ parameter, Represents the loss function The gradient of the parameter, α represents the learning rate; (3.4) Based on the updated parameters, recalculate the loss on the query set and calculate its gradient with respect to the initial parameters. After calculating the gradient of the query set in all tasks, update the parameters of the initial network using the following formula: Where β represents the learning rate.
5. According to claim 1, the small sample target detection method based on meta-learning is characterized in that: The specific process of step 4 is as follows: (4.1) In O test A series of small sample target detection test tasks are constructed on the basis of t ,Each task contains a support sample set and a query sample set; (4.2) The i-th support sample is represented by I i , and its corresponding target position label value is expressed as The label value of the target's credibility value is expressed as The target category label value is The qth query sample is represented as I q , and its corresponding target position label value is expressed as The label value of the target's credibility value is expressed as The target category label value is 6. The small sample target detection method based on meta-learning according to claim 1, characterized in that: The specific process of step 5 is as follows: (5.1) Input the support samples in the meta-training set into the target detection model to obtain the output f of the image sample θ (I i )∈R S×S×(L+N) , where the coordinate prediction value of the corresponding bounding box is expressed as (x i ,y i , w i ,h i ), the credibility value of the target is expressed as C i , the class prediction value is denoted as p i (c); (5.2) The calculation formula of the loss function of the tth task is: (5.3) Use the gradient descent method to fine-tune the parameters in the network; (5.4) Input the query sample into the target detection model and obtain the target category of the query image sample as the position coordinate output value.
Citation Information
Patent Citations
Photovoltaic panel defect detection method based on meta learning
CN113222896A
Small sample model generation and welding seam detection method based on regional feature metric learning
CN113256594A
Cylinder sleeve small sample defect detection method based on meta learning
CN114663729A
