A method and apparatus for constructing a four-point detection model for labels
Patent Information
- Application Number
- CN202310958596.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-31
- Publication Date
- 2026-09-01
- Estimated Expiration
- 2043-07-31
AI Technical Summary
[0005]发明目的:本发明的一个目的在于提供一种标签四点检测模型构建方法,能够解决现有基于anchor-free目标检测方法所存在的检测效果差、精度低、效率低以及无法准确识别目标标签四点角点的问题
[0034](1)本发明的标签四点检测模型训练简易,能够有效检测不规则四边形目标并精确输出不规则四边形的四个角点的坐标,检测速度快、准确度高且实用性强;
Smart Images

Figure CN116993969B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to target detection technology, specifically to a method and apparatus for constructing a four-point detection model for labels. Background Technology
[0002] With the rapid development of artificial intelligence and deep learning, computer vision technologies such as object detection have been widely applied in various industries and have played an important role. Among them, anchor-free object detection technologies, represented by FoveaBox and FCOS, have changed the status quo that most object detection algorithms had to use anchor boxes, greatly reducing the complexity of the model and the amount of output.
[0003] Specifically, compared to anchor-based methods, the biggest advantage of anchor-free methods lies in their high detection speed and model efficiency. This is because the method does not require pre-designing anchors; it only needs to regress the target center point, height, and width in feature maps at different scales. This significantly reduces the model's time consumption and computational cost.
[0004] However, the overall detection accuracy of existing anchor-free methods cannot reach that of the best models in anchor-based methods. Furthermore, they present significant challenges for detecting labels on irregular quadrilaterals, such as inaccurate detection and the inability to accurately identify the four corner points of the target label. Currently, most common detection algorithms regress bounding boxes, but based on engineering experience, bounding box localization is less accurate than corner point localization. Summary of the Invention
[0005] Purpose of the invention: One purpose of this invention is to provide a method for constructing a four-point detection model for labels, which can solve the problems of poor detection effect, low accuracy, low efficiency and inability to accurately identify the four corner points of target labels in existing anchor-free target detection methods.
[0006] Another objective of this invention is to provide a device for constructing a four-point detection model for labels.
[0007] Technical solution: The label four-point detection model construction method of the present invention includes the following steps:
[0008] Obtain a training dataset and perform data augmentation on the training dataset; the training dataset includes multiple samples, each containing a labeled image; label the labeled image of each sample with the correct target detection box;
[0009] Each sample from the training dataset is sequentially input into the initial network model of a pre-constructed label four-point detection model. The initial network model includes a backbone network, a location sub-network, and a classification sub-network. The backbone network extracts and generates multi-layer feature maps for the corresponding samples. These multi-layer feature maps are then input into the location sub-network to generate the target prediction box for each object in the multi-layer feature map and to obtain the initial location information for each object. The multi-layer feature map is then input into the classification sub-network to obtain the initial category information for each object. The target prediction boxes for each object in the multi-layer feature map are mapped back to the original image, and multiple predicted boxes with restored ground coordinates are calculated. A preset method is used to select the optimal predicted box, along with its location and category information.
[0010] The initial network model is trained using the training dataset. Positive and negative samples are constructed based on the target detection box and the preset scaling factor to calculate the loss during training. Different loss functions are used to train the location sub-network and the classification sub-network, and finally a label four-point detection model that meets the preset performance is obtained.
[0011] Furthermore, the backbone network adopts a feature pyramid network, which includes top-down pathways and lateral connections. The top-down pathways are ResNet networks. The pyramid levels of the feature pyramid network range from shallow to deep, and each level downsamples the input sample image.
[0012] Furthermore, the process of mapping the target prediction box of each object in the multi-layer feature map back to the original image and calculating multiple predicted boxes with restored true coordinates includes:
[0013] The target prediction box of each object in the multi-layer feature map is mapped back to the original image. The normalized offset between the projected coordinates and the real image is calculated using the Smooth L1 loss function to obtain multiple predicted boxes with restored real coordinates.
[0014] Furthermore, the data augmentation operation performed on the training dataset includes at least perspective transformation and random scaling operations.
[0015] Furthermore, the construction of positive and negative samples based on the target detection box and the preset scaling factor includes:
[0016] Map the target detection box of the corresponding sample to the feature map of the target's level, and calculate the coordinates of the center point using the following formula:
[0017]
[0018]
[0019] c ’ x =x ’ 1+0.5(x ’ 2-x ’ 1),c ’ y =y1 ’ +0.5(y ’ 2-y1 ’ );
[0020] Where (x1, y1) and (x2, y2) are the coordinates of the top-left and bottom-right of the target detection box; (x ’ 1,y1 ’ ) and (x ’ 2,y2 ’ (c) represents the coordinates of the top-left and bottom-right of the mapped target detection box; ’ x ,c ’ y ) represents the coordinates of the center point of the mapped target detection box; 2 l Indicates the step size.
[0021] Furthermore, the construction of positive and negative samples based on the target detection box and the preset scaling factor also includes:
[0022] Weights are assigned to each positive sample based on the distance between each positive sample within the target detection box and the coordinates of the center point. A generalized normalized two-dimensional Gaussian distribution with rotation and scaling properties is introduced, and the calculation formula is as follows:
[0023]
[0024] Where X represents the coordinates of the positive sample; u represents the coordinates of the center keypoint; (·) T This indicates transpose.
[0025] Furthermore, the optimal prediction box, along with its location and category information, is obtained by filtering from multiple predicted boxes with restored real coordinates using a preset method. The preset method employs a non-maximum suppression method.
[0026] Furthermore, the initial network model employs a Gaussian strategy-based sample distribution and confidence prediction.
[0027] Furthermore, the step of inputting the multi-layer feature map into the classification sub-network to obtain the initial category information of each target in the multi-layer feature map includes:
[0028] The multi-layer feature map is input into the classification sub-network for pixel-by-pixel classification, and the confidence of the corresponding sample is predicted to obtain the initial category information and initial location information of each target.
[0029] In another embodiment of the present invention, a label four-point detection model construction device includes...
[0030] The data acquisition module is used to acquire the training dataset and perform data augmentation operations on the training dataset.
[0031] The model building module is used to construct the initial network model of the label four-point detection model. It sequentially inputs each sample from the training dataset into the pre-constructed initial network model, which includes a backbone network, a location sub-network, and a classification sub-network. The module extracts and generates multi-layer feature maps for the corresponding samples through the backbone network, inputs these multi-layer feature maps into the location sub-network to generate target prediction boxes and initial location information for each target in the multi-layer feature maps, and inputs the multi-layer feature maps into the classification sub-network to obtain initial category information for each target in the multi-layer feature maps. It also maps the target prediction boxes of each target in the multi-layer feature maps back to the original image, calculates multiple predicted boxes with restored ground coordinates, and uses a preset method to select the optimal predicted box, along with its location and category information, from these predicted boxes.
[0032] The model training module is used to train an initial network model using the training dataset, construct positive and negative samples based on the target detection box and a preset scaling factor, and train the location sub-network and classification sub-network using different loss functions to finally obtain a label four-point detection model that meets the preset performance.
[0033] Beneficial effects: Compared with the prior art, the technical solution of the present invention has the following beneficial effects:
[0034] (1) The label four-point detection model of the present invention is easy to train, can effectively detect irregular quadrilateral targets and accurately output the coordinates of the four corner points of the irregular quadrilateral, and has fast detection speed, high accuracy and strong practicality.
[0035] (2) Data augmentation of the training dataset can improve the quality of the dataset, thereby enhancing the generalization ability of the model;
[0036] (3) The backbone network adopts a feature pyramid network, which integrates feature maps from shallow to deep layers to make full use of the features at each level. Attached Figure Description
[0037] Figure 1 This is a flowchart of the method of the present invention;
[0038] Figure 2 This is a schematic diagram of the initial network model structure in an embodiment of the present invention;
[0039] Figure 3This is a schematic diagram of sample allocation based on Gaussian distribution in an embodiment of the present invention;
[0040] Figure 4 This is a diagram of the feature pyramid structure in an embodiment of the present invention. Detailed Implementation
[0041] The technical solution of the present invention will now be described in detail with reference to specific embodiments and accompanying drawings.
[0042] like Figure 1 As shown, the label four-point detection model construction method of the present invention includes the following steps:
[0043] Step S101: Obtain the training dataset and perform data augmentation operations on it. The training dataset includes multiple samples, each containing a labeled image; correctly label the object detection bounding box for each sample's labeled image.
[0044] In this step, when acquiring the training dataset, a camera can be used to capture and collect labeled images. Specifically, a preset remote control system is used to control the camera to rotate and acquire labeled images in a time-sharing manner to obtain sample data containing different features and construct the training dataset.
[0045] In some embodiments, based on the acquired label images, a complete dataset is first constructed. The dataset is then divided into a training set and a test set according to a preset ratio. The training set is used to train an initial network model, and the test set is used to test the trained label four-point detection model to evaluate its performance. For example, the preset ratio is 7:3.
[0046] In this step, data augmentation operations are performed on the training dataset to improve sample quality, thereby enhancing the model's generalization ability and robustness. These data augmentation operations include at least perspective transformation and random scaling operations.
[0047] Step S102: As Figure 2As shown, the initial network model for constructing the label four-point detection model is presented. This initial network model includes a backbone network, a location sub-network, and a classification sub-network. Each sample from the training dataset is sequentially input into the pre-constructed initial network model for label four-point detection. The backbone network extracts and generates multi-layer feature maps for the corresponding samples. The multi-layer feature maps are then input into the location sub-network to generate target prediction boxes for each target in the multi-layer feature maps and obtain the initial location information for each target. The multi-layer feature maps are then input into the classification sub-network to obtain the initial category information for each target in the multi-layer feature maps. The target prediction boxes for each target in the multi-layer feature maps are then mapped back to the original image, and multiple predicted boxes with restored ground coordinates are calculated. A preset method is used to select the optimal predicted box, along with its location and category information, from these multiple predicted boxes with restored ground coordinates.
[0048] In this step, before inputting each sample from the training dataset into the initial network model of the pre-built label four-point detection model, it is necessary to set the initial parameters of the initial network model.
[0049] In this step, the multi-layer feature map is input into the classification sub-network to obtain the initial category information of each target in the multi-layer feature map, including: inputting the multi-layer feature map into the classification sub-network for pixel-by-pixel classification, predicting the confidence of the corresponding sample, so as to obtain the initial category information of each target in the multi-layer feature map.
[0050] In this step, the target prediction box of each object in the multi-layer feature map is mapped back to the original image, and multiple predicted boxes with restored ground coordinates are calculated. This includes: mapping the target prediction box of each object in the multi-layer feature map back to the original image, and using the Smooth L1 loss function to calculate the normalized offset between the projected coordinates and the real image, thereby obtaining multiple predicted boxes with restored ground coordinates.
[0051] In this step, a preset method is used to filter the optimal prediction box, along with its location and category information, from multiple predicted boxes with restored true coordinates. The preset method employs non-maximum suppression. The location information includes the coordinates of four points: the upper left, upper right, lower left, and lower right of the target prediction box.
[0052] In this step, the initial network model uses a Gaussian strategy-based sample distribution and confidence prediction. Specifically, the initial sample distribution is changed to a Gaussian strategy-based sample distribution, and similarly, the confidence prediction is also based on a Gaussian strategy. The network structure is designed, and the number of output channels is adjusted to produce a 12 (4+8) predicted feature map. Four channels represent the predicted Gaussian scores of the four corner points, and eight channels represent the coordinates of the four corner points, thus obtaining the target label's classification and the coordinates of its top-left, top-right, bottom-left, and bottom-right corner points. For example... Figure 3The diagram shown is a sample allocation diagram based on Gaussian distribution, demonstrating the visualization effect of the target detection box and the minimum circumscribed quadrilateral formed by the four corner points.
[0053] In constructing the initial neural network model, this invention introduces a Gaussian strategy for sample distribution, which can effectively reflect spatial distribution information and more accurately identify target images.
[0054] The initial network model constructed in this invention, compared to existing anchor-free object detection algorithms, does not rely on default anchor settings during both training and testing phases, making the model more robust to bounding box distribution. The initial network model includes a backbone network and two sub-networks with different tasks: a location sub-network and a classification sub-network. The backbone network is primarily responsible for calculating multi-layer feature maps from the input sample images; in this invention, the backbone network is implemented using an existing network. The location sub-network is used to predict bounding boxes at corresponding locations based on the calculated multi-layer feature maps. The classification sub-network is used to perform pixel-by-pixel classification on the calculated multi-layer feature maps.
[0055] In this step, the initial network model uses a Feature Pyramid Network (FPN) as the backbone. In convolutional networks, as network depth increases, the size of feature maps decreases, and the semantic information becomes increasingly abstract. Shallow feature maps contain less semantic information, but the target location is relatively accurate. Deep feature maps contain richer semantic information, but the target location is more coarse, making it easier to miss small objects. The Feature Pyramid Network integrates feature maps from shallow to deep layers, making full use of features at each level.
[0056] In this step, the backbone network employs a feature pyramid network, which includes top-down pathways and lateral connections. The top-down pathways are ResNet networks. For a single-scale input image, the feature pyramid network constructs a feature pyramid through top-down feature map processing and lateral connections, enabling target detection at different scales. For example, ... Figure 4 As shown, the feature pyramid network constructed in this invention has feature pyramid levels from P3 to P7. Each level P1 downsamples the input sample image; for example, each level downsamples the input sample image by 1 / 2. The number of channels in all levels is C = 256.
[0057] Step S103: Train the initial network model using the training dataset. Construct positive and negative samples based on the target detection boxes and a preset scaling factor. Train the location sub-network and classification sub-network using different loss functions to finally obtain a label four-point detection model that meets the preset performance. In this scheme, a Focal Loss loss function is constructed to train the classification sub-network, and a Smooth L1 loss function is constructed to train the location sub-network.
[0058] In existing anchor-based detectors, the problem of ambiguous location definitions often arises. Specifically, each location in the multi-layer feature map obtained through the backbone network has multiple anchors, some of which are positive samples and some are negative samples. This forces the classifier to distinguish not only samples from different locations but also positive and negative samples at the same location, thus leading to the problem of ambiguous location definitions. In this invention, the classification sub-network of the initial neural network model explicitly predicts a classification result at each location, effectively avoiding the ambiguity problem in anchors.
[0059] Meanwhile, if samples within the correctly labeled ground truth boxes (GTboxes) are directly taken as positive samples, some points near the GTboxes are far from the center of the target and even closer to the background pixels. If these points are also taken as positive samples, it will cause difficulties in training the model. However, if they are taken as negative samples, the aforementioned ambiguity problem will still occur.
[0060] This invention addresses the aforementioned issues. Therefore, when calculating positive and negative samples, it does not require calculating IOU like anchors. Instead, it directly maps the target detection box (GT box) onto the feature map of the corresponding level, thereby determining positive and negative samples and increasing the discriminative power between them. Specifically:
[0061] Positive and negative samples are constructed based on the target detection bounding box and a preset scaling factor, including:
[0062] Suppose any target detection bounding box (GT box) is (x1, t1, x2, t2), where (x1, t1) and (x2, t2) represent the coordinates of the top-left and bottom-right of the target detection box, respectively. The target detection boxes of the corresponding samples are plotted with a stride of 2. l Mapping the coordinates of the top left, bottom right, and center points onto the feature map of the target level, the calculation formulas are shown in formulas (1) to (3):
[0063]
[0064]
[0065] c'x =x'1+0.5(x'2-x'1),c' y =y'1+0.5(y'2-t'1 (3)
[0066] Where (x1,y1) and (x2,y2) are the coordinates of the top-left and bottom-right of the target detection box; (x'1,y'1) and (x'2,y'2) are the coordinates of the top-left and bottom-right of the mapped target detection box; (c' x ,c' y ) represents the coordinates of the center point of the mapped target detection box; 2 l Indicates the step size.
[0067] Meanwhile, as mentioned above, not all points within the ground truth box are positive samples; some points are far from the target center. Therefore, a scaling factor is introduced, and the range of positive samples is dynamically set according to the scaling factor. The calculation formulas are shown in formulas (4) and (5):
[0068] x”1=c' x -0.5(x'2-x'1)σ1y”1=c' y -0.5(y'2-y'1)σ1 (4)
[0069] x”2=c' x +0.5(x'2-x'1)σ1,y”2=c' y +0.5(y'2-y'1)σ1 (5)
[0070] Where (x”1,y”1) and (x”2,y”2) represent the upper left and lower right coordinates of the positive sample range after scaling factor adjustment, respectively.
[0071] For negative samples, another scaling factor σ2 is used to adjust the width and height of the mapped GT box again according to the above formula, so that it expands outward a little. The points that expand outside the GT box border are taken as negative samples.
[0072] Points between two bounding boxes scaled by scaling factors σ1 and σ2 will be ignored during training. For example, if σ1 = 0.3 and σ2 = 0.4, then the region between 0.3 and 0.4 will not be included in the training.
[0073] In practice, considering that positive samples only account for a small portion of the entire feature map and there is still an imbalance between positive and negative samples, this invention constructs a Focal Loss loss function for optimization when training the classification sub-network to handle the imbalance between positive and negative samples.
[0074] The four corner points of a label form a quadrilateral, often exhibiting characteristics such as rotation and shearing. Therefore, directly selecting keypoints within the ground truth (GT) box as positive samples does not accurately reflect spatial distribution information. Furthermore, treating all points within the GT box as equivalent positive samples is also inaccurate. Therefore, this invention introduces the concept of weighting, arguing that keypoints closer to the center acquire more comprehensive feature information, thus requiring a higher weight for central keypoints compared to edge points. To fit the shape of any quadrilateral, a generalized normalized two-dimensional Gaussian distribution with rotation and scaling properties is introduced based on the principle of distributional weighting, as detailed below:
[0075] Weights are assigned to each positive sample based on the distance between each positive sample within the target detection bounding box and the center point coordinates. A generalized normalized two-dimensional Gaussian distribution with rotation and scaling properties is introduced, and the calculation formula is as follows:
[0076]
[0077] Where X represents the coordinates of the positive sample; u represents the coordinates of the center keypoint; (·) T This indicates transpose.
[0078] In the initial neural network model's position subnetwork, coordinate prediction is mainly achieved by learning the Transformation function. During training, the coordinates of the positive samples selected on the feature map are first transformed to the coordinates on the original image, and then the offset of the coordinates from the GT box bounding box of the object sample to which they belong is obtained. In this invention, the predicted bounding box is increased from only two corner points (top left and bottom right) to four corner points, and the Smooth L1 loss function is used as the loss function for calculating the coordinates. The calculation formulas for the coordinates are shown in formulas (7) to (10):
[0079]
[0080] in, (x1, y1), (x2, y2), (x3, y3), and (x4, y4) represent the coordinates of the top-left, top-right, bottom-left, and bottom-right points of the predicted bounding box output by the model, respectively; (x, y) represents the coordinates of the top-left, top-right, bottom-left, and bottom-right points of the detected object bounding box, respectively; (x, y) represents the coordinates of the positive sample. l The step size is represented by z; z is the normalization factor, which projects the output space onto a space centered at 1.
[0081] Meanwhile, when constructing the initial neural network model, this invention introduces a Gaussian strategy for sample distribution, which can well reflect spatial distribution information and more accurately identify target images.
[0082] Experimental data shows that the four-point label detection model provided by this invention can detect irregular quadrilateral target labels, such as material labels and license plates; it can detect multiple label images simultaneously, and the detection accuracy rate reaches over 90%.
[0083] In summary, the label four-point detection model construction method of this invention collects label images to construct a training dataset for model training; performs data augmentation on the training dataset to improve its quality and enhance the model's generalization ability by labeling each sample in the training dataset with the correct target detection box; constructs an initial network model, which includes a backbone network, a location subnetwork, and a classification subnetwork, wherein the backbone network adopts a feature pyramid network; introduces a Gaussian strategy for sample distribution and designs a network structure so that the model finally outputs a predicted feature map with 12 channels, of which 4 channels are the predicted Gaussian scores of the four corner points and 8 channels are the coordinates of the four corner points; the backbone network uses a feature pyramid network to fuse feature maps from shallow to deep layers to fully utilize features at each level. Image samples are input into the initial network model, and the backbone network extracts and generates multi-layer feature maps for the corresponding image samples. Then, a classification sub-network and a location sub-network generate the initial category and location of each target. The predicted bounding box of each target in the multi-layer feature map is mapped back to the original image, and the coordinate loss is calculated using the Smooth L1 loss function to obtain multiple target predicted bounding boxes. A non-maximum suppression method is used to select the optimal category and location of the target predicted bounding box. The initial network model is trained using a training dataset, and a loss function is constructed to finally obtain the labeled four-point detection model. The labeled four-point detection model provided by this invention is easy to train, can effectively detect irregular quadrilateral targets, and accurately outputs the coordinates of the four corner points of the irregular quadrilateral. It has a fast detection speed, high accuracy, and strong practicality.
[0084] The present invention also includes a label four-point detection model construction device, which can construct a label four-point detection model, specifically including:
[0085] The data acquisition module is used to acquire the training dataset and perform data augmentation operations on the training dataset.
[0086] The model building module is used to construct the initial network model of the label four-point detection model. It sequentially inputs each sample from the training dataset into the pre-constructed initial network model, which includes a backbone network, a location sub-network, and a classification sub-network. The module extracts and generates multi-layer feature maps for the corresponding samples through the backbone network, inputs these multi-layer feature maps into the location sub-network to generate target prediction boxes and initial location information for each target in the multi-layer feature maps, and inputs the multi-layer feature maps into the classification sub-network to obtain initial category information for each target in the multi-layer feature maps. It also maps the target prediction boxes of each target in the multi-layer feature maps back to the original image, calculates multiple predicted boxes with restored ground coordinates, and uses a preset method to select the optimal predicted box, along with its location and category information, from these predicted boxes.
[0087] The model training module is used to train an initial network model using the training dataset, construct positive and negative samples based on the target detection box and a preset scaling factor, and train the location sub-network and classification sub-network using different loss functions to finally obtain a label four-point detection model that meets the preset performance.
Claims
1. A method for constructing a four-point label detection model, characterized in that, The method includes the following steps: Obtain a training dataset and perform data augmentation on the training dataset; the training dataset includes multiple samples, each containing a labeled image; label the labeled image of each sample with the correct target detection box; Each sample in the training dataset is sequentially input into the initial network model of a pre-constructed label four-point detection model. The initial network model includes a backbone network, a location sub-network, and a classification sub-network. The backbone network extracts and generates multi-layer feature maps for the corresponding samples. These multi-layer feature maps are then input into the location sub-network to generate the target prediction box for each object in the multi-layer feature map and obtain the initial location information for each object. The multi-layer feature map is then input into the classification sub-network to obtain the initial category information for each object. The target prediction boxes for each object in the multi-layer feature map are mapped back to the original image, and multiple predicted boxes with restored ground coordinates are calculated. A preset method is used to select the optimal predicted box, along with its location and category information, from these multiple predicted boxes with restored ground coordinates. The initial network model is trained using the training dataset. Positive and negative samples are constructed based on the target detection box and the preset scaling factor to calculate the loss during training. Different loss functions are used to train the location sub-network and the classification sub-network, and finally a label four-point detection model that meets the preset performance is obtained. The construction of positive and negative samples based on the target detection box and a preset scaling factor includes: Map the target detection box of the corresponding sample to the feature map of the target's level, and calculate the coordinates of the center point using the following formula: ; ; ; in, and The coordinates of the top left and bottom right of the target detection box; and These are the coordinates of the top-left and bottom-right of the mapped target detection box; These are the coordinates of the center point of the mapped target detection box; Indicates the step size; A scaling factor is introduced, and the range of positive samples is dynamically set according to the scaling factor. The calculation formula is as follows: ; ; in, and These represent the top-left and bottom-right coordinates of the positive sample range after scaling factor adjustment; For negative samples, use another scaling factor. Adjust the width and height of the mapped GT box again according to the above formula to expand it outward, and take the points that expand outside the GT box border as negative samples; Weights are assigned to each positive sample based on the distance between each positive sample within the target detection box and the coordinates of the center point. A generalized normalized two-dimensional Gaussian distribution with rotation and scaling properties is introduced, and the calculation formula is as follows: ; in, The coordinates of the positive sample; Represents the coordinates of the central key point; This indicates transpose.
2. The label four-point detection model construction method according to claim 1, characterized in that: The backbone network adopts a feature pyramid network, which includes top-down pathways and lateral connections. The top-down pathways are ResNet networks. The pyramid levels of the feature pyramid network range from shallow to deep, and each level downsamples the input sample image.
3. The label four-point detection model construction method according to claim 1, characterized in that, The process of mapping the target prediction box of each object in the multi-layer feature map back to the original image and calculating multiple predicted boxes with restored ground coordinates includes: The target prediction box of each object in the multi-layer feature map is mapped back to the original image. The normalized offset between the projected coordinates and the real image is calculated using the Smooth L1 loss function to obtain multiple predicted boxes with restored real coordinates.
4. The label four-point detection model construction method according to claim 1, characterized in that: The data augmentation operation performed on the training dataset includes at least perspective transformation and random scaling operations.
5. The label four-point detection model construction method according to claim 1, characterized in that: The optimal prediction box, along with its location and category information, is obtained by filtering from multiple predicted boxes with restored real coordinates using a preset method. The preset method employs a non-maximum suppression method.
6. The label four-point detection model construction method according to claim 1, characterized in that: The initial network model uses a Gaussian strategy for sample distribution and confidence prediction.
7. The label four-point detection model construction method according to claim 1, characterized in that, The step of inputting the multi-layer feature map into the classification sub-network to obtain the initial category information of each target in the multi-layer feature map includes: The multi-layer feature map is input into the classification sub-network for pixel-by-pixel classification, and the confidence level of the corresponding sample is predicted to obtain the initial category information of each target in the multi-layer feature map.
8. A device for constructing a four-point detection model for a label, characterized in that: include The data acquisition module is used to acquire a training dataset and perform data augmentation operations on the training dataset; the training dataset includes multiple samples, each containing a labeled image; and the correct target detection box is labeled for the labeled image of each sample. The model building module is used to construct the initial network model of the label four-point detection model; it is used to input each sample of the training dataset into the pre-constructed initial network model of the label four-point detection model, the initial network model including a backbone network, a location sub-network, and a classification sub-network; it is used to extract and generate multi-layer feature maps of the corresponding samples through the backbone network, input the multi-layer feature maps into the location sub-network to generate the target prediction box and the initial location information of each target in the multi-layer feature map, input the multi-layer feature map into the classification sub-network to obtain the initial category information of each target in the multi-layer feature map; it is also used to map the target prediction box of each target in the multi-layer feature map back to the original image, calculate multiple predicted boxes with restored ground coordinates, and use a preset method to select the optimal target prediction box and the location and category information of the optimal target prediction box from the multiple predicted boxes with restored ground coordinates; The model training module is used to train an initial network model using the training dataset, construct positive and negative samples based on the target detection box and a preset scaling factor, and train the location sub-network and classification sub-network using different loss functions to finally obtain a label four-point detection model that meets the preset performance. The construction of positive and negative samples based on the target detection box and a preset scaling factor includes: Map the target detection box of the corresponding sample to the feature map of the target's level, and calculate the coordinates of the center point using the following formula: ; ; ; in, and The coordinates of the top left and bottom right of the target detection box; and These are the coordinates of the top-left and bottom-right of the mapped target detection box; These are the coordinates of the center point of the mapped target detection box; Indicates the step size; A scaling factor is introduced, and the range of positive samples is dynamically set according to the scaling factor. The calculation formula is as follows: ; ; in, and These represent the top-left and bottom-right coordinates of the positive sample range after scaling factor adjustment; For negative samples, use another scaling factor. Adjust the width and height of the mapped GT box again according to the above formula to expand it outward, and take the points that expand outside the GT box border as negative samples; Weights are assigned to each positive sample based on the distance between each positive sample within the target detection box and the coordinates of the center point. A generalized normalized two-dimensional Gaussian distribution with rotation and scaling properties is introduced, and the calculation formula is as follows: ; in, The coordinates of the positive sample; Represents the coordinates of the central key point; This indicates transpose.
Citation Information
Patent Citations
Target detection method based on SSD improvement
CN111126472A
Ship image target detection method and system in complex environment
CN115880495A