A weakly supervised image segmentation method based on box annotation
Through the weak supervision method based on box annotation, combined with the vector guidance, point guidance and plane guidance of the deep learning model, the problem of high pixel-level annotation cost in image segmentation is solved, and efficient image segmentation effect is achieved, which is close to fully supervised performance.
Patent Information
- Application Number
- CN202111257634.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-27
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2041-10-27
AI Technical Summary
The application of image segmentation in the field of computer vision is limited by the high cost and strictness of pixel-level annotation, which results in high computational costs and difficulty in achieving widespread application.
A weak supervision method based on box annotation is used to perform image segmentation through vector guidance, point guidance and plane guidance, combined with a deep learning model to reduce annotation costs and achieve practical performance.
This method significantly reduces the annotation cost, achieves excellent quantitative and qualitative results, is close to fully supervised performance, proves the feasibility of box annotation in saliency detection, and can be quickly applied to other fully supervised models.
Smart Images

Figure CN113971678B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a weakly supervised image segmentation method based on frame annotation, and belongs to the field of computer vision. Background Art
[0002] Image segmentation is a key component of image understanding and promotes deep applications in the field of computer vision, such as autonomous driving, pose estimation, and image synthesis. In these practical applications, image segmentation is often superior to object detection because an object mask will be more accurate than an object box. Even if some practical applications require an object box, we can get the object box by taking the circumscribed rectangular box of the object mask, and the additional computational cost for the entire model is almost negligible. However, in many real-world situations, image segmentation is not as widely used as object detection. In actual use, we found that the main obstacle to image segmentation is not the speed and accuracy of real-time processing, but the more stringent pixel-level annotation. Pixel-level annotation is to label each pixel in the image with a certain category, so this annotation method requires a lot of manpower, time, and financial support. In order to alleviate the limitation of high annotation cost on the practicality of image segmentation, we use a low-quality annotation, object box annotation, to achieve weak supervision training of image segmentation model and meet practical performance requirements. Summary of the invention
[0003] Purpose of the invention: To propose a weakly supervised image segmentation method based on box annotation, to implement a weakly supervised training image segmentation model and meet practical performance requirements.
[0004] Technical solution: A weakly supervised image segmentation method based on box annotation, comprising the following steps:
[0005] Step 1: Initialize input: Complete image conversion into deep learning data;
[0006] Step 2: Build a deep learning model: Build an end-to-end image segmentation model;
[0007] Step 3: Normalize output: Output the calculation results of the deep learning model.
[0008] According to one aspect of the present invention, the initialization input in step 1 is specifically:
[0009] Step 11, data input: first transfer the image to the computer;
[0010] Step 12, data enhancement: Do some special processing on the image, including random changes in image size, random flipping of the image, random changes in image color, and random cropping of the image. By using these data enhancements, the image style is enriched as much as possible on the basis of the original image to fit various actual changes in real scenes;
[0011] Step 13: Data conversion: Use the image reading code to convert image data into deep learning data.
[0012] According to one aspect of the present invention, the specific steps of establishing the deep learning model in step 2 are as follows:
[0013] Step 21, define the model structure: define the structure and order relationship of each module in the model;
[0014] Step 22: Implement the model structure: Based on the Pytorch code library, implement the corresponding model structure in order according to the definition;
[0015] Step 23, compile model: code compilation process, determine whether there are problems in the current implementation process;
[0016] Step 24. Configure the model: set model parameters and hyperparameters.
[0017] According to one aspect of the present invention, the deep learning model structure includes the following three layers:
[0018] Convolution layer: Perform multiple convolution operations on multi-channel inputs. Each convolution produces an output of one channel, so multiple channels of output can be obtained. The convolution is defined as:
[0019]
[0020] Where z[x,y] is the calculation result, g[x,y] is the input data, f[x,y] is the convolution kernel, and * indicates the convolution operation;
[0021] Activation layer: Each input value is modified by the activation function to obtain an output of the same size. This function uses the Relu function:
[0022] f(x)=max(0,x);
[0023] Pooling layer: Sample the input data proportionally, and its sampling method is expressed as:
[0024] f(X)=max([X]).
[0025] According to one aspect of the present invention, the normalized output in step 3 includes two stages, a training stage and an application stage.
[0026] According to one aspect of the present invention, the image segmentation processing method in the training stage specifically comprises the following steps:
[0027] Step 31: convert the annotation of the target box into an image representation, wherein the area inside the target box is set to 1 and the area outside the box is set to 0;
[0028] Step 32: Three methods are used to guide the model to learn the target information provided by the target box. The three guidance methods are vector guidance, point guidance and plane guidance.
[0029] Step 33: Integrate the errors and losses caused by the three guidance methods. According to the principle of gradient back propagation, pass the errors and losses layer by layer to the basic computing operations of each deep learning. Then, through the gradient descent method, the parameters of each basic computing operation converge in a better direction, gradually reduce the errors and losses, and make the model achieve the best performance and the best results.
[0030] According to one aspect of the present invention, the vector guidance method guides the model to learn the target information provided by the target box as follows:
[0031] Step 41: Perform vector projection of the target frame on the original image, and perform horizontal and vertical projections respectively. The projection method is to take the maximum value in each direction. The specific calculation method is as follows:
[0032] l x =Vect x (l) = max x (l),
[0033] l y =Vect y (l) = max y (l);
[0034] Step 42, through this projection method, the two-dimensional target annotation is mapped to one-dimensional target guidance information;
[0035] Step 43, this paper then uses the same method to map the calculation results of the previous deep learning model to the corresponding horizontal and vertical prediction vectors;
[0036] Step 44, this paper then calculates the respective errors by combining the horizontal and vertical target guidance information with their corresponding prediction vectors, and the loss function adopts binary cross entropy or Dice loss:
[0037]
[0038] According to one aspect of the present invention, the point guidance method provides clear guidance information for one or more points, so that the model learns specific target features from the guidance information of these points, and strengthens the model's emphasis on these points during training, that is, taking the minimum and maximum values of the prediction images inside and outside the box respectively, and making their two values tend to the background class 0 value, and the loss calculation formula is as follows:
[0039]
[0040] According to one aspect of the present invention, the plane guidance method is specifically:
[0041] Step 51: First, calculate the color similarity of each pixel pair on the original image, and take the pixel pairs with similar colors as positive samples. The color similarity is calculated as follows:
[0042]
[0043] Step 52: Then, the same method is used to calculate the probability similarity for the predicted mask. The probability similarity is calculated as follows:
[0044]
[0045] Step 53, finally, the probability similarity of the positive samples is made consistent, and the loss of the plane guidance is calculated as follows:
[0046]
[0047] According to one aspect of the present invention, the application stage directly uses the model trained in this article for reasoning, and then performs color filling on the reasoning result. The color filling method is: the predicted probability obtained by reasoning is distributed to [0,255] to meet the display requirements of image pixels.
[0048] Beneficial effects: This method proves the feasibility of box annotation in saliency detection tasks; this method obtains excellent results through vector guidance, point guidance and plane guidance; Figure 3 and Figure 4 As shown, our method outperforms other weakly supervised saliency models and is close to fully supervised methods under both quantitative and qualitative analysis; the method can be quickly applied to other fully supervised saliency models. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] Figure 1 It is a flow chart of the weakly supervised image segmentation method based on box annotation.
[0050] Figure 2 It is a model structure diagram of deep learning.
[0051] Figure 3This is a comparison chart of the evaluation results of weakly supervised image segmentation methods based on box annotation.
[0052] Figure 4 This is a comparison chart of the experimental results. DETAILED DESCRIPTION
[0053] like Figure 1 As shown, in this embodiment, a weakly supervised image segmentation method based on box annotation includes the following steps:
[0054] Step 1: Initialize input: Complete image conversion into deep learning data;
[0055] Step 2: Build a deep learning model: Build an end-to-end image segmentation model;
[0056] Step 3: Normalize output: Output the calculation results of the deep learning model.
[0057] In a further embodiment, the initialization input in step 1 is specifically:
[0058] Step 11, data input: first transfer the image to the computer;
[0059] Step 12, data enhancement: Do some special processing on the image, including random changes in image size, random flipping of the image, random changes in image color, and random cropping of the image. By using these data enhancements, the image style is enriched as much as possible on the basis of the original image to fit various actual changes in real scenes;
[0060] Step 13: Data conversion: Use the image reading code to convert image data into deep learning data.
[0061] In a further embodiment, the specific steps of establishing the deep learning model in step 2 are as follows:
[0062] Step 21, define the model structure: define the structure and order relationship of each module in the model;
[0063] Step 22: Implement the model structure: Based on the Pytorch code library, implement the corresponding model structure in order according to the definition;
[0064] Step 23, compile model: code compilation process, determine whether there are problems in the current implementation process;
[0065] Step 24. Configure the model: set model parameters and hyperparameters.
[0066] In a further embodiment, Figure 2 As shown, the deep learning model structure includes the following three layers:
[0067] Convolution layer: Perform multiple convolution operations on multi-channel inputs. Each convolution produces an output of one channel, so multiple channels of output can be obtained. The convolution is defined as:
[0068]
[0069] Where z[x,y] is the calculation result, g[x,y] is the input data, f[x,y] is the convolution kernel, and * indicates the convolution operation;
[0070] Activation layer: Each input value is modified by the activation function to obtain an output of the same size. This function uses the Relu function:
[0071] f(x)=max(0,x);
[0072] Pooling layer: Sample the input data proportionally, and its sampling method is expressed as:
[0073] f(X)=max([X]).
[0074] In a further embodiment, the normalized output in step 3 includes two stages, a training stage and an application stage.
[0075] In a further embodiment, the specific steps of the image segmentation processing method in the training phase are:
[0076] Step 31: convert the annotation of the target box into an image representation, wherein the area inside the target box is set to 1 and the area outside the box is set to 0;
[0077] Step 32: Three methods are used to guide the model to learn the target information provided by the target box. The three guidance methods are vector guidance, point guidance and plane guidance.
[0078] Step 33: Integrate the errors and losses caused by the three guidance methods. According to the principle of gradient back propagation, pass the errors and losses layer by layer to the basic computing operations of each deep learning. Then, through the gradient descent method, the parameters of each basic computing operation converge in a better direction, gradually reduce the errors and losses, and make the model achieve the best performance and the best results.
[0079] In a further embodiment, the vector guidance method guides the model to learn the target information provided by the target box as follows:
[0080] Step 41: Perform vector projection of the target frame on the original image, and perform horizontal and vertical projections respectively. The projection method is to take the maximum value in each direction. The specific calculation method is as follows:
[0081] l x =Vect x (l) = max x(l),
[0082] l y =Vect y (l) = max y (l);
[0083] Step 42, through this projection method, the two-dimensional target annotation is mapped to one-dimensional target guidance information;
[0084] Step 43, this paper then uses the same method to map the calculation results of the previous deep learning model to the corresponding horizontal and vertical prediction vectors;
[0085] Step 44, this paper then calculates the respective errors by combining the horizontal and vertical target guidance information with their corresponding prediction vectors, and the loss function adopts binary cross entropy or Dice loss:
[0086]
[0087] In a further embodiment, the point guidance method provides clear guidance information for one or more points, so that the model learns specific target features from the guidance information of these points, and strengthens the model's emphasis on these points during training, that is, taking the minimum and maximum values of the prediction images inside and outside the box respectively, and making them tend to the background class 0 value, and the loss calculation formula is as follows:
[0088]
[0089] In a further embodiment, the plane guidance method is specifically:
[0090] Step 51: First, calculate the color similarity of each pixel pair on the original image, and take the pixel pairs with similar colors as positive samples. The color similarity is calculated as follows:
[0091]
[0092] Step 52: Then, the same method is used to calculate the probability similarity for the predicted mask. The probability similarity is calculated as follows:
[0093]
[0094] Step 53, finally, the probability similarity of the positive samples is made consistent, and the loss of the plane guidance is calculated as follows:
[0095]
[0096] In a further embodiment, the application stage directly uses the model trained in this article for reasoning, and then performs color filling on the reasoning result. The color filling method is: distribute the predicted probability obtained by reasoning to [0,255] to meet the display requirements of image pixels.
[0097] The preferred embodiments of the present invention are described in detail above; however, the present invention is not limited to the specific details in the above embodiments. Within the technical concept of the present invention, various equivalent transformations can be made to the technical solutions of the present invention, and these equivalent transformations all belong to the protection scope of the present invention.
Claims
1. A weakly supervised image segmentation method based on box annotation, characterized in that: The steps include: Step 1: Initialize input: Complete image conversion into deep learning data; Step 2: Build a deep learning model: Build an end-to-end image segmentation model; Step 3, normalized output: output the calculation results of the deep learning model; the normalized output includes a training phase and an application phase, wherein: the specific steps of the image segmentation processing method in the training phase are: Step 31: convert the annotation of the target box into an image representation, wherein the area inside the target box is set to 1 and the area outside the box is set to 0; Step 32: Three methods are used to guide the model to learn the target information provided by the target box. The three guidance methods are vector guidance, point guidance and plane guidance. Step 33: Integrate the errors and losses brought by the three guidance methods, and according to the principle of gradient back propagation, pass the errors and losses layer by layer to the basic calculation operations of each deep learning, and then use the gradient descent method to make the parameters of each basic calculation operation converge in a better direction, gradually reduce the errors and losses, and make the model achieve the best performance and the best results; The vector guidance method guides the model to learn the target information provided by the target box, which is specifically implemented as follows: Perform vector projection of the target frame on the original image, and perform horizontal and vertical projections respectively. The projection method is to take the maximum value in each direction. The specific calculation method is as follows: l x =Vect x (l)=max x (l); l y =Vect y (l)=max y (l); Through this projection method, the two-dimensional target annotation is mapped to one-dimensional target guidance information; Then this paper uses the same method to map the calculation results of the previous deep learning model to the corresponding horizontal and vertical prediction vectors; After that, this paper uses the horizontal and vertical target guidance information and its corresponding prediction vector to calculate their respective errors, and the loss function uses binary cross entropy or Dice loss: The point guidance method provides clear guidance information for one or more points, so that the model can learn specific target features from the guidance information of these points, and strengthen the model's emphasis on these points during training, that is, take the minimum and maximum values of the prediction images inside and outside the box respectively, and make their two values tend to the background class 0 value. The loss calculation formula is as follows: The specific planar guidance method is: First, the color similarity of each pixel pair is calculated on the original image, and the pixel pairs with similar colors are regarded as positive samples. The color similarity is calculated as follows: Then the same method is used to calculate the probability similarity for the predicted mask. The probability similarity is calculated as follows: Finally, the probability similarity of the positive samples is made consistent, and the loss of plane guidance is calculated as follows: The application stage directly uses the model trained in this article for inference, and then fills the inference result with color. The color filling method is as follows: the predicted probability obtained by inference is distributed to [0, 255] to meet the display requirements of image pixels.
2. The weakly supervised image segmentation method based on box annotation according to claim 1, characterized in that: The initialization input in step 1 is specifically: Step 11, data input: first transfer the image to the computer; Step 12, data enhancement: Do some special processing on the image, including random changes in image size, random flipping of the image, random changes in image color, and random cropping of the image. By using these data enhancements, the image style is enriched as much as possible on the basis of the original image to fit various actual changes in real scenes; Step 13: Data conversion: Use image reading code to convert image data into deep learning data.
3. The weakly supervised image segmentation method based on box annotation according to claim 1, characterized in that: The specific steps of establishing the deep learning model in step 2 are as follows: Step 21, define the model structure: define the structure and order relationship of each module in the model; Step 22: Implement the model structure: Based on the Pytorch code library, implement the corresponding model structure in order according to the definition; Step 23, compile model: code compilation process, determine whether there are problems in the current implementation process; Step 24. Configure the model: set model parameters and hyperparameters.
4. The weakly supervised image segmentation method based on box annotation according to claim 3 is characterized in that: The deep learning model structure includes the following three layers: Convolution layer: Perform multiple convolution operations on multi-channel inputs. Each convolution produces an output of one channel, and multiple channels are output. The convolution is defined as: Where z[x,y] is the calculation result, g[x,y] is the input data, f[x,y] is the convolution kernel, and * indicates the convolution operation; Activation layer: Each input value is modified by the activation function to obtain an output of the same size. This function uses the Relu function: f(x)=max(0,x); Pooling layer: Sample the input data proportionally, and its sampling method is expressed as: f(X)=max([X]).
Citation Information
Patent Citations
Tunnel surface defect segmentation method based on deep learning
CN111507990A
