Object detection model training method and object detection method based on classification regression
By training the regressor and classifier in the object detection model separately and using the regression detection sub-model for equal sampling, the category imbalance problem is solved, the classification performance and accuracy of the object detection model are improved, and the difficulty of model debugging is reduced.
Patent Information
- Application Number
- CN202011118266.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-10-19
- Publication Date
- 2025-01-14
- Estimated Expiration
- 2040-10-19
AI Technical Summary
In the object detection scenario, the problem of category imbalance seriously affects the classification performance of the detector. The existing methods balance multiple samples and few samples by manually generating more data, but debugging is difficult and the effect is not obvious.
By training the regressor and classifier in the object detection model separately, using the regression detection sub-model to sample the training data equally to obtain the classification training data, thereby building the object detection model, ensuring the category balance during the classifier training process, and reducing the model Debugging difficulty.
It realizes that the classification performance and accuracy of the object detection model are improved without adding new samples, and reduces the difficulty of model debugging.
Smart Images

Figure CN112241705B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to artificial intelligence and provides a target detection model training method and a target detection method based on classification regression. Background Art
[0002] With the development of computer vision technology, target detection technology has emerged. Target detection, also known as target extraction, is an image segmentation based on the geometric and statistical features of the target. It combines the segmentation and recognition of the target into one. Its accuracy and real-time performance are important capabilities of the entire system. Especially in complex scenes, when multiple targets need to be processed in real time, automatic target extraction and recognition are particularly important. With the development of computer technology and the widespread application of computer vision principles, the use of computer image processing technology to track targets in real time has become increasingly popular. Dynamic real-time tracking and positioning of targets has wide application value in intelligent transportation systems, intelligent monitoring systems, military target detection, and surgical instrument positioning in medical navigation surgery. However, in target detection scenarios, category imbalance is a very common and prominent problem, which seriously affects the classification performance of the detector. Taking vehicle detection as an example, assuming that vehicles are divided into three categories: cars, buses (including passenger cars), and trucks, in dense scenes, the ratio of cars to the other two types of vehicles can reach 10:1 or even 20:1, which is a very serious imbalance.
[0003] The current method for dealing with category imbalance in target detection is mainly to balance the multi-sample category and the small sample category by artificially generating more data. However, the benefits of this method are not very obvious, and it is difficult to debug during the training process of the detection model. Summary of the invention
[0004] Based on this, it is necessary to provide a target detection model training method and a target detection method based on classification regression that can effectively reduce the difficulty of model debugging in response to the above technical problems.
[0005] A method for training a target detection model based on classification regression, the method comprising:
[0006] Obtain model training data and initial target detection model;
[0007] The feature extractor and the regressor in the initial target detection model are trained using model training data to obtain a regression detection sub-model;
[0008] Perform balanced sampling on the model training data through the regression detection sub-model to obtain classification training data;
[0009] Training the classifier in the initial target detection model according to the classification training data to obtain a classification sub-model;
[0010] A target detection model is constructed based on the regression detection sub-model and the classification sub-model.
[0011] In one embodiment, performing balanced sampling on the model training data through the regression detection sub-model to obtain classification training data includes:
[0012] Acquire a feature map corresponding to the model training data and a positive sample area in the feature map through the regression detection sub-model;
[0013] According to the category of the detection target in the positive sample area, the model training data is evenly sampled to obtain classification training data.
[0014] In one embodiment, obtaining model training data includes:
[0015] Acquire historical pictures and category information corresponding to the historical pictures, wherein the historical pictures include historical pictures containing the detection target and historical pictures not containing the detection target;
[0016] According to the category information corresponding to the historical pictures, target type tags are added to the historical pictures to obtain model training data.
[0017] In one embodiment, before adding the target type tag to the historical image and obtaining the model training data, the method further includes:
[0018] Get model resolution requirements;
[0019] Performing data cleaning on the historical images according to the model resolution requirement;
[0020] Adding target type tags to the historical images and obtaining model training data includes:
[0021] According to the category information corresponding to the historical pictures after data cleaning, target type tags are added to the historical pictures after data cleaning to obtain model training data.
[0022] In one embodiment, after constructing the target detection model according to the regression detection sub-model and the classification sub-model, the method further includes:
[0023] Obtaining labeled model verification data, inputting the model verification data into the target detection model, and obtaining a target detection result corresponding to the model verification data;
[0024] Obtaining the detection accuracy of the target detection model according to the data label corresponding to the model verification data and the target detection result corresponding to the model verification data;
[0025] When the detection accuracy of the target detection model is greater than a preset accuracy threshold, it is determined that the target detection model has passed the verification.
[0026] In one embodiment, after obtaining the detection accuracy of the target detection model according to the data mark corresponding to the model verification data and the target detection result corresponding to the model verification data, the method further includes:
[0027] When the detection accuracy of the target detection model is less than or equal to the preset accuracy threshold;
[0028] The regression detection sub-model and the classification sub-model in the target detection model are respectively verified by the labeled model verification data to obtain sub-model verification results;
[0029] The target detection model is updated with data according to the sub-model verification result, and the step of returning to input the model verification data into the target detection model to obtain the target detection result corresponding to the model verification data.
[0030] A target detection method, the method comprising:
[0031] Acquire image data to be detected;
[0032] The image data to be detected is input into the above-mentioned target detection model to obtain the target detection result.
[0033] A target detection model training device based on classification regression, the device comprising:
[0034] Data acquisition module, used to obtain model training data and initial target detection model;
[0035] A first model training module is used to train the feature extractor and the regressor in the initial target detection model through model training data to obtain a regression detection sub-model;
[0036] A balanced sampling module, used for performing balanced sampling on the model training data through the regression detection sub-model to obtain classification training data;
[0037] A second model training module is used to train the classifier in the initial target detection model according to the classification training data to obtain a classification sub-model;
[0038] A model building module is used to build a target detection model based on the regression detection sub-model and the classification sub-model.
[0039] In one embodiment, the balanced sampling module is specifically used for:
[0040] Acquire a feature map corresponding to the model training data and a positive sample area in the feature map through the regression detection sub-model;
[0041] According to the category of the detection target in the positive sample area, the model training data is evenly sampled to obtain classification training data.
[0042] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0043] Obtain model training data and initial target detection model;
[0044] The feature extractor and the regressor in the initial target detection model are trained using model training data to obtain a regression detection sub-model;
[0045] Perform balanced sampling on the model training data through the regression detection sub-model to obtain classification training data;
[0046] Training the classifier in the initial target detection model according to the classification training data to obtain a classification sub-model;
[0047] A target detection model is constructed based on the regression detection sub-model and the classification sub-model.
[0048] A computer storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the following steps are implemented:
[0049] Obtain model training data and initial target detection model;
[0050] The feature extractor and the regressor in the initial target detection model are trained using model training data to obtain a regression detection sub-model;
[0051] Perform balanced sampling on the model training data through the regression detection sub-model to obtain classification training data;
[0052] Training the classifier in the initial target detection model according to the classification training data to obtain a classification sub-model;
[0053] The target detection model is constructed based on the regression detection sub-model and the classification sub-model.
[0054] In the above-mentioned classification-regression-based target detection model training method, device, computer equipment, storage medium and target detection method, by obtaining model training data and an initial target detection model; training the feature extractor and regressor in the initial target detection model through the model training data to obtain a regression detection sub-model; performing balanced sampling of the model training data through the regression detection sub-model to obtain classification training data; training the classifier in the initial target detection model according to the classification training data to obtain a classification sub-model; and constructing a target detection model according to the regression detection sub-model and the classification sub-model. The present application trains the regressor and classifier in the target detection model separately, and the model training data first trains the feature extractor and regressor in the target detection, and then obtains the classification training data for training the classifier through the obtained regression detection sub-model and the balanced sampling method, thereby ensuring the category balance in the classifier training process, and obtaining a target detection model with excellent performance in both the regression part and the classification part. At the same time, since the regression part and the classification part are obtained by step-by-step training based on the model training data, no additional new samples are required, thereby effectively reducing the difficulty of debugging the target detection model. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] Figure 1 This is an application scenario diagram of a target detection model training method based on classification regression in one embodiment;
[0056] Figure 2 A schematic diagram of a process of training a target detection model based on classification regression in one embodiment;
[0057] Figure 3 A schematic diagram showing a comparison between a training process of a target detection model training method based on classification regression in one embodiment and a training process of an existing target detection model training method;
[0058] Figure 4 In one embodiment Figure 2 Schematic diagram of the sub-process of step 205;
[0059] Figure 5 A schematic diagram of a process for obtaining model training data in one embodiment;
[0060] Figure 6 A schematic diagram of a process for verifying a target detection model in one embodiment;
[0061] Figure 7 It is a structural block diagram of a target detection model training device based on classification regression in one embodiment;
[0062] Figure 8 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0063] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0064] The target detection model training method based on classification regression provided in this application can be applied to Figure 1 In the application environment shown. Among them, the terminal 102 communicates with the model training server 104 through the network. When the model training personnel need to obtain a target detection model for detecting certain specific targets, they can submit the corresponding model training data and the initial target detection model to the model training server 104 through the terminal 102 to build the target detection model. Specifically, the user can send the model training data and the initial target detection model to the model training server 104 through the terminal 102. The model training server 104 obtains the model training data and the initial target detection model; trains the feature extractor and the regressor in the initial target detection model through the model training data to obtain the regression detection sub-model; performs balanced sampling on the model training data through the regression detection sub-model to obtain the classification training data; trains the classifier in the initial target detection model according to the classification training data to obtain the classification sub-model; and builds the target detection model according to the regression detection sub-model and the classification sub-model. Among them, the terminal 102 can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers and portable wearable devices, and the server 104 can be implemented with an independent server or a server cluster consisting of multiple servers.
[0065] In one embodiment, Figure 2 As shown in the figure, a method for training a target detection model based on classification regression is provided. Figure 1 The model training server 104 in the example is used as an example to illustrate, and the following steps are included:
[0066] Step 201, obtaining model training data and an initial target detection model.
[0067] Among them, the model training data refers to the data used to train the model. Specifically, a number of pictures can be used as model training data, and these pictures contain various types of targets to be detected. Before model training, it is necessary to add corresponding labels to the targets in the model training data. The initial target detection model refers to an untrained initialization model. The target detection model for target detection on the image can be obtained by training the initial target detection model. The target detection model specifically includes three parts: feature extractor, regressor and classifier. The feature extractor is used to extract the features of the image, and the regressor is used to determine the position of the detection target in the image. The classifier is used to determine the category to which the detected target belongs.
[0068] Specifically, when conducting a target detection model training, the staff needs to first input the model training data and the initial target detection model into the model training server 104 through the terminal. In another embodiment, the initial target detection model is pre-stored in the model training server 104, and the staff only needs to input the model training data to start a target detection model training process.
[0069] Step 203: Train the feature extractor and the regressor in the initial target detection model using the model training data to obtain a regression detection sub-model.
[0070] Among them, similar to the traditional target detection model training method, the regressor and classifier of the target detection model in this application also need to share the feature extraction network, but the difference is that after obtaining the feature map, the two must pass through different convolution modules, that is, have different parameters, so that the regression detection submodule used for detection and the classification submodule used for classification are trained separately.
[0071] Specifically, after obtaining the model training data and the initial target detection model, the feature extractor in the initial target detection model can be trained through the model training data, that is, the feature map in the model feature data is extracted through the feature extractor. At the same time, after obtaining the feature map, it is also necessary to pass the feature map through the convolution module, and then the regressor determines the specific position of the detection target in the image. Through model training, the feature extractor and regressor in the initial target detection network are first trained, and the corresponding output results obtained are the feature map corresponding to the model data, and the position of each detection target in the model training data. The trained model is a regression detection sub-model that combines the feature extraction function and the regression detection function.
[0072] Step 205: Perform balanced sampling on the model training data through the regression detection sub-model to obtain classification training data.
[0073] The balanced sampling specifically refers to sampling various types of detection targets based on the detection results in the regression detection sub-model. The result of the balanced sampling specifically refers to the feature map data after balanced sampling, and the number of various types of detection targets after sampling is balanced.
[0074] Specifically, since the detection targets of the target detection method in the present application include multiple types, and classification specifically refers to determining the type of the area where the target detected by the regressor is located, but since the corresponding quantities of different types of detection targets are often different in the training samples, in order to improve the classification accuracy of the classifier, it is necessary to first determine the category of the detection target in the area where the detection target is located, and then perform balanced sampling based on the category of the detection target to ensure that each type of detection target in the feature map of the sampling result is equal. Equality here specifically refers to the overall balance of the number of detection targets of each type in all samples during the classifier training process. This ensures that during the training of the target detection model, the training data of each type remains balanced, thereby improving the classification performance of the target detection model.
[0075] Step 207: train the classifier in the initial target detection model according to the classification training data to obtain a classification sub-model.
[0076] Step 209: construct a target detection model based on the regression detection sub-model and the classification sub-model.
[0077] Specifically, in the present application, by separating the regressor from the classifier and training them separately, the feature detector and the regressor are first trained, so that the corresponding feature map and the position of the detection target are extracted from the model training data through the trained regression detection model, and then the feature map in the model training data is extracted and evenly sampled, so that the sample data of various types can be balanced during the classification training process, and the model parameters in the feature extractor and the regressor need to be kept unchanged during the classification training process. This reduces the problem of uneven detection accuracy during target detection due to unbalanced training samples, thereby improving the target detection accuracy.
[0078] Specifically, Figure 3 The left picture of Figure a in the middle is a description of the existing object detection model training process. After feature extraction, the regressor and classifier are trained simultaneously through a unified convolution module. They are trained together, which is also the main reason for class imbalance. Figure 3The right figure of Figure a is a schematic diagram of the model training proposed in this application. Like the traditional method, the regression module and the classification model of this method share the feature extraction network at the same time. However, the difference is that after obtaining the feature map, the two must pass through different convolution modules, that is, they have different parameters. This design is to train the detection module and the classification module separately. During the training process, you can first Figure 3 The left side of Figure b shows the training regressor: all categories are unified into one category, and the regressor is trained until convergence. At this time, the model has the ability to distinguish between foreground and background, but the classifier is not trained, but Figure 3 As shown on the right side of the middle figure b, the feature map is extracted from the original image through the regressor. According to the output of the regressor, the corresponding positive sample area on the feature map is extracted, and these positive samples are evenly sampled as the training data of the classifier. The convolution module and the classification head of the classifier are trained until convergence. The model obtained at this time can achieve good classification performance. The difference from the original model is that the parameters originally connected together are divided into two parts. Since the two share the feature extractor, the amount of calculation is not increased too much. At the same time, the balanced sampling ensures the class balance during the classifier training process, thereby improving the accuracy of target detection and reducing the difficulty of debugging.
[0079] The above-mentioned classification and regression-based target detection model training method obtains model training data and an initial target detection model; trains the feature extractor and regressor in the initial target detection model through the model training data to obtain a regression detection sub-model; performs balanced sampling of the model training data through the regression detection sub-model to obtain classification training data; trains the classifier in the initial target detection model according to the classification training data to obtain a classification sub-model; and constructs a target detection model according to the regression detection sub-model and the classification sub-model. The present application trains the regressor and classifier in the target detection model separately, and the model training data first trains the feature extractor and regressor in the target detection, and then obtains the classification training data for training the classifier through the obtained regression detection sub-model and the balanced sampling method, thereby ensuring the category balance in the classifier training process, and can obtain a target detection model with excellent performance in both the regression part and the classification part. At the same time, since the regression part and the classification part are obtained by step-by-step training based on the model training data, no additional new samples are required, thereby effectively reducing the difficulty of debugging the target detection model.
[0080] In one embodiment, if Figure 4 As shown, step 205 includes:
[0081] Step 401, obtaining a feature map corresponding to the model training data and a positive sample area in the feature map through a regression detection sub-model;
[0082] Step 403, according to the category of the detection target in the positive sample area, the model training data is evenly sampled to obtain classification training data.
[0083] The positive sample refers to the area where the detection target is detected, and the sample area specifically refers to the area where the detection target is located.
[0084] Specifically, the feature map in the model training data can be extracted through the regression detection sub-model, and the positive sample area in the feature map can be determined at the same time, and then the model training data can be balanced sampled according to the category of the detection target in the positive sample area to obtain the classification training data. The category of the detection target in the positive sample area can be determined by pre-marking the model training data. When the positive sample area is obtained, the category of the corresponding detection target is determined based on the annotation corresponding to the positive sample area, and then based on the positive sample area and the category of the detection target in the positive sample area, it is balanced sampled to obtain the classification training data. In this embodiment, by balanced sampling of the positive sample area, it can be effectively ensured that the number of various types of detection targets in the training data for training the classifier is balanced, thereby improving the accuracy of the target detection model used for target detection.
[0085] In one embodiment, if Figure 5 As shown, before step 201, it also includes:
[0086] Step 502, obtaining historical pictures and category information corresponding to the historical pictures, where the historical pictures include historical pictures containing the detection target and historical pictures not containing the detection target;
[0087] Step 504: Add target type tags to the historical images according to the category information corresponding to the historical images, and obtain model training data.
[0088] Among them, the historical pictures specifically include historical pictures containing detection targets and historical pictures not containing detection targets, which are used to train the target detection model to determine whether the picture contains the detection target. The category information corresponding to the historical pictures specifically refers to the category of the historical pictures, such as whether the historical pictures contain detection targets, the types and quantity of detection targets contained in the historical pictures, etc. Adding target type tags to historical pictures specifically refers to adding corresponding target type tags according to the types of detection targets in historical pictures containing detection targets, and for historical pictures that do not contain detection targets, a type tag with a target type of "none" can be added. The process of adding tags can specifically be to manually classify historical pictures, and then import historical pictures into the target detection server 104 according to the classified categories, and the target detection server 104 adds target type tags in sequence according to the classification.
[0089] Specifically, the target detection server 104 can also automatically generate model training data. Specifically, the user can input a number of historical pictures, set the detection target, and add corresponding detection target annotations to the historical pictures. The source of the historical pictures specifically includes that if it is used to detect targets in random scenes, images in random scenes can be used, and if it is used to detect targets in fixed scenes, images corresponding to fixed scenes need to be used. Among them, annotation specifically refers to annotating historical pictures according to whether the historical pictures contain the detection target, and according to the location of the detection target in the picture and the type of the detection target. In this embodiment, by pre-acquiring historical pictures and annotating the historical pictures, the effectiveness of the obtained model training data can be effectively guaranteed, thereby improving the success rate of target detection.
[0090] In one embodiment, before step 504, the method further includes: obtaining a model resolution requirement; and performing data cleaning on the historical images according to the model resolution requirement. Step 504 includes: adding a target type tag to the historical images after data cleaning according to the category information corresponding to the historical images after data cleaning, and obtaining model training data.
[0091] Specifically, after obtaining several historical pictures that contain the target to be detected and do not contain the target to be detected, the target detection server 104 needs to clean and filter these historical pictures. Because the success rate of target detection is related to the resolution of the image. In order to ensure the detection success rate of the obtained target detection model, pictures that do not meet the requirements such as resolution or clarity can be removed. Then the cleaned historical pictures are marked to obtain model training data. In this embodiment, by performing data cleaning on historical pictures, the validity of the obtained model training data can be further guaranteed, thereby improving the success rate of target detection.
[0092] In one embodiment, if Figure 6 As shown, after step 209, the following steps are also included:
[0093] Step 601, obtain labeled model verification data, input the model verification data into the target detection model, and obtain the target detection result corresponding to the model verification data.
[0094] Step 603, obtaining the detection accuracy of the target detection model according to the data label corresponding to the model verification data and the target detection result corresponding to the model verification data.
[0095] Step 605: When the detection accuracy of the target detection model is greater than a preset accuracy threshold, it is determined that the target detection model has passed the verification.
[0096] Among them, the model validation data can be regarded as part of the model training data. Before the model training starts, the data used for training can be divided into a training set and a validation set in a ratio of 7 to 3. The training set is used as model training data for model training, while the validation set is used as model validation data to complete the model validation. The preset accuracy threshold can be set according to the actual detection requirements.
[0097] Specifically, after obtaining the target detection model, the obtained target detection model needs to be further debugged to ensure the accuracy of target detection. Specifically, the verification of the target detection model can be completed by using marked model verification data. Specifically, the model verification data is input into the target detection model, and the target detection result corresponding to the model verification data is obtained. By comparing the data mark corresponding to the model verification data and the target detection result corresponding to the model verification data, it is determined whether the target detection result corresponding to each model verification data is accurate. When the detection accuracy is greater than the accuracy threshold, it can be determined that the target detection model has passed the verification. In one embodiment, the model verification data can also be grouped according to the type of the detection target. Only when the detection accuracy of all groups is greater than the preset accuracy threshold, the model training server 104 will determine that the target detection model has passed the verification. In this embodiment, the obtained target detection model is verified by the model verification data to ensure that the detection accuracy of the output target detection model is effectively guaranteed.
[0098] In one embodiment, after step 603, it also includes: when the detection accuracy of the target detection model is less than or equal to a preset accuracy threshold; verifying the regression detection sub-model and the classification sub-model in the target detection model respectively through labeled model verification data to obtain sub-model verification results; updating the target detection model data according to the sub-model verification results, returning to the step of inputting the model verification data into the target detection model to obtain the target detection result corresponding to the model verification data.
[0099] Specifically, when the target detection model fails to pass the verification, it is necessary to verify the regression detection sub-model and the classification sub-model in the target detection model respectively through the marked model verification data, so as to locate whether there is a problem with the regression detection sub-model of the feature extraction and regression process, or there is a problem with the classification sub-model of the detection target classification process. After obtaining the sub-model verification result; after updating the target detection model data according to the sub-model verification result, you can return to the step of inputting the model verification data into the target detection model and obtaining the target detection result corresponding to the model verification data, so as to re-verify the updated target detection model. In this embodiment, by verifying the regression detection sub-model and the classification sub-model in the target detection model that failed the verification step by step, it is more accurate to locate which part of the model is wrong, thereby effectively improving the efficiency of the model debugging process and comprehensively improving the training efficiency of the target detection model.
[0100] In one of the embodiments, the present application also provides a target detection method, which includes: obtaining image data to be detected; inputting the image data to be detected into the target detection model in the above embodiment to obtain a target detection result.
[0101] Specifically, after obtaining the target detection model, the model training server 104 can also implement target detection based on the target detection model. The user can submit the image data to be detected to the model training server 104 through the terminal 102, and then the model training server 104 inputs the received image data to be detected into the target detection model, and obtains the target detection result corresponding to the image data to be detected through the target detection model. The target detection model of the present application can effectively detect various types of detection targets.
[0102] In addition, the present application also provides an application scenario, which applies the above-mentioned target detection model training method based on classification regression. Specifically, the application of the target detection model training method based on classification regression in this application scenario is as follows: when it is necessary to detect the traffic flow and the number of various types of vehicles in the traffic flow at a designated road exit, the vehicle detection model can be trained by the target detection model based on classification regression of the present application to obtain a vehicle detection model, and then the vehicle detection model is used to detect the traffic flow and various types of vehicles (including large vehicles, medium-sized vehicles and small vehicles, etc.). Specifically, the user needs to prepare training data for the vehicle detection model and the initial target detection model. Among them, the model training data can be a historical picture collected at a designated road exit, and then add whether it contains a vehicle, the number of vehicles and the type of vehicle. Then, the feature extractor and regressor in the initial target detection model are trained with the labeled model training data to obtain a regression detection sub-model; the feature map corresponding to the model training data and the positive sample area in the feature map are obtained through the regression detection sub-model; according to the category of the detection target in the positive sample area, the model training data is evenly sampled to obtain classification training data. The classifier in the initial target detection model is trained according to the classification training data to obtain the classification sub-model; the target detection model is constructed according to the regression detection sub-model and the classification sub-model. At the same time, the trained model needs to be verified, and the labeled model verification data can be obtained; the model verification data is input into the target detection model to obtain the target detection result corresponding to the model verification data; the detection accuracy of the target detection model is obtained according to the data label corresponding to the model verification data and the target detection result corresponding to the model verification data; when the detection accuracy of the target detection model is greater than the preset accuracy threshold, the target detection model is determined to have passed the verification. When the detection accuracy of the target detection model is less than or equal to the preset accuracy threshold; the regression detection sub-model and the classification sub-model in the target detection model are verified respectively by the labeled model verification data to obtain the sub-model verification result; the target detection model is updated according to the sub-model verification result, and the step of inputting the model verification data into the target detection model to obtain the target detection result corresponding to the model verification data is returned.
[0103] It should be understood that although Figure 2-6 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 2-6At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0104] In one embodiment, Figure 7 As shown, a target detection model training device based on classification regression is provided, comprising:
[0105] The data acquisition module 702 is used to acquire model training data and an initial target detection model.
[0106] The first model training module 704 is used to train the feature extractor and the regressor in the initial target detection model through the model training data to obtain the regression detection sub-model.
[0107] The balanced sampling module 706 is used to perform balanced sampling on the model training data through the regression detection sub-model to obtain classification training data.
[0108] The second model training module 708 is used to train the classifier in the initial target detection model according to the classification training data to obtain a classification sub-model.
[0109] The model building module 710 is used to build a target detection model based on the regression detection sub-model and the classification sub-model.
[0110] In one embodiment, the balanced sampling module 706 is specifically used to: obtain the feature map corresponding to the model training data and the positive sample area in the feature map through the regression detection sub-model; and perform balanced sampling on the model training data according to the category of the detection target in the positive sample area to obtain classification training data.
[0111] In one of the embodiments, a training data construction module is also included, which is used to: obtain historical pictures and category information corresponding to the historical pictures, the historical pictures including historical pictures containing detection targets and historical pictures not containing detection targets; add target type tags to the historical pictures according to the category information corresponding to the historical pictures, and obtain model training data.
[0112] In one of the embodiments, the training data construction module is also used to: obtain model resolution requirements; perform data cleaning on historical images according to the model resolution requirements; add target type tags to the historical images after data cleaning according to category information corresponding to the historical images after data cleaning, and obtain model training data.
[0113] In one of the embodiments, a model verification module is also included, which is used to: obtain labeled model verification data, input the model verification data into the target detection model, and obtain the target detection results corresponding to the model verification data; obtain the detection accuracy of the target detection model based on the data labels corresponding to the model verification data and the target detection results corresponding to the model verification data; when the detection accuracy of the target detection model is greater than a preset accuracy threshold, it is determined that the target detection model has passed the verification.
[0114] In one of the embodiments, the model verification module is also used for: when the detection accuracy of the target detection model is less than or equal to a preset accuracy threshold; verifying the regression detection sub-model and the classification sub-model in the target detection model respectively through labeled model verification data to obtain sub-model verification results; updating the target detection model data according to the sub-model verification results, returning to the step of inputting the model verification data into the target detection model to obtain the target detection result corresponding to the model verification data.
[0115] In one of the embodiments, the present application also provides a target detection device, which is specifically used to: obtain image data to be detected; input the image data to be detected into the target detection model in the above-mentioned target detection model training device to obtain the target detection result.
[0116] For the specific limitations of the target detection model training device based on classification regression, please refer to the limitations of the target detection model training method based on classification regression above, which will not be repeated here. Each module in the above-mentioned target detection model training device based on classification regression can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0117] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 8 As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store target detection model training data based on classification regression. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a target detection model training method based on classification regression is implemented.
[0118] Those skilled in the art will understand that Figure 8 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0119] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0120] Obtain model training data and initial target detection model;
[0121] The feature extractor and regressor in the initial target detection model are trained using the model training data to obtain a regression detection sub-model;
[0122] The model training data is evenly sampled through the regression detection sub-model to obtain classification training data;
[0123] The classifier in the initial target detection model is trained according to the classification training data to obtain a classification sub-model;
[0124] The target detection model is constructed based on the regression detection sub-model and the classification sub-model.
[0125] In one embodiment, when the processor executes the computer program, the following steps are also implemented: obtaining a feature map corresponding to the model training data and a positive sample area within the feature map through a regression detection sub-model; performing balanced sampling on the model training data according to the category of the detection target in the positive sample area to obtain classification training data.
[0126] In one embodiment, when the processor executes the computer program, the processor also implements the following steps: obtaining historical pictures and category information corresponding to the historical pictures, the historical pictures including historical pictures containing the detection target and historical pictures not containing the detection target; adding target type tags to the historical pictures according to the category information corresponding to the historical pictures, and obtaining model training data.
[0127] In one embodiment, when the processor executes the computer program, the following steps are also implemented: adding target type tags to the historical pictures after data cleaning according to the category information corresponding to the historical pictures after data cleaning, and obtaining model training data.
[0128] In one embodiment, when the processor executes the computer program, the following steps are also implemented: obtaining labeled model verification data, inputting the model verification data into the target detection model, and obtaining the target detection results corresponding to the model verification data; obtaining the detection accuracy of the target detection model based on the data labels corresponding to the model verification data and the target detection results corresponding to the model verification data; when the detection accuracy of the target detection model is greater than a preset accuracy threshold, it is determined that the target detection model has passed the verification.
[0129] In one embodiment, the processor also implements the following steps when executing the computer program: when the detection accuracy of the target detection model is less than or equal to a preset accuracy threshold; the regression detection sub-model and the classification sub-model in the target detection model are respectively verified by labeled model verification data to obtain sub-model verification results; the target detection model is updated according to the sub-model verification results, and the step of returning to input the model verification data into the target detection model to obtain the target detection result corresponding to the model verification data is performed.
[0130] In one embodiment, a computer storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0131] Obtain model training data and initial target detection model;
[0132] The feature extractor and regressor in the initial target detection model are trained using the model training data to obtain a regression detection sub-model;
[0133] The model training data is evenly sampled through the regression detection sub-model to obtain classification training data;
[0134] The classifier in the initial target detection model is trained according to the classification training data to obtain a classification sub-model;
[0135] The target detection model is constructed based on the regression detection sub-model and the classification sub-model.
[0136] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: obtaining a feature map corresponding to the model training data and a positive sample area within the feature map through a regression detection sub-model; performing balanced sampling on the model training data according to the category of the detection target in the positive sample area to obtain classification training data.
[0137] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: obtaining historical pictures and category information corresponding to the historical pictures, the historical pictures including historical pictures containing detection targets and historical pictures not containing detection targets; adding target type tags to the historical pictures according to the category information corresponding to the historical pictures, and obtaining model training data.
[0138] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: adding target type tags to the historical pictures after data cleaning according to the category information corresponding to the historical pictures after data cleaning, and obtaining model training data.
[0139] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: obtaining labeled model verification data, inputting the model verification data into the target detection model, and obtaining the target detection results corresponding to the model verification data; obtaining the detection accuracy of the target detection model based on the data labels corresponding to the model verification data and the target detection results corresponding to the model verification data; when the detection accuracy of the target detection model is greater than a preset accuracy threshold, it is determined that the target detection model has passed the verification.
[0140] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: when the detection accuracy of the target detection model is less than or equal to a preset accuracy threshold; the regression detection sub-model and the classification sub-model in the target detection model are respectively verified by labeled model verification data to obtain sub-model verification results; the target detection model is updated according to the sub-model verification results, and the step of returning to input the model verification data into the target detection model to obtain the target detection result corresponding to the model verification data is performed.
[0141] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in the present application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0142] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0143] The above embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A target detection model training method based on classification regression, the method comprising: Obtain model training data and initial target detection model; The feature extractor and the regressor in the initial target detection model are trained using model training data to obtain a regression detection sub-model; Acquire a feature map corresponding to the model training data and a positive sample area in the feature map through the regression detection sub-model; Determining the category of the detection target in the positive sample area according to the annotation of the model training data; According to the category of the detection target in the positive sample area, the model training data is evenly sampled to obtain classification training data in which sample data of various types are balanced; Training the classifier in the initial target detection model according to the classification training data to obtain a classification sub-model; A target detection model is constructed based on the regression detection sub-model and the classification sub-model.
2. The method according to claim 1, characterized in that: The obtaining of model training data comprises: Acquire historical pictures and category information corresponding to the historical pictures, wherein the historical pictures include historical pictures containing the detection target and historical pictures not containing the detection target; According to the category information corresponding to the historical pictures, target type tags are added to the historical pictures to obtain model training data.
3. The method according to claim 2, characterized in that Before adding the target type tag to the historical image and obtaining the model training data, the method further includes: Get model resolution requirements; Performing data cleaning on the historical images according to the model resolution requirement; Adding target type tags to the historical images and obtaining model training data includes: According to the category information corresponding to the historical pictures after data cleaning, target type tags are added to the historical pictures after data cleaning to obtain model training data.
4. The method according to claim 1, characterized in that: After the target detection model is constructed according to the regression detection sub-model and the classification sub-model, the method further includes: Get labeled model validation data; Inputting the model verification data into the target detection model to obtain the target detection result corresponding to the model verification data; Obtaining the detection accuracy of the target detection model according to the data label corresponding to the model verification data and the target detection result corresponding to the model verification data; When the detection accuracy of the target detection model is greater than a preset accuracy threshold, it is determined that the target detection model has passed the verification.
5. The method according to claim 4, characterized in that After obtaining the detection accuracy of the target detection model according to the data mark corresponding to the model verification data and the target detection result corresponding to the model verification data, the method further includes: When the detection accuracy of the target detection model is less than or equal to the preset accuracy threshold; The regression detection sub-model and the classification sub-model in the target detection model are respectively verified by the labeled model verification data to obtain sub-model verification results; The target detection model is updated according to the sub-model verification result, and the step of inputting the model verification data into the target detection model to obtain the target detection result corresponding to the model verification data is returned.
6. A target detection method, characterized in that: The method comprises: Acquire image data to be detected; The image data to be detected is input into the target detection model as described in any one of claims 1 to 5 to obtain a target detection result.
7. A target detection model training device based on classification regression, characterized in that: The device comprises: Data acquisition module, used to obtain model training data and initial target detection model; A first model training module is used to train the feature extractor and the regressor in the initial target detection model through model training data to obtain a regression detection sub-model; A balanced sampling module is used to obtain the feature map corresponding to the model training data and the positive sample area in the feature map through the regression detection sub-model; determine the category of the detection target in the positive sample area according to the annotation of the model training data; and perform balanced sampling on the model training data according to the category of the detection target in the positive sample area to obtain classification training data in which sample data of various types are balanced; A second model training module is used to train the classifier in the initial target detection model according to the classification training data to obtain a classification sub-model; A model building module is used to build a target detection model based on the regression detection sub-model and the classification sub-model.
8. The device according to claim 7, characterized in that The data acquisition module is specifically used to: obtain historical pictures and category information corresponding to the historical pictures, the historical pictures including historical pictures containing detection targets and historical pictures not containing detection targets; add target type tags to the historical pictures according to the category information corresponding to the historical pictures, and obtain model training data.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Unbalanced data classification model training method, device and equipment and storage medium
CN110163261A
Improved target detection method based on region-of-interest training on small-scale data set
CN111783819A