A method for instance segmentation of multi-objective tasks
By performing histogram equalization on the image and constructing a multi-objective feature extraction network, combined with the non-maximum suppression algorithm and binary regression function, the problems of low recognition accuracy, slow efficiency and rough segmentation in image segmentation are solved, and a more complete solution is achieved. Efficient instance segmentation for multi-objective tasks.
Patent Information
- Application Number
- CN202010686619.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-07-16
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2040-07-16
AI Technical Summary
The existing technology has the problems of low recognition accuracy, slow recognition efficiency and rough segmentation in image segmentation, especially poor performance in target recognition of complex scenes and segmentation of multi-target task instances.
By performing histogram equalization processing on the collected sample images, a multi-target feature extraction network is constructed, candidate bounding boxes are used to extract and classify target objects, and redundant bounding boxes are eliminated through the non-maximum suppression algorithm, and finally fully connected are used layers and binary regression functions for instance segmentation.
It improves the recognition accuracy, speeds up the recognition efficiency, and solves the problem of rough segmentation, allowing the target object to be segmented from the image more accurately.
Smart Images

Figure CN111986125B
Abstract
Description
Technical Field
[0001] The present invention relates to a method for multi-objective task instance segmentation. Technical Background
[0002] In recent years, with the rapid development of computer science and technology, image processing, image target detection, image segmentation, etc. based on computer technology have also achieved unprecedented rapid development. Among them, deep learning has surpassed humans in instance segmentation by learning massive digital image features and extracting key target features, bringing one surprise after another to the industry. With the resurgence of neural networks, video image methods based on convolutional neural networks have become the mainstream technology for image segmentation and recognition, using template matching, edge feature extraction, gradient histograms and other means to achieve accurate image recognition. Although image feature segmentation based on neural networks can effectively identify targets in complex scenes, and its effect is far better than traditional methods, it also has shortcomings: (1) It is weak in noise resistance; (2) The overfitting problem is solved by using the Dropout method, and the convolutional neural network model and parameters are improved, but the accuracy is slightly reduced; (3) The introduction of variable convolution and separable convolution structures improves the generalization of the model and enhances the feature extraction ability of the network model, but the target recognition performance in complex scenes is poor; (4) Although the currently proposed image segmentation method can directly predict the image pixel classification information and achieve pixel positioning of the target object, the model has problems such as large number of parameters, low efficiency, and rough segmentation. In short, both traditional detection methods and image segmentation methods have problems such as cumbersome operation, low recognition accuracy, slow recognition efficiency, and rough segmentation. Summary of the invention
[0003] In order to overcome the above-mentioned deficiencies in the prior art, the present invention provides a method for multi-target task instance segmentation in view of the current problems of low recognition accuracy, slow recognition efficiency and rough segmentation.
[0004] The present invention first performs histogram equalization on the collected sample image to make its features more distinct; then, a multi-target feature extraction network is constructed to extract features from the preprocessed image; subsequently, the target objects on the feature map are extracted and classified using candidate bounding boxes; then, redundant bounding boxes are eliminated using a non-maximum suppression algorithm, and only candidate bounding boxes with a small deviation from the true calibration box and the highest confidence score are retained; finally, a fully connected layer is connected, and binary mask regression is performed on the candidate bounding boxes to segment all the target tasks on the input image.
[0005] To achieve the above object, the present invention adopts the following technical solutions:
[0006] A method for multi-objective task instance segmentation comprises the following steps:
[0007] Step 1: histogram equalization processing of sample image;
[0008] The histogram of an image shows the grayscale distribution of the image. When the grayscale of the histogram is concentrated in the low-value area, the image brightness is low; when the grayscale of the histogram is concentrated in the high-value area, the image brightness is high. When the histogram is concentrated in the middle value area, a low-contrast image is obtained; when the histogram is distributed more evenly and widely, a high-contrast image is obtained. Therefore, the method of making the grayscale of the image evenly distributed can be used to improve the contrast of the image and make the image clear.
[0009] The specific steps of histogram equalization are as follows:
[0010] (1) Count the gray levels of the histogram;
[0011] First, let the variable r represent the gray level of the pixel in the image and normalize the gray level. If the gray level of the image is {0,1,2,...,L-1}, then
[0012]
[0013] Among them, 0≤r≤1, L is the number of gray levels.
[0014] (2) Calculate the corresponding probability density;
[0015] Because the grayscale of the image pixels is randomly distributed between [0,1], the probability density function can be used to represent the distribution of the grayscale of the image. k Represents discrete grayscale, using P r (r k ) represents the grayscale r k Probability of occurrence:
[0016]
[0017] Among them, n k For the image where r appears k The number of pixels of this grayscale, n is the total number of pixels in the image, and n k / n indicates frequency.
[0018] (3) Find the cumulative distribution function;
[0019] The function expression for histogram equalization of an image is:
[0020]
[0021] Among them, k is the number of gray levels.
[0022] (4) Find the output gray level corresponding to each gray level;
[0023] The output grayscale is obtained through the inverse transformation process of the following formula:
[0024] r i =T -1 (S i ) (4)
[0025] (5) Map to the new image and obtain the histogram after equalization.
[0026] The original sample image is processed by histogram equalization so that the foreground and background features become more distinct, and then it is used as a new image sample and used as input for subsequent steps.
[0027] Step 2: construct a multi-target feature extraction network;
[0028] The present invention is based on the ResNeXt101 network and combines the FPN network to construct a multi-target feature extraction network structure, which consists of four parts: input layer, convolutional network, pooling layer and semantic feature enhancement layer. The specific parameter settings are as follows:
[0029] 2.1) Input layer design;
[0030] The sample image obtained in step 1 is further scaled and resized to 1024*1024. If the sample image is not a square, black pixels need to be filled on one side of its short side.
[0031] 2.2) Convolutional network design;
[0032] (1) Two convolutional layers are set in the first stage. The first layer has 64 7*7 convolution kernels with a convolution step of 2. This structure adds a ReLu activation function after the first layer. The second layer structure is exactly the same as the first layer, and is also composed of 64 7*7 convolution kernels with a convolution step of 2. A maximum pooling layer with a step of 2 and a receptive field of 2*2 is added between the second layer and the second stage network.
[0033] (2) In the second stage, first connect a convolution layer with 64 channels and a convolution kernel size of 1*1; then connect a convolution layer with 64 channels and a convolution kernel size of 3*3; and finally connect a convolution layer with 256 channels and a convolution kernel size of 1*1. These three layers are regarded as a whole parallel convolution layer, and in this stage, the cardinality of the branches is set to 32, and three whole convolution operations are performed continuously;
[0034] (3) The convolution operation in the third and fourth stages is the same as that in the second stage, but the number of channels of the convolution kernel in the third stage is twice that of the second stage, and the number of channels of the convolution kernel in the fourth stage is four times that of the second stage;
[0035] (4) In the fifth stage, the network structure is divided into two layers, namely the fully connected layer and the Dropout layer. The feature dimension of the fully connected layer output is 2048, the parameter of the Dropout layer is set to 0.5, and a ReLu activation function is added at the end.
[0036] 2.3) Pooling layer design;
[0037] The main parameters of the pooling layer include four aspects: pooling mode, pooling kernel size, sliding step size, and number of pooling types. The pooling mode of the present invention selects the maximum pooling mode. The size of the pooling kernel is related to the size of the extracted feature map. The present invention sets the pooling kernel size of the first four pooling layers Pool1, Pool2, Pool3, and Pool4 to 2*2. Because the feature map obtained after the pooling operation of the fifth pooling layer Pool5 needs to be used as the input data of the semantic feature enhancement layer, the pooling kernel size of Pool5 is set to 3*3. Finally, the sliding step size of the five pooling layers is 1, and the pooling type is valid. The valid type of pooling mode does not extract the boundary information of the feature matrix.
[0038] 2.4) Semantic feature enhancement layer;
[0039] This layer is composed of an FPN network, which uses bilinear interpolation to upsample the features of the 5 feature maps obtained by the 5 pooling layers by a factor of 2, so that the feature maps are doubled in size based on the original pixels, and then the deep and subtle feature information on the feature maps is extracted. At the same time, the number of channels of the feature maps input from the lower layer is changed through 1*1 convolution, and then the features extracted by upsampling and the corresponding elements after 1*1 convolution are added to achieve the effect of strengthening the semantic feature information.
[0040] Step 3: Design candidate bounding boxes and extract and classify target objects on the feature map;
[0041] The main function of this step is to locate the target object on the image. The principle is to use the feature map processed by the semantic feature enhancement layer in step 2.4) to generate multiple anchor suggestion boxes, then traverse the entire feature map to label the anchors, and then use the RPN region generation network to learn and distinguish the anchors. Finally, the position of the bounding box is determined according to the regression loss function of the candidate bounding box, and the category of the target object corresponding to the candidate bounding box is determined according to the classification loss function.
[0042] 3.1) Generate anchor candidate windows;
[0043] For each position on the feature map processed by the semantic feature enhancement layer, the present invention uses k=9 possible candidate window anchors as a set of reference windows of fixed size, that is, three regions {128 2 , 256 2 , 512 2} and all combinations of three scaling ratios {1:2, 1:1, 2:1}, the present invention uses these 9 templates for any sliding window position on any image;
[0044] 3.2) Traverse the feature map and calculate the image features;
[0045] The generated anchor candidate window is used as the initial detection frame and slides. Then, the center point of the sliding window corresponding to the center point of the true value calibration area of the original image is calculated according to the image size. The mapping relationship between the sliding window position and the original image position can be obtained through the center point and the width and height. From this, the overlapping area of the detection frame and the true calibration frame position on the original image can be obtained, and positive and negative labels are attached to the detection frame. The present invention sets a positive label if the overlapping area is greater than 70%, and a negative label if it is less than 30%, and then passes the labeled anchors to the RPN area generation network for learning and judging whether there is a target object. If there is a target object, it is marked by the candidate boundary box.
[0046] 3.3) Setting the candidate bounding box loss function;
[0047] The loss function of this step consists of two parts: regression loss function and classification loss function. The total loss function can be expressed as:
[0048]
[0049] Among them, N cls Indicates the number of foregrounds, N box represents the sum of pixels after the border regression; i represents the i-th proposed box in the iteration process; p i Indicates the probability of predicting the foreground (target object) or background; Indicates whether the predicted position is foreground or background. If it is foreground, then record Otherwise remember t i Represents the four-dimensional coordinate information of the proposed box, namely the center point coordinates, box width and box height t i =(x i ,y i ,w i ,h i ),and Represents the coordinate information of the target object that actually corresponds to the target object, recorded as λ represents the weight to balance the bounding box regression and classification losses.
[0050] The regression loss function is expressed as:
[0051]
[0052] in, The function calculation formula is:
[0053]
[0054] The classification loss function is expressed as:
[0055]
[0056] Step 4: Use the non-maximum suppression algorithm to remove redundant bounding boxes;
[0057] In step 3, for the same target object marked on the original image, multiple candidate bounding boxes are obtained. The present invention screens out the candidate bounding boxes through a non-maximum suppression algorithm. The specific process is as follows:
[0058] ① Sort all possible detection boxes according to the size of the confidence;
[0059] ②Put the detection box with the highest confidence in the output sequence;
[0060] ③ Calculate the ratio of the overlapping area between the detection window obtained in step ② and the remaining window;
[0061] ④ If the difference between the overlap area ratio obtained by the above calculation and the threshold T is greater than 0, the current window is considered to be the same target as the window obtained in step ②, and then the window is deleted;
[0062] ⑤ Return to step ① and loop until all default windows are processed;
[0063] ⑥The remaining window in the output sequence is the final detection result.
[0064] Step 5: Perform binary regression on the candidate bounding box to obtain the instance segmentation result;
[0065] The candidate bounding box obtained in step 4 and its corresponding feature map are passed into the fully connected layer network, and then connected to a binary regression function to obtain the instance segmentation result.
[0066] 5.1) Design a fully connected layer network;
[0067] The present invention connects three fully connected layers in series to form a small network to process the result obtained in step 4. The first two fully connected layers are both 256-channel, 14*14-sized fully connected layers, and the third fully connected layer is a 28*28 fully connected layer.
[0068] 5.2) Design a binary regression function;
[0069] In the calculation process of the binary regression function, the present invention only uses the channel loss when the region of interest is the real target object, and the other channels do not contribute to the loss of the function. When specifically calculating the binary regression function, its expression is as follows:
[0070]
[0071] Where m represents the image resolution; K represents the total number of channels; 1 k It is used to classify the target object in the kth channel. If it contributes to the loss, it is 1, otherwise it is 0; y represents the label value of the position, and its value is also either 0 or 1; sigmoid(x) represents the result of transforming the output value x through the sigmoid(x) function.
[0072] The above function is used to distinguish the target object and the background in the candidate bounding box, and segment the target object.
[0073] Preferably, the threshold value T of step ④ is 0.7.
[0074] The advantages of the present invention are:
[0075] The present invention provides a method for multi-target task instance segmentation in view of the current problems of low recognition accuracy, slow recognition efficiency and rough segmentation. First, the collected sample image is histogram-equalized to make its features more distinct; then, the preprocessed image is feature-extracted by constructing a multi-target feature extraction network; then, the target objects on the feature map are extracted and classified using candidate bounding boxes; then, the redundant bounding boxes are eliminated by the non-maximum suppression algorithm, and only the candidate bounding boxes with small deviations from the true calibration box and the highest confidence score are retained; finally, the fully connected layer is connected, and the candidate bounding boxes are regressed by binary masks to segment all the target tasks on the input image. Therefore, the present invention can improve the recognition accuracy, speed up the recognition efficiency, and use the binary regression function to segment the target object from the image, thereby solving the problem of rough segmentation. The inventive method can be applied to defect detection in the quality inspection process of manufacturing workshops, and can also be applied to the express sorting technology neighborhood of the logistics industry, and has certain application prospects. BRIEF DESCRIPTION OF THE DRAWINGS
[0076] FIG. 1a and FIG. 1b are comparisons of the results of sample images before and after histogram equalization, wherein FIG. 1a is a sample image without histogram equalization, and FIG. 1b is a sample image after histogram equalization;
[0077] Figure 2a to Figure 2b is the grayscale histogram used for histogram equalization, where Figure 2a is the grayscale value of the image, Figure 2b is based on Figure 2a The grayscale histogram produced;
[0078] Figure 3 is the histogram equalization transformation function;
[0079] Figure 4 It is an example diagram of the scaling operation of the input layer of the multi-objective feature extraction network of the present invention;
[0080] Figure 5 It is a design diagram of a semantic feature enhancement layer in a multi-objective feature extraction network of the present invention;
[0081] Figure 6 It is a multi-objective feature extraction network structure diagram of the present invention;
[0082] Figure 7 is a flow chart of candidate bounding box extraction and classification of the present invention;
[0083] Figure 8 It is a logic diagram of processing candidate boxes by the non-maximum suppression algorithm of the present invention;
[0084] Fig. 9 It is the technical roadmap of the present invention. DETAILED DESCRIPTION
[0085] In order to overcome the above-mentioned shortcomings of the prior art, the present invention provides a method for multi-target task instance segmentation in view of the current problems of low recognition accuracy, slow recognition efficiency and rough segmentation. First, the collected sample image is histogram equalized to make its features more distinct; then, the preprocessed image is feature extracted by constructing a multi-target feature extraction network; then, the target objects on the feature map are extracted and classified using candidate bounding boxes; then, redundant bounding boxes are eliminated by the non-maximum suppression algorithm, and only the candidate bounding boxes with small deviations from the true calibration box and the highest confidence score are retained; finally, the fully connected layer is connected, and the candidate bounding boxes are regressed by binary masks to segment all the target tasks on the input image.
[0086] To achieve the above object, the present invention adopts the following technical solutions:
[0087] A method for multi-objective task instance segmentation comprises the following steps:
[0088] Step 1: histogram equalization processing of sample image;
[0089] The histogram of an image shows the grayscale distribution of the image. When the grayscale of the histogram is concentrated in the low-value area, the image brightness is low; when the grayscale of the histogram is concentrated in the high-value area, the image brightness is high. When the histogram is concentrated in the middle value area, a low-contrast image is obtained; when the histogram is distributed more evenly and widely, a high-contrast image is obtained. Therefore, the method of making the grayscale of the image evenly distributed can be used to improve the contrast of the image and make the image clear.
[0090] The specific steps of histogram equalization are as follows:
[0091] (1) Count the gray levels of the histogram;
[0092] First, let the variable r represent the gray level of the pixel in the image and normalize the gray level. If the gray level of the image is {0, 1, 2, …, L-1}, then
[0093]
[0094] Among them, 0≤r≤1, L is the number of gray levels.
[0095] (2) Calculate the corresponding probability density;
[0096] Because the grayscale of the image pixels is randomly distributed between [0,1], the probability density function can be used to represent the distribution of the grayscale of the image. k Represents discrete grayscale, using P r (r k ) represents the grayscale r k Probability of occurrence:
[0097]
[0098] Among them, n k For the image where r appears k The number of pixels of this grayscale, n is the total number of pixels in the image, and n k / n is the frequency in probability theory.
[0099] (3) Find the cumulative distribution function;
[0100] The function expression for histogram equalization of an image is:
[0101]
[0102] Among them, k is the number of gray levels.
[0103] (4) Find the output gray level corresponding to each gray level;
[0104] The output grayscale is obtained through the inverse transformation process of the following formula:
[0105] r i =T -1 (S i ) (4)
[0106] (5) Map to the new image and obtain the histogram after equalization.
[0107] The original sample image is processed by histogram equalization so that the foreground and background features become more distinct, and then it is used as a new image sample and used as the input of the following steps.
[0108] Step 2: construct a multi-target feature extraction network;
[0109] The present invention is based on the ResNeXt101 network and combines the FPN network to construct a multi-target feature extraction network structure, which consists of four parts: input layer, convolutional network, pooling layer and semantic feature enhancement layer. The specific parameter settings are as follows:
[0110] 2.1) Design the input layer;
[0111] The sample image obtained in step 1 is further scaled and resized to 1024*1024. If the sample image is not a square, black pixels need to be filled on one side of its short side.
[0112] 2.2) Design a convolutional network;
[0113] (1) Two convolutional layers are set in the first stage. The first layer has 64 7*7 convolution kernels with a convolution step of 2. This structure adds a ReLu activation function after the first layer. The second layer structure is exactly the same as the first layer, and is also composed of 64 7*7 convolution kernels with a convolution step of 2. A maximum pooling layer with a step of 2 and a receptive field of 2*2 is added between the second layer and the second stage network.
[0114] (2) In the second stage, first connect a convolution layer with 64 channels and a convolution kernel size of 1*1; then connect a convolution layer with 64 channels and a convolution kernel size of 3*3; and finally connect a convolution layer with 256 channels and a convolution kernel size of 1*1. These three layers are regarded as a whole parallel convolution layer, and in this stage, the cardinality of the branches is set to 32, and three whole convolution operations are performed continuously;
[0115] (3) The convolution operation in the third and fourth stages is the same as that in the second stage, but the number of channels of the convolution kernel in the third stage is twice that of the second stage, and the number of channels of the convolution kernel in the fourth stage is four times that of the second stage;
[0116] (4) In the fifth stage, the network structure is divided into two layers, namely the fully connected layer and the Dropout layer. The feature dimension of the fully connected layer output is 2048, the parameter of the Dropout layer is set to 0.5, and a ReLu activation function is added at the end.
[0117] 2.3) Design the pooling layer;
[0118] The main parameters of the pooling layer include four aspects: pooling mode, pooling kernel size, sliding step size, and number of pooling types. The pooling mode of the present invention selects the maximum pooling mode. The size of the pooling kernel is related to the size of the extracted feature map. The present invention sets the pooling kernel size of the first four pooling layers Pool1, Pool2, Pool3, and Pool4 to 2*2. Because the feature map obtained after the pooling operation of the fifth pooling layer Pool5 needs to be used as the input data of the semantic feature enhancement layer, the pooling kernel size of Pool5 is set to 3*3. Finally, the sliding step size of the five pooling layers is 1, and the pooling type is valid. The valid type of pooling mode does not extract the boundary information of the feature matrix.
[0119] 2.4) Semantic feature enhancement layer;
[0120] This layer is composed of an FPN network, which uses bilinear interpolation to upsample the features of the 5 feature maps obtained by the 5 pooling layers by a factor of 2, so that the feature maps are doubled in size based on the original pixels, and then the deep and subtle feature information on the feature maps is extracted. At the same time, the number of channels of the feature maps input from the lower layer is changed through 1*1 convolution, and then the features extracted by upsampling and the corresponding elements after 1*1 convolution are added to achieve the effect of strengthening the semantic feature information.
[0121] Step 3: Design candidate bounding boxes and extract and classify target objects on the feature map;
[0122] The main function of this step is to locate the target object on the image. The principle is to use the feature map processed by the semantic feature enhancement layer in step 2.4) to generate multiple anchor suggestion boxes, then traverse the entire feature map to label the anchors, and then use the RPN region generation network to learn and distinguish the anchors. Finally, the position of the bounding box is determined according to the regression loss function of the candidate bounding box, and the category of the target object corresponding to the candidate bounding box is determined according to the classification loss function.
[0123] 3.1) Generate anchor candidate windows;
[0124] For each position on the feature map processed by the semantic feature enhancement layer, the present invention uses k=9 possible candidate window anchors as a set of reference windows of fixed size, that is, three regions {128 2 , 256 2 , 512 2} and all combinations of three scaling ratios {1:2, 1:1, 2:1}, the present invention uses these 9 templates for any sliding window position on any image;
[0125] 3.2) Traverse the feature map and calculate the image features;
[0126] The generated anchor candidate window is used as the initial detection frame and slides. Then, the center point of the sliding window corresponding to the center point of the true value calibration area of the original image is calculated according to the image size. The mapping relationship between the sliding window position and the original image position can be obtained through the center point and the width and height. From this, the overlapping area of the detection frame and the true calibration frame position on the original image can be obtained, and positive and negative labels are attached to the detection frame. The present invention sets a positive label if the overlapping area is greater than 70%, and a negative label if it is less than 30%, and then passes the labeled anchors to the RPN area generation network for learning and judging whether there is a target object. If there is a target object, it is marked by the candidate boundary box.
[0127] 3.3) Setting the candidate bounding box loss function;
[0128] The loss function of this step consists of two parts: regression loss function and classification loss function. The total loss function can be expressed as:
[0129]
[0130] Among them, N cls Indicates the number of foregrounds, N box represents the sum of pixels after the border regression; i represents the i-th proposed box in the iteration process; p i Indicates the probability of predicting the foreground (target object) or background; Indicates whether the predicted position is foreground or background. If it is foreground, then record Otherwise remember t i Represents the four-dimensional coordinate information of the proposed box, namely the center point coordinates, box width and box height t i =(x i ,y i ,w i ,h i ),and Represents the coordinate information of the target object that actually corresponds to the target object, recorded as λ represents the weight to balance the bounding box regression and classification losses.
[0131] The regression loss function is expressed as:
[0132]
[0133] in, The function calculation formula is:
[0134]
[0135] The classification loss function is expressed as:
[0136]
[0137] Step 4: Use the non-maximum suppression algorithm to remove redundant bounding boxes;
[0138] In step 3, for the same target object marked on the original image, multiple candidate bounding boxes are obtained. The present invention screens out the candidate bounding boxes through a non-maximum suppression algorithm. The specific process is as follows:
[0139] ① Sort all possible detection boxes according to the size of the confidence;
[0140] ②Put the detection box with the highest confidence in the output sequence;
[0141] ③ Calculate the ratio of the overlapping area between the detection window obtained in step ② and the remaining window;
[0142] ④ If the difference between the overlap area ratio obtained by the above calculation and the threshold T (T=0.7 in the present invention) is greater than 0, the current window is considered to be the same target as the window obtained in step ②, and then the window is deleted;
[0143] ⑤ Return to step ① and loop until all default windows are processed;
[0144] ⑥The remaining window in the output sequence is the final detection result.
[0145] Step 5: Perform binary regression on the candidate bounding box to obtain the instance segmentation result;
[0146] The candidate bounding box obtained in step 4 and its corresponding feature map are passed into the fully connected layer network, and then connected to a binary regression function to obtain the instance segmentation result.
[0147] 5.1) Design a fully connected layer network;
[0148] The present invention connects three fully connected layers in series to form a small network to process the result obtained in step 4. The first two fully connected layers are both 256-channel, 14*14-sized fully connected layers, and the third fully connected layer is a 28*28 fully connected layer.
[0149] 5.2) Design a binary regression function;
[0150] In the calculation process of the binary regression function, the present invention only uses the channel loss when the region of interest is the real target object, and the other channels do not contribute to the loss of the function. When specifically calculating the binary regression function, its expression is as follows:
[0151]
[0152] Where m represents the image resolution; K represents the total number of channels; 1 k It is used to classify the target object in the kth channel. If it contributes to the loss, it is 1, otherwise it is 0; y represents the label value of the position, and its value is also either 0 or 1; sigmoid(x) represents the result of transforming the output value x through the sigmoid(x) function.
[0153] The above function is used to distinguish the target object and the background in the candidate bounding box, and segment the target object.
[0154] The advantages of the present invention are:
[0155] The present invention provides a method for multi-target task instance segmentation in view of the current problems of low recognition accuracy, slow recognition efficiency and rough segmentation. First, the collected sample image is histogram-equalized to make its features more distinct; then, the preprocessed image is feature-extracted by constructing a multi-target feature extraction network; then, the target objects on the feature map are extracted and classified using candidate bounding boxes; then, the redundant bounding boxes are eliminated by the non-maximum suppression algorithm, and only the candidate bounding boxes with small deviations from the true calibration box and the highest confidence score are retained; finally, the fully connected layer is connected, and the candidate bounding boxes are regressed by binary masks to segment all the target tasks on the input image. Therefore, the present invention can improve the recognition accuracy, speed up the recognition efficiency, and use the binary regression function to segment the target object from the image, thereby solving the problem of rough segmentation. The inventive method can be applied to defect detection in the quality inspection process of manufacturing workshops, and can also be applied to the express sorting technology neighborhood of the logistics industry, and has certain application prospects.
[0156] The contents described in the embodiments of this specification are merely an enumeration of the implementation forms of the inventive concept. The protection scope of the present invention should not be regarded as limited to the specific forms described in the embodiments. The protection scope of the present invention also extends to equivalent technical means that can be conceived by those skilled in the art based on the inventive concept.
Claims
1. A method for multi-objective task instance segmentation, comprising the following steps: Step 1: histogram equalization of sample images; specifically including: (1) Count the gray levels of the histogram; First, let the variable r represent the gray level of the pixel in the image and normalize the gray level. If the gray level of the image is {0,1,2,...,L-1}, then Among them, 0≤r≤1, L is the number of gray levels; (2) Calculate the corresponding probability density; The pixel gray levels of the image are randomly distributed between [0,1], and the probability density function is used to represent the distribution of the image gray levels; in discrete form, r k Represents discrete grayscale, using P r (r k ) represents the grayscale r k Probability of occurrence: Among them, n k For the image where r appears k The number of pixels of this grayscale, n is the total number of pixels in the image, and n k / n indicates frequency; (3) Find the cumulative distribution function; The function expression for histogram equalization of an image is: Where k is the gray level; (4) Find the output gray level corresponding to each gray level; The output grayscale is obtained through the inverse transformation process of the following formula: r i =T -1 (S i ) (4) (5) Mapping to a new image to obtain a histogram after equalization processing; The original sample image is processed by histogram equalization to make the foreground and background features more distinct, and then it is used as a new image sample as input for subsequent steps; Step 2: construct a multi-target feature extraction network; Based on the ResNeXt101 network, a multi-target feature extraction network structure is constructed in combination with the FPN network. The multi-target feature extraction network structure consists of four parts: input layer, convolutional network, pooling layer and semantic feature enhancement layer. The specific parameter settings are as follows: 2.1) Design the input layer; The sample image obtained in step 1 is further scaled and resized to 1024*1024. If the sample image is not a square, black pixels need to be filled on one side of its short side. 2.2) Design a convolutional network; 1) In the first stage, two convolutional layers are set. The first layer has 64 7*7 convolution kernels with a convolution step of 2. This structure adds a ReLu activation function after the first layer. The second layer structure is exactly the same as the first layer, and is also composed of 64 7*7 convolution kernels with a convolution step of 2. A maximum pooling layer with a step of 2 and a receptive field of 2*2 is added between the second layer and the second stage network. 2) In the second stage, first connect a convolution layer with 64 channels and a convolution kernel size of 1*1; then connect a convolution layer with 64 channels and a convolution kernel size of 3*3; finally connect a convolution layer with 256 channels and a convolution kernel size of 1*1; regard these three layers as a whole parallel convolution layer, and set the branch cardinality to 32 at this stage, and perform three overall convolution operations continuously; 3) The convolution operation mode of the third and fourth stages is the same as that of the second stage, but the number of channels of the convolution kernel in the third stage is twice that of the second stage, and the number of channels of the convolution kernel in the fourth stage is four times that of the second stage; 4) In the fifth stage, the network structure is divided into two layers, namely the fully connected layer and the Dropout layer. The feature dimension of the fully connected layer output is 2048, the parameter of the Dropout layer is set to 0.5, and a ReLu activation function is added at the end; 2.3) Design the pooling layer; The parameters of the pooling layer include four aspects: pooling mode, pooling kernel size, sliding step size, and number of pooling types; the pooling mode selects the maximum pooling mode; the size of the pooling kernel is related to the size of the extracted feature map, and the pooling kernel size of the first four pooling layers Pool1, Pool2, Pool3, and Pool4 are all set to 2*2. Because the feature map obtained after the pooling operation of the fifth pooling layer Pool5 needs to be used as the input data of the semantic feature enhancement layer, the pooling kernel size of Pool5 is set to 3*3; finally, the sliding step size of the five pooling layers is 1, and the pooling type is valid. The valid type of pooling does not extract the boundary information of the feature matrix; 2.4) Semantic feature enhancement layer; It is composed of an FPN network. It uses bilinear interpolation to upsample the features of the 5 feature maps obtained by the 5 pooling layers by 2 times, so that the feature map is doubled on the basis of the original pixels. Then, the deep and subtle feature information on the feature map is extracted. At the same time, the number of channels of the feature map input from the lower layer is changed by 1*1 convolution. Then, the features extracted by upsampling and the corresponding elements after 1*1 convolution are added to achieve the effect of strengthening the semantic feature information. Step 3: Design candidate bounding boxes and extract and classify target objects on the feature map; It is used to locate the target object on the image. The principle is to use the feature map processed by the semantic feature enhancement layer in step 2.4) to generate multiple anchor suggestion boxes, then traverse the entire feature map to label the anchors, and then use the RPN region generation network to learn and distinguish the anchors. Finally, the position of the bounding box is determined according to the regression loss function of the candidate bounding box, and the category of the target object corresponding to the candidate bounding box is determined according to the classification loss function. 3.1) Generate anchor candidate windows; For each position on the feature map processed by the semantic feature enhancement layer, k = 9 possible candidate window anchors are used as a set of reference windows of fixed size, that is, the three regions {128 2 , 256 2 , 512 2 } and all combinations of three scaling ratios {1:2, 1:1, 2:1}, the present invention uses these 9 templates for any sliding window position on any image; 3.2) Traverse the feature map and calculate the image features; The generated anchor candidate window is used as the initial detection frame and slides. Then, according to the image size, the center point of the sliding window is calculated to correspond to the center point of the true value calibration area of the original image. The mapping relationship between the sliding window position and the original image position can be obtained through the center point and the width and height. From this, the overlapping area between the detection frame and the true calibration frame position on the original image can be calculated, and positive and negative labels are attached to the detection frame at the same time; if the overlapping area is greater than 70%, a positive label is attached, and if it is less than 30%, a negative label is attached. Then, the labeled anchors are passed to the RPN area generation network for learning and judging whether there is a target object. If there is a target object, it is marked by the candidate bounding box; 3.3) Setting the candidate bounding box loss function; The loss function of this step consists of two parts: regression loss function and classification loss function. The total loss function can be expressed as: Among them, N cls Indicates the number of foregrounds, N box represents the sum of pixels after the border regression; i represents the i-th proposed box in the iteration process; p i Indicates the probability of predicting the foreground (target object) or background; Indicates whether the predicted position is foreground or background. If it is foreground, then record Otherwise remember t i Represents the four-dimensional coordinate information of the proposed box, namely the center point coordinates, box width and box height t i =(x i ,y i ,w i ,h i ),and Represents the coordinate information of the target object that actually corresponds to the target object, recorded as λ represents the weight for balancing bounding box regression and classification losses; The regression loss function is expressed as: in, The function calculation formula is: The classification loss function is expressed as: Step 4: Use the non-maximum suppression algorithm to remove redundant bounding boxes; In step 3, for the same target object marked on the original image, multiple candidate bounding boxes will be obtained. The candidate bounding boxes are screened out by the non-maximum suppression algorithm. The specific process is as follows: ① Sort all possible detection boxes according to the size of the confidence; ②Put the detection box with the highest confidence in the output sequence; ③ Calculate the ratio of the overlapping area between the detection window obtained in step ② and the remaining window; ④ If the difference between the overlap area ratio obtained by the above calculation and the threshold T is greater than 0, the current window is considered to be the same target as the window obtained in step ②, and then the window is deleted; ⑤ Return to step ① and loop until all default windows are processed; ⑥The remaining window in the output sequence is the final detection result; Step 5: Perform binary regression on the candidate bounding box to obtain the instance segmentation result; The candidate bounding box obtained in step 4 and its corresponding feature map are passed into the fully connected layer network, and then connected to a binary regression function to obtain the instance segmentation result; 5.1) Design a fully connected layer network; Connect three fully connected layers in series to form a small network to process the results obtained in step 4; the first two fully connected layers are 256-channel, 14*14-sized fully connected layers, and the third fully connected layer is a 28*28 fully connected layer; 5.2) Design a binary regression function; In the calculation process of the binary regression function, only the channel loss when the region of interest is the real target object is used, and the other channels do not contribute to the loss of the function; when the binary regression function is specifically calculated, its expression is as follows: Where m represents the image resolution; K represents the total number of channels; 1 k Used to classify the target object in the kth channel. If it contributes to loss, it is 1, otherwise it is 0; y represents the label value of the position, and its value is also either 0 or 1; sigmoid(x) represents the result of transforming the output value x through the sigmoid(x) function; The above function is used to distinguish the target object and the background in the candidate bounding box, and segment the target object.
2. The method for multi-objective task instance segmentation according to claim 1, characterized in that: The threshold value of step ④ is T=0.7.
