Target detection model construction method and apparatus, target detection method and apparatus, and device, medium and product
By adopting the screening strategy of dynamic threshold and anchor box similarity conditions in the target detection model, the problem of low training accuracy of the target detection model in the existing technology is solved, and a more accurate target detection effect is achieved.
Patent Information
- Application Number
- PCT/CN2024/081690
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-03-31
- Filing Date
- 2024-03-14
- Publication Date
- 2024-10-03
AI Technical Summary
The training accuracy of existing target detection models is not high, resulting in inaccurate target detection. Especially in terminal devices, the use of fixed IOU thresholds can easily lead to missed detections or false detections.
A cascading strategy using dynamic thresholds for anchor box matching is used to update target anchor boxes through quality evaluation, adaptively adjust anchor box classification thresholds, select target anchor boxes that meet anchor box similarity conditions, and determine reasonable anchor boxes based on the intersection and union ratio. Classification threshold, dynamically adjust the number of anchor boxes to improve detection accuracy.
It improves the accuracy and recall rate of the target detection model, reduces the false detection rate, achieves more accurate classification of positive and negative samples, and improves the detection accuracy of the target detection model.
Smart Images

Figure CN2024081690_03102024_PF_FP_ABST
Abstract
Description
Target detection model construction, target detection methods, devices, equipment, media and products
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] This application is based on the application with CN application number 202310343525.4 and application date March 31, 2023, and claims its priority. The disclosed content of the CN application is hereby introduced as a whole into this application. Technical Field
[0003] The embodiments of the present disclosure relate to the field of computer technology, and in particular to target detection model construction, target detection methods, devices, equipment, media, and products. Background Art
[0004] Object detection models typically use algorithms such as deep neural networks to detect target objects in images and determine their categories, such as vehicles, streetlights, and pedestrians. Object detection models can typically detect multiple objects in an image, and each object can be marked with a detection box.
[0005] In related technologies, object detection models typically set multiple anchor boxes in an image and classify the anchor boxes using a fixed threshold to obtain positive and negative samples. Detection boxes are then predicted using the anchor boxes that are classified as positive samples.
[0006] Summary of the Invention
[0007] In a first aspect, an embodiment of the present disclosure provides a method for constructing a target detection model, comprising:
[0008] Based on the target detection model, multiple anchor boxes of the sample image are determined;
[0009] Based on at least one annotation frame of the sample image, selecting a target anchor frame that meets the anchor frame similarity condition from multiple anchor frames;
[0010] Determining an anchor box classification threshold based on at least one annotation box and a target anchor box;
[0011] Iteratively update the target detection model based on the anchor box classification threshold and multiple anchor boxes corresponding to the sample image;
[0012] In response to the target detection model iteration not being terminated, the proportion of first-quality anchor frames in multiple anchor frames is determined according to the quality evaluation threshold. In response to the proportion of first-quality anchor frames being greater than a preset proportion threshold, the target anchor frame is updated. The quality evaluation threshold is determined based on the anchor frame classification threshold. The first-quality anchor frame is an anchor frame among multiple anchor frames whose intersection-over-union ratio with the labeling frame is greater than the quality evaluation threshold.
[0013] In a second aspect, an embodiment of the present disclosure provides a target detection method, including:
[0014] In response to a target detection request, determining an image to be detected;
[0015] Based on the target detection model, the detection result of the target object in the image to be detected is output. The target detection model is constructed based on the target detection model construction method provided by the first aspect above.
[0016] In a third aspect, an embodiment of the present disclosure provides a device for constructing a target detection model, comprising:
[0017] A determination unit, configured to determine multiple anchor frames of a sample image based on a target detection model;
[0018] A selection unit, configured to select a target anchor frame that satisfies an anchor frame similarity condition from a plurality of anchor frames based on at least one annotation frame of the sample image;
[0019] A threshold unit, configured to determine an anchor box classification threshold based on at least one annotation box and a target anchor box;
[0020] An iterative unit, configured to iteratively update the target detection model based on an anchor box classification threshold and multiple anchor boxes corresponding to multiple sample images;
[0021] An updating unit is configured to determine, in response to the target detection model iteration not being terminated, a proportion of first-quality anchor frames in a plurality of anchor frames according to a quality evaluation threshold, and to update a target anchor frame in response to the proportion of the first-quality anchor frames being greater than a preset proportion threshold, wherein the quality evaluation threshold is determined based on an anchor frame classification threshold; the first-quality anchor frame is an anchor frame in a plurality of anchor frames whose intersection-over-union ratio with the labeled frame is greater than the quality evaluation threshold.
[0022] In a fourth aspect, an embodiment of the present disclosure provides a target detection device, including:
[0023] A response unit, configured to determine an image to be detected in response to a target detection request;
[0024] An input unit is used to output a detection result of a target object in an image to be detected based on a target detection model, wherein the target detection model is trained based on any one of the target detection model construction methods provided in the first aspect above.
[0025] In the fifth aspect, an embodiment of the present disclosure provides an electronic device, comprising: a processor and a memory; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory, so that at least one processor executes the target detection model construction method as described in the first aspect and various possible methods involved in the first aspect, or the target detection method as described in the second aspect and various possible methods involved in the second aspect.
[0026] In the sixth aspect, an embodiment of the present disclosure provides a computer-readable storage medium, in which computer execution instructions are stored. When the processor executes the computer execution instructions, the target detection model construction method as described in the first aspect and various possible methods involved in the first aspect or the target detection method as described in the second aspect and various possible methods involved in the second aspect are implemented.
[0027] In the seventh aspect, an embodiment of the present disclosure provides a computer program product, including a computer program, which, when executed by a processor, implements the first aspect and various possible target detection model construction methods involved in the first aspect or the second aspect and various possible target detection methods involved in the second aspect.
[0028] In an eighth aspect, an embodiment of the present disclosure provides a computer program comprising instructions, which, when executed by a processor, causes the processor to execute the target detection model construction method as described in the first aspect and various possible methods involved in the first aspect, or the target detection method as described in the second aspect and various possible methods involved in the second aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0030] FIG1 is an application network architecture diagram of a method for building a target detection model provided by an embodiment of the present disclosure;
[0031] FIG2 is a flow chart of a method for constructing a target detection model provided by an embodiment of the present disclosure;
[0032] FIG3 is an example diagram of an anchor frame provided by an embodiment of the present disclosure;
[0033] FIG4 is a flow chart of a method for constructing a target detection model provided by an embodiment of the present disclosure;
[0034] FIG5 is a flow chart of a method for constructing a target detection model provided by an embodiment of the present disclosure;
[0035] FIG6 is a flow chart of a method for constructing a target detection model provided by an embodiment of the present disclosure;
[0036] FIG7 is a flow chart of a target detection method provided by an embodiment of the present disclosure;
[0037] FIG8 is a structural diagram illustrating an example of a target detection model building device provided by an embodiment of the present disclosure;
[0038] FIG9 is a structural diagram illustrating an example of a target detection device provided by an embodiment of the present disclosure;
[0039] FIG10 is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0040] To make the objectives, technical solutions, and advantages of the embodiments of the present disclosure more clear, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present disclosure, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present disclosure without making any creative efforts shall fall within the scope of protection of the present disclosure.
[0041] In the related art, the computing power of the terminal device is relatively poor. The terminal device can be, for example, a mobile phone, a vehicle-mounted device, a tablet computer, a handheld device, etc. The terminal device can set a trained target detection model and detect targets such as vehicles, faces, street lights and / or license plates through the target detection model. In order to achieve target detection of the terminal device, an anchor frame matching training strategy can generally be adopted. This strategy can set multiple anchor frames and corresponding GT (Ground truth, annotation frame), and calculate the IOU (Intersection over Union, overlap rate or intersection over union ratio) values between multiple anchor frames and annotation frames respectively, and obtain the IOU values corresponding to the multiple anchor frames. The IOU values corresponding to each anchor frame are used to determine whether each anchor frame belongs to a positive sample or a negative sample. However, when the IOU threshold is directly set, missed detection or false detection is prone to occur. An IOU threshold that is too high may result in missed detection, and an IOU threshold that is too low may result in multiple false detections.
[0042] As mentioned above, the detection frame obtained by using a fixed threshold for detection is not very accurate.
[0043] In response to the above technical problems, the embodiments of the present disclosure provide a target detection model construction, target detection method, device, equipment, medium and product to overcome the problem of low training accuracy of the target detection model, which leads to inaccurate target detection.
[0044] The technical solution disclosed herein can be applied to fields such as intelligent transportation, target tracking, and video special effects applications in the fields of artificial intelligence and computer vision. During the iterative training of the target detection model, a cascade strategy for anchor frame matching based on dynamic thresholds can be implemented. The cascade strategy can refer to updating the target anchor frame using the quality evaluation of the anchor frame after an iterative update, dynamically adjusting the threshold using the target anchor frame, and adaptively adjusting the anchor frame quality evaluation threshold and the anchor frame classification threshold. This can improve the detection effect of the anchor frame classification threshold on the target detection model, obtain more accurate classification results for positive and negative samples, improve false positives, and increase the recall rate of the target detection model.
[0045] In an embodiment of the present disclosure, during the construction of a target detection model, based on multiple anchor frames and annotation frames for a sample image, the target anchor frame can be selected from multiple anchor frames using the annotation frame. The target anchor frame is an anchor frame that satisfies the similarity condition of the anchor frame, so that the target anchor frame and the annotation frame meet the similarity condition. By setting the similarity condition of the anchor frame, the screening of the target anchor frame can be achieved. After obtaining the target anchor frame, the annotation frame and the target anchor frame can be used to determine the anchor frame classification threshold. The target anchor frame is closer to the annotation frame. By allowing the target anchor frame to participate in the determination process of the anchor frame classification threshold, a more reasonable anchor frame classification threshold can be determined. According to the anchor frame classification threshold and the multiple anchor frames corresponding to the sample image, the target detection model can be iteratively updated. When the iteration of the target detection model is not terminated, the proportion of the first quality anchor frame in the multiple anchor frames can be determined according to the quality evaluation threshold. If the proportion of the first quality anchor frame is greater than the preset ratio threshold, the target anchor frame can be updated. The quality evaluation threshold is determined based on the anchor frame classification threshold. When the proportion of the first quality anchor frame is greater than the preset ratio threshold, the target anchor frame can be updated to adjust the anchor frame classification threshold. The adjusted anchor frame classification threshold can enable the target detection model to classify the anchor frame more accurately, improve the detection accuracy of the target classification model, and reduce the false detection rate.
[0046] The following describes in detail the technical solutions of the present invention and how they solve the above-mentioned technical problems by way of embodiments. The following embodiments may be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments. The following embodiments of the present invention are described in detail with reference to the accompanying drawings.
[0047] FIG1 is an application network architecture diagram of a target detection model construction method provided by the present disclosure. The application network architecture according to the embodiment of the present disclosure may include an electronic device and a client that is connected to the electronic device through a local area network or a wide area network. Assuming that the electronic device can be a personal computer, an ordinary server, a super personal computer, a cloud server or other types of servers, the present disclosure does not make too many restrictions on the specific type of the electronic device. The client can be, for example, a mobile phone, a tablet computer, a vehicle-mounted device, a smart home appliance, a wearable device or other terminal device. The present disclosure does not make too many restrictions on the specific type of the client. As shown in FIG1 , the technical solution of the present disclosure is introduced in detail by taking the electronic device as a cloud server 11 and the first client vehicle-mounted terminal 12 as an example.
[0048] For example, the cloud server 11 can train the target detection model using the target detection model construction method disclosed herein to obtain the target detection model. The target detection model can be sent to the vehicle terminal 12, which is only exemplary. During operation of the vehicle terminal 12, the target in the image to be detected 13, such as a vehicle 131 or a pedestrian 132, is detected to achieve accurate detection of the target.
[0049] Referring to FIG2 , FIG2 is a flowchart of a method for building a target detection model provided by an embodiment of the present disclosure. The method may include the following steps:
[0050] 201: Based on the target detection model, determine multiple anchor boxes of the sample image.
[0051] For example, an anchor frame can be a fixed reference frame of different sizes and aspect ratios set in the image. When constructing the target detection model, the training sample can be constructed by the degree of overlap between the annotation frame and the anchor frame, that is, the target detection model can divide multiple anchor frames into positive samples and negative samples. The detection target is further determined by the divided positive samples. In practical applications, an image can be set with a 4-digit or even 5-digit anchor frame, so the sample division of the anchor frame is more important. Of course, in order to ensure the full detection of each coordinate point in the image, multi-scale anchor frame setting can be performed on the same pixel point, that is, multiple anchor frames are set with the pixel point as the center, and the pixel point can be obtained from pixel sampling in the sample image. In addition, at least one channel image corresponding to the sample image can be anchored separately, and the anchor frame setting can be implemented with a smaller image processing unit to improve the accuracy of the anchor frame setting.
[0052] 202: Based on the annotation box of the sample image, a target anchor box that meets the anchor box similarity condition is selected from multiple anchor boxes.
[0053] The sample image can also be associated with at least one annotation box, which can be used to mark the rectangular box and category label of the detection target or detection object. For example, the annotation box can include a rectangular box corresponding to a vehicle and a vehicle category label, a rectangular box and a pedestrian category label for each of one or more pedestrians in the image, and a rectangular box and a road label corresponding to the road. Therefore, a sample image can be associated with at least one annotation box, each of which is associated with a category label, and the category label can be the label of the detection target in the annotation box. The anchor box and at least one annotation box are calculated for IOU, and the maximum IOU value corresponding to the anchor box is obtained. When the maximum IOU value is greater than the IOU threshold, the anchor box is determined to be a positive sample, and the category label of the annotation box corresponding to the maximum IOU value can be used as the category label of the anchor box. For example, if the label category of the annotation box corresponding to the anchor box is "cat", "cat" can be used as the category of the detection target in the anchor box, which means that the detection target in the anchor box is determined to be a cat.
[0054] For ease of understanding, as shown in an example diagram of an anchor frame in Figure 3, a sample image 300 can include multiple anchor frames 301, and the sizes and positions of the anchor frames can be different. Of course, the number, size, and position of the anchor frames are exemplary and should not constitute a specific limitation. In actual applications, the anchor frame can cover the entire sample image, which is not shown here for the sake of clarity. The annotation box can be a pre-marked real rectangular box that can accurately surround the detected target, refer to the annotation box 302 in Figure 3. The annotation box can be associated with the target category of the detected target in the box.
[0055] For example, the anchor frame similarity condition can be represented by the similarity between the anchor frame and the annotated frame. For example, based on the similarity between multiple anchor frames and the annotated frame, the top K anchor frames with the highest similarity can be selected as the target anchor frames. A similarity threshold can also be set, and based on the similarity between multiple anchor frames and the annotated frame, the anchor frame with a similarity higher than the similarity threshold can be selected as the target anchor frame.
[0056] 203: Determine the anchor box classification threshold based on the annotation box and the target anchor box.
[0057] The anchor box classification threshold can be a value for distinguishing positive and negative samples of the anchor box during the construction of the target detection model. When the IOU value corresponding to the anchor box is greater than the anchor box classification threshold, the anchor box is a positive sample. When the IOU value corresponding to the anchor box is not less than the anchor box classification threshold, the anchor box is a negative sample.
[0058] For example, step 203 may include: calculating the IOU value between the annotation box and its corresponding target anchor box, and calculating the anchor box classification threshold according to the IOU value corresponding to each target anchor box.
[0059] For example, the annotation box may include at least one. Step 203 may be: determining an anchor box classification threshold based on the at least one annotation box and the target anchor box corresponding to the at least one annotation box. The calculation method of the anchor box classification threshold can refer to the detailed description of the following embodiment.
[0060] 204: Iteratively update the target detection model according to the anchor box classification threshold and multiple anchor boxes corresponding to the sample image.
[0061] For example, iterative updates to an object detection model can refer to continuously iteratively updating the model parameters of the object detection model. During this iterative update, the anchor box classification threshold can be simultaneously updated. The anchor box classification threshold can participate in the iterative update process of the object detection model, and by adjusting the anchor box classification threshold, the model parameters of the object detection model can be continuously optimized.
[0062] For example, the target detection model can predict the offset between the anchor box and the annotation box, obtain the offset prediction result between the anchor box and its annotation box, and calculate the error based on the prediction result and the true value offset between the anchor box and its corresponding annotation box to obtain the error loss, and update the target detection model through the error loss.
[0063] 205: If the iteration of the target detection model has not terminated, the proportion of first-quality anchor frames in the multiple anchor frames is determined according to the quality evaluation threshold. If the proportion of first-quality anchor frames is greater than the preset proportion threshold, the target anchor frame is updated; the quality evaluation threshold is determined based on the anchor frame classification threshold; the first-quality anchor frame is the anchor frame whose intersection-over-union ratio with the annotation frame is greater than the quality evaluation threshold among the multiple anchor frames.
[0064] For example, if the object detection model iteration terminates, the object detection model at the time of the termination is obtained. The object detection model obtained at the time of the termination can be used to detect the detection box containing the target object in the image to be detected and output the category corresponding to the detection box. The category corresponding to the detection box is the object category to which the target object belongs.
[0065] For example, the target detection model iteration not being terminated may include: the error loss of the target detection model is less than a loss threshold and / or the preset number of iterations is not reached.
[0066] In an embodiment of the present disclosure, during the construction of a target detection model, based on multiple anchor frames and annotation frames for a sample image, the target anchor frame can be selected from multiple anchor frames using the annotation frame. The target anchor frame is an anchor frame that satisfies the similarity condition of the anchor frame, so that the target anchor frame and the annotation frame meet the similarity condition. By setting the similarity condition of the anchor frame, the screening of the target anchor frame can be achieved. After obtaining the target anchor frame, the annotation frame and the target anchor frame can be used to determine the anchor frame classification threshold. The target anchor frame is closer to the annotation frame. By allowing the target anchor frame to participate in the determination process of the anchor frame classification threshold, a more reasonable anchor frame classification threshold can be determined. According to the anchor frame classification threshold and the multiple anchor frames corresponding to the sample image, the target detection model can be iteratively updated. When the iteration of the target detection model is not terminated, the proportion of the first quality anchor frame in the multiple anchor frames can be determined according to the quality evaluation threshold. If the proportion of the first quality anchor frame is greater than the preset ratio threshold, the target anchor frame can be updated. The quality evaluation threshold is determined based on the anchor frame classification threshold. When the proportion of the first quality anchor frame is greater than the preset ratio threshold, the target anchor frame can be updated to adjust the anchor frame classification threshold. The adjusted anchor frame classification threshold can enable the target detection model to classify the anchor frame more accurately, improve the detection accuracy of the target classification model, and reduce the false detection rate.
[0067] FIG4 is a flowchart of a method for building a target detection model according to an embodiment of the present disclosure. The method differs from the aforementioned embodiment in that step 202, based on the annotation frame, selects a target anchor frame from multiple anchor frames that satisfies the anchor frame similarity condition. The method may include the following steps:
[0068] 401: Determine the number of anchor boxes corresponding to the target anchor box set for the annotation box.
[0069] For example, in this embodiment, the number of anchor boxes corresponding to a target anchor box can be represented by the symbol k. One annotation box can correspond to k target anchor boxes.
[0070] 402: According to the number of annotation boxes and anchor boxes, select a target anchor box that meets the anchor box similarity condition from multiple anchor boxes.
[0071] In step 205, updating the target anchor frame may include:
[0072] 403: Update the number of anchor boxes, and select a target anchor box that meets the anchor box similarity condition from multiple anchor boxes based on the updated number of anchor boxes and the annotation box.
[0073] In an embodiment of the present disclosure, during the iterative update process of the target detection model, the number of anchor boxes of the target anchor box can be set, and the selection process of the target anchor box can be constrained according to the number of anchor boxes of the target anchor box, so that the selection of the target anchor box is adapted to the number of anchor boxes.
[0074] For example, based on any of the above embodiments, updating the number of anchor boxes includes:
[0075] Determine the number of first anchor frames according to the number of anchor frames and the preset adjustment amount;
[0076] and / or,
[0077] Determine the first number of anchor frames based on the number of anchor frames and the preset adjustment coefficient;
[0078] The updated number of anchor boxes is determined based on the first number of anchor boxes.
[0079] For example, the adjustment amount can be a pre-set constant for adjusting the number of anchor boxes. The adjustment amount can be added to the number of anchor boxes to obtain the first number of anchor boxes. The size of the adjustment amount can be set according to usage requirements, for example, it can be set to an arbitrary constant such as 1 or -2. The first number of anchor boxes can be expressed as the sum of the number of anchor boxes and the adjustment amount. For example, if the number of anchor boxes is represented by k, when the adjustment amount is -2, the first number of anchor boxes can be expressed as k-2. The adjustment coefficient can be a pre-set constant for adjusting the change ratio of the number of anchor boxes. The adjustment coefficient can be multiplied by the number of anchor boxes to obtain the first number of anchor boxes. The value of the adjustment coefficient can be set according to usage requirements, for example, it can be set to an arbitrary constant such as 1, 0.9, or 0.8.
[0080] For example, the number of first anchor frames can be determined using both the adjustment amount and the adjustment coefficient. The number of anchor frames can be first added to the adjustment amount to obtain the number of second anchor frames, and then the second number of anchor frames can be multiplied by the adjustment coefficient to obtain the number of first anchor frames. Alternatively, the number of anchor frames can be multiplied by the adjustment coefficient to obtain the number of third anchor frames, and then the third number of anchor frames can be added to the adjustment amount to obtain the number of first anchor frames.
[0081] In this embodiment, by setting the adjustment amount and / or adjustment coefficient, flexible adjustment of the number of anchor frames can be achieved. By adjusting the number of anchor frames to different degrees, the number of anchor frames can be made more adaptable to the current model iteration, thereby improving the stability of model detection and avoiding the anchor frame classification threshold being set too high or too low due to the number of anchor frames being too high or too low, thereby reducing the stability of model detection.
[0082] For example, based on any of the foregoing embodiments, determining the updated number of anchor boxes based on the first number of anchor boxes includes:
[0083] If the first anchor frame number is greater than the preset upper limit of the anchor frame number, determining the preset upper limit of the anchor frame number to be the updated anchor frame number;
[0084] If the first number of anchor frames is less than or equal to the preset upper limit of the number of anchor frames, the first number of anchor frames is determined to be the updated number of anchor frames.
[0085] Exemplarily, the number of anchor boxes can be updated by inputting the number of anchor boxes into the anchor box number update formula, and the new number of anchor boxes can be calculated to achieve accurate update of the number of anchor boxes.
[0086] For example, the update formula for the number of anchor boxes can be expressed as:
[0087] k2=min(maxk,β(k1+α), where α is the adjustment amount of the number of anchor boxes, and β is the adjustment coefficient of the number of anchor boxes. maxk is the upper limit of the preset number of anchor boxes, that is, the preset maximum number of anchor boxes. k1 can be the number of anchor boxes used in this iterative training, and k2 can be the updated number of anchor boxes. The updated number of anchor boxes can be used for the next iteration.
[0088] The adjustment amount, adjustment coefficient, and upper limit of the number of anchor boxes can be set according to usage requirements. For example, the adjustment amount can be set to -2, the adjustment coefficient to 1, and the upper limit of the number of anchor boxes to 7.
[0089] In this embodiment, the first number of anchor boxes may be the number of anchor boxes adjusted by the adjustment amount and / or the adjustment coefficient. The updated first number of anchor boxes is constrained by an upper limit on the number of anchor boxes. When the first number of anchor boxes is greater than the upper limit, the upper limit is determined to be the updated number of anchor boxes; otherwise, the first number of anchor boxes is determined to be the updated number of anchor boxes. The upper limit on the number of anchor boxes is a preset empirical value obtained through multiple experiments. Since the setting of the number of anchor boxes can directly affect the anchor box classification threshold, when the first number of anchor boxes is constrained by the upper limit on the number of anchor boxes, the problem of the anchor box classification threshold remaining in an unreasonable numerical range for a long time, which may occur when the first number of anchor boxes is unconstrained, can be avoided. This may result in the target detection model requiring multiple iterative training cycles to adjust the anchor box classification threshold to a reasonable value. The method of the disclosed embodiment improves the efficiency of adjusting the anchor box classification threshold, thereby effectively reducing the number of model iterations and increasing the speed of building the target detection model.
[0090] In some embodiments, based on the number of annotation boxes and anchor boxes, selecting a target anchor box that meets the anchor box similarity condition from multiple anchor boxes includes:
[0091] For at least one annotation box, calculate the similarity between each annotation box and multiple anchor boxes respectively;
[0092] Sort the similarities between each annotation box and multiple anchor boxes in descending order to obtain the sorting results corresponding to each annotation box;
[0093] Based on the number k of anchor boxes and the ranking results corresponding to each annotation box, the first k anchor boxes corresponding to each annotation box are determined as the target anchor boxes corresponding to the annotation box.
[0094] For example, the similarity between the annotation box and the anchor box may include the intersection-over-union (IOU) of the anchor box and the annotation box. The intersection of the anchor box and the annotation box may be determined first, and then the union of the anchor box and the annotation box may be determined. The ratio of the intersection and the union may be calculated to obtain the IOU value of the anchor box as the similarity. In addition, in addition to the ratio between the intersection and the union of the anchor box and the annotation box mentioned above, the intersection-over-union may also include any one of the intersection-over-union ratios, such as GIOU (Generalized Intersection over Union) and DIOU (Distance-Intersection over Union). In this embodiment, the specific calculation method of the intersection-over-union ratio is not overly limited.
[0095] In the disclosed embodiment, the similarity between each annotation frame and multiple anchor frames can be calculated based on the anchor frame and the annotation frame corresponding to the anchor frame. By sorting the similarities, the closest and most similar target anchor frame can be obtained for each annotation frame, further improving the accuracy of the anchor frame classification threshold.
[0096] For example, based on any embodiment, determining the anchor box classification threshold based on the labeled box and the target anchor box includes:
[0097] According to the target anchor box corresponding to the annotation box, determine the intersection-over-union ratio of the annotation box and each target anchor box;
[0098] The anchor box classification threshold is determined based on the intersection-over-union ratio between the annotation box and each target anchor box.
[0099] For example, a label box can correspond to multiple target anchor boxes, and the intersection-over-union ratio of each label box and its corresponding target anchor box can be calculated. The anchor box classification threshold is determined by the intersection-over-union ratio of each label box and its corresponding target anchor box.
[0100] For example, the intersection-and-union (IoU) of each annotation box and its corresponding target anchor box can be sorted to obtain the IoU ranking result for each target anchor box. The median IoU of the IoU ranking results of the K target anchor boxes corresponding to each annotation box can be selected as the anchor box classification threshold. Alternatively, the mean of each annotation box and its corresponding target anchor box can be calculated to obtain the anchor box classification threshold.
[0101] For example, the IoU ratios of the K target anchor boxes corresponding to each labeled frame can be added together to obtain the total IoU ratio, and the total number of target anchor boxes corresponding to the K target anchor boxes corresponding to each labeled frame can be determined. The quotient of the total IoU ratio and the total number of target anchor boxes can be calculated as the anchor box classification threshold. The number of K target anchor boxes corresponding to different labeled frames can be the same or different.
[0102] For example, suppose there are three annotation boxes, which correspond to K1, K2, and K3 target anchor boxes respectively. The target anchor boxes corresponding to the three annotation boxes can be sorted by their intersection-and-union ratio to obtain the sorted results of (K1+K2+K3) target anchor boxes, and the intersection-and-union ratio of the target anchor box corresponding to the median of the results can be taken as the anchor box classification threshold.
[0103] Similarly, taking the example of three annotation boxes corresponding to K1, K2 and K3 target anchor boxes respectively, the intersection-and-union ratios of the K1 target anchor box, the K2 target anchor box and the K3 target anchor box can be added to obtain the total intersection-and-union ratios, and the total number of target anchor boxes corresponding to the K target anchor boxes of each annotation box can be calculated: K1+K2+K3. The quotient of the sum of the intersection-and-union ratios and the total number of target anchor boxes can be calculated as the anchor box classification threshold.
[0104] For example, taking the median as the anchor box classification threshold, the following formula can be used: median(IOU top-k )
[0105] Top-k can be the K target anchor boxes corresponding to the annotation box that meet the anchor box similarity condition. Median represents the function that takes the median of the IOU values of the K target anchor boxes.
[0106] In the embodiment of the present disclosure, after the target anchor frame selection is performed for the annotation frame, the anchor frame classification threshold can be determined through the k target anchor frames corresponding to the annotation frame, so that the anchor frame classification threshold is referenced to the k target anchor frames. The target anchor frame is an anchor frame that meets similar anchor frame conditions as the annotation frame, which is more in line with actual detection requirements. Therefore, the accuracy and precision of the anchor frame classification threshold can be improved through the target anchor frame.
[0107] FIG5 is a flowchart of a method for building a target detection model provided by an embodiment of the present disclosure. The method differs from the above embodiment in that, in step 203, the target detection model is iteratively updated based on the anchor box classification threshold and multiple anchor boxes corresponding to the sample image. The method may include the following steps:
[0108] 501: Classify the multiple anchor frames according to the anchor frame classification threshold and the label frame corresponding to the sample image to obtain classification results corresponding to the multiple anchor frames, where the classification results include positive samples or negative samples.
[0109] For example, the classification result corresponding to an anchor box may include a positive sample indicating that the anchor box belongs to a certain annotated box, or a negative sample indicating that the anchor box is a negative sample. A positive sample corresponding to a annotated box may include one or more. In addition, the classification result may also include other classification results that are neither positive nor negative. Anchor boxes judged to have such other classification results may not participate in the subsequent training of the object detection model.
[0110] 502: According to the target detection model, target detection is performed based on the positive anchor box whose classification result is a positive sample, and a detection result corresponding to the positive anchor box is obtained.
[0111] For example, the positive class anchor box may include an anchor box that corresponds to a certain annotation box and belongs to a positive sample of the annotation box.
[0112] 503: Iteratively update the target detection model based on the detection results and annotation boxes corresponding to the positive anchor boxes.
[0113] For example, step 503 may include calculating an error loss based on the detection results and the labeled boxes corresponding to the positive class anchor boxes. The error loss is used to determine whether the object detection model iteration has terminated. If so, the current object detection model is obtained. If not, the object detection model is updated and step 205 is executed.
[0114] The target detection model can predict the offset between the positive class anchor box and its corresponding annotated box. That is, for the positive class anchor box, the target detection model can predict the first offset between it and the annotated box that best matches it. This first offset is a predicted value. Since the annotated box corresponding to the actual positive class anchor box has been determined in step 501, the second offset between the positive class anchor box and its corresponding annotated box can be calculated. This second offset is a calculated value. The loss can be calculated using the first and second offsets of each positive class sample to obtain the error loss of the target detection model.
[0115] For the steps related to the iterative termination judgment and error loss calculation of the target detection model, please refer to the description of the relevant technology and will not be repeated here.
[0116] For example, the classification results of positive and negative samples of the anchor box can be determined by the following formula:
[0117] bbox represents the classification result of the anchor box. Thr is the anchor box classification threshold.
[0118] In the disclosed embodiment, during the iterative training of the target detection model, multiple anchor frames can be classified and processed by using the anchor frame classification threshold and the annotation frame to obtain the classification results of each anchor frame, which may include positive samples or negative samples. After the anchor frame classification, target detection can be performed based on the positive class anchor frame whose classification result is a positive sample according to the target detection model to obtain the detection result corresponding to the positive class anchor frame. That is, target detection of the positive class anchor frame can be achieved through anchor frame classification and model detection, so that the target detection model learns the characteristics of the positive sample. Since sample classification is achieved based on the anchor frame classification threshold, the dynamic adjustment of the anchor frame classification threshold can continuously optimize the classification results of each anchor frame, and then use the continuously optimized anchor frame classification results to train the target detection model, which can effectively improve the detection accuracy of the target detection model and reduce the false detection rate of the model.
[0119] For example, based on any of the above embodiments, step 501 may include:
[0120] According to the annotation box corresponding to the sample image, determine the intersection-over-union ratios corresponding to multiple anchor boxes and the annotation box respectively;
[0121] If the intersection-over-union ratio corresponding to the anchor frame is less than the anchor frame classification threshold, the classification result of the anchor frame is determined to be a negative sample;
[0122] For each annotation box, if the intersection-over-union ratio of the anchor box to the annotation box is greater than the anchor box classification threshold, the anchor box is determined to be the positive sample corresponding to the annotation box.
[0123] For any anchor box, if the intersection-over-union ratio of the anchor box is less than the anchor box classification threshold, the negative sample is the classification result of the anchor box, and the anchor box no longer participates in the positive sample selection of the annotation box.
[0124] For each annotation box, one annotation box can correspond to one or more corresponding anchor boxes. If the intersection-over-union ratio of the anchor box corresponding to the annotation box and the annotation box is greater than the anchor box classification threshold, the anchor box corresponding to the annotation box is determined to be a positive sample of the annotation box.
[0125] For example, the step of determining the positive sample corresponding to each labeled box may include: first determining the intersection-over-union (IoU) of the labeled box and its corresponding at least one anchor box, and then selecting an anchor box whose IoU value with the at least one anchor box corresponding to the labeled box is greater than the anchor box classification threshold as the positive sample corresponding to the labeled box. Each labeled box may correspond to one or more positive samples. A positive sample of a labeled box refers to an anchor box corresponding to the labeled box and whose IoU value is greater than the anchor box classification threshold.
[0126] In this embodiment, by comparing the intersection-over-union ratio corresponding to the anchor box and the labeled box with the anchor box classification threshold, the anchor box can be classified into positive and negative samples, and the positive and negative samples of the labeled box can also be classified, so that a comprehensive classification of the anchor frame can be achieved. Through the accurate classification of the anchor frame, more accurate positive and negative samples can be obtained, and then when the positive sample is used for target detection model training, the detection accuracy of the target detection model for the positive sample can be improved, a more stable model detection result can be obtained, the model detection stability can be improved, and the model false detection rate can be reduced.
[0127] For example, the steps for calculating the intersection-over-union (IOU) corresponding to each anchor frame may include: first determining the label frame corresponding to each anchor frame; calculating the IOU value between each anchor frame and the label frame corresponding to the anchor frame to obtain the IOU value corresponding to each anchor frame. The IOU value of each anchor frame may then be compared with the anchor frame classification threshold to obtain the threshold comparison results corresponding to each anchor frame, where the threshold comparison results include being greater than the anchor frame classification threshold or less than or equal to the anchor frame classification threshold. From the threshold comparison results of each anchor frame, anchor frames greater than the anchor frame classification threshold may be determined as positive samples, and anchor frames less than or equal to the anchor frame classification threshold may be determined as negative samples.
[0128] For example, determining the labeling box corresponding to each anchor box may include: calculating the IOU values corresponding to each anchor box and at least one labeling box, respectively, to obtain the labeling box corresponding to the maximum IOU value of each anchor box as the labeling box corresponding to the anchor box.
[0129] For example, the classification results of positive and negative samples of the anchor box can be determined by the following formula:
[0130] bbox represents the classification result of the anchor box. Thr is the anchor box classification threshold.
[0131] For example, the anchor box classification threshold can be used to calculate the quality evaluation threshold. The calculation steps of the quality evaluation threshold include:
[0132] Multiply the anchor box classification threshold and the threshold adjustment coefficient to obtain the first quality threshold, and add the first quality threshold and the threshold adjustment amount to obtain the quality evaluation threshold. That is, the calculation formula of the quality evaluation threshold Qthr can be: Othr=Δt2+Δt1*thr
[0133] thr is the anchor box classification threshold, Δt1 is the threshold adjustment coefficient, and Δt2 is the threshold adjustment amount. The threshold adjustment coefficient and threshold adjustment amount can be set according to usage requirements. For example, the adjustment coefficient can be set to 2 / 3, and the adjustment amount can be set to 1 / 3.
[0134] In this embodiment, the quality evaluation threshold can be calculated by the anchor box classification threshold and the quality threshold calculation formula, and the quality evaluation threshold is determined based on the anchor box classification threshold. The quality evaluation threshold is used to determine the proportion of the first quality anchor box. When the proportion of the first quality anchor box is greater than the preset proportion threshold, the target anchor box can be updated, thereby achieving the update of the anchor box classification threshold. For example, when the proportion of the first quality anchor box is greater than the preset proportion threshold, it means that the anchor box classification threshold is set too high. At this time, the number of anchor boxes can be dynamically reduced, and the target anchor box can be updated according to the updated number of anchor boxes. From the aforementioned embodiment, it can be seen that the anchor box classification threshold can be dynamically improved through the above method, and the improvement of the anchor box classification threshold can screen positive samples with higher IOU, that is, positive samples with higher quality, to participate in the training of the target detection model, thereby enabling the target detection model to learn positive samples with higher IOU and improve the model's false detection.
[0135] As shown in FIG6 , a flowchart of a method for building a target detection model provided by an embodiment of the present disclosure is provided. The difference from the above embodiment is that in step 205, determining the proportion of first-quality anchor frames in multiple anchor frames based on the quality evaluation threshold may include:
[0136] 601: Determine the intersection-over-union ratios (IoUs) corresponding to the multiple anchor boxes according to the label boxes corresponding to the sample image.
[0137] Regarding the calculation steps of the intersection-over-union ratio of the anchor boxes, reference can be made to the description of the aforementioned embodiment and will not be repeated here.
[0138] 602: Determine, according to the intersection-over-union ratios (IRUs) corresponding to the multiple anchor frames, a first quality anchor frame whose IRUs are greater than a quality evaluation threshold among the multiple anchor frames.
[0139] The first quality anchor box is selected from multiple anchor boxes according to the quality evaluation threshold.
[0140] 603: Determine a first-quality anchor frame ratio based on the number of first-quality anchor frames and the number of multiple anchor frames. The quality evaluation threshold is greater than the anchor frame classification threshold.
[0141] For example, the object detection model can perform multiple rounds of training iterations. During each round of training iteration, the object detection model can determine the first-quality anchor frame from all anchor frames of all training images in the current training round through steps 601-603 to determine the proportion of first-quality anchor frames among all anchor frames in the current iteration. By dynamically determining the proportion of first-quality anchor frames throughout the training process, the anchor frame classification threshold can be dynamically adjusted throughout the training process.
[0142] In the disclosed embodiment, the quality of each anchor frame can be evaluated by determining its intersection-over-union (IoU) ratio, resulting in a first-quality anchor frame with an IoU ratio greater than a quality evaluation threshold. During the training of the target detection model, the proportion of first-quality anchor frames determines whether to update the anchor frame classification threshold. This allows for dynamic adjustment of the anchor frame classification threshold, enabling the target detection model to learn accurate positive samples and reduce the false positive rate of the target detection model.
[0143] For example, determining the intersection-over-union ratios corresponding to multiple anchor frames according to the annotation frames corresponding to the sample image may include:
[0144] According to at least one annotation box corresponding to the sample image, calculating the intersection-over-union ratio corresponding to each anchor box and at least one annotation box;
[0145] According to the intersection-and-union ratios corresponding to each anchor frame and at least one annotation frame, the maximum intersection-and-union ratio corresponding to each anchor frame is determined to determine the intersection-and-union ratios corresponding to multiple anchor frames.
[0146] For any anchor box, the intersection-and-union (IoU) ratio corresponding to the anchor box and at least one annotation box can be determined, and the maximum IoU ratio can be determined from the IoU ratios corresponding to the anchor box and at least one annotation box, and the maximum IoU ratio can be used as the IoU ratio corresponding to the anchor box.
[0147] In an embodiment of the present disclosure, when at least one annotated frame is included, the intersection-and-union (IoU) of each anchor frame and the at least one annotated frame can be calculated, and the maximum IoU corresponding to each anchor frame can be used as the IoU corresponding to each anchor frame. The IoU can indicate the degree of similarity between the anchor frame and each annotated frame. The larger the IoU, the more similar the anchor frame and the annotated frame are. Therefore, the maximum IoU is used as the IoU corresponding to the anchor frame. The IoU corresponding to the anchor frame is correlated with its most similar annotated frame, so that the IoU corresponding to the anchor frame can more accurately represent its detection effect in the sample image. The IoU corresponding to the anchor frame is used to evaluate the quality of the anchor frame to determine the first-quality anchor frame from all anchor frames in the current round of training. The proportion of the first-quality anchor frame can be used to determine whether to update the target anchor frame, and the target anchor frame is used to determine the anchor frame classification threshold. The anchor frame classification threshold has a significant impact on the training accuracy of the target detection model. Therefore, accurately evaluating the anchor frame is conducive to obtaining a more accurate anchor frame classification threshold, which can effectively improve the model accuracy of the target detection model and reduce the false detection rate of the model.
[0148] FIG7 is a flowchart of a target detection method provided by an embodiment of the present disclosure. The method may include the following steps:
[0149] 701: In response to a target detection request, determine an image to be detected.
[0150] 702: Output a detection result of a target object in the image to be detected based on a target detection model, where the target detection model is obtained based on the target detection model construction method provided in any of the above embodiments.
[0151] In an embodiment of the present disclosure, when there is a target detection request, an image to be detected and multiple anchor frames of the image to be detected can be determined in response to the target detection request, so as to output the anchor frame where the target object in the image to be detected is located and the anchor frame category corresponding to the detection frame through the target detection model. The target detection model can be constructed and obtained through the above embodiment. During the construction process, the target anchor frame is dynamically adjusted, and the classification effect of the anchor frame classification threshold can be improved by adjusting the target anchor frame, so that the target detection model can detect the anchor frame more accurately, improve the detection accuracy of the target classification model, and reduce the false detection rate.
[0152] As shown in FIG8 , it is a flow chart of a target detection model construction apparatus provided by an embodiment of the present disclosure. The target detection model construction apparatus 800 may include:
[0153] Determining unit 801: used to determine multiple anchor frames of the sample image based on the target detection model;
[0154] Selection unit 802: configured to select a target anchor frame that meets the anchor frame similarity condition from multiple anchor frames based on the annotation frame of the sample image;
[0155] Threshold unit 803: used to determine the anchor box classification threshold based on the annotation box and the target anchor box;
[0156] Iteration unit 804: configured to iteratively update the target detection model according to the anchor frame classification threshold and the multiple anchor frames corresponding to the multiple sample images;
[0157] Update unit 805: used to determine the proportion of first-quality anchor frames in multiple anchor frames according to the quality evaluation threshold if the iteration of the target detection model has not terminated, and update the target anchor frame if the proportion of first-quality anchor frames is greater than the preset proportion threshold; the quality evaluation threshold is determined based on the anchor frame classification threshold; the first-quality anchor frame is an anchor frame among multiple anchor frames whose intersection-over-union ratio with the label frame is greater than the quality evaluation threshold.
[0158] As an embodiment, the selecting unit 802 includes:
[0159] A quantity determination module is used to determine the number of anchor boxes corresponding to the target anchor box set for the annotation box;
[0160] The target selection module is used to select the target anchor frame that meets the anchor frame similarity condition from multiple anchor frames based on the number of annotation frames and anchor frames;
[0161] Update unit, including:
[0162] The model update module is used to update the number of anchor boxes and select the target anchor box that meets the anchor box similarity condition from multiple anchor boxes based on the updated number of anchor boxes and the annotation box.
[0163] In some embodiments, the model updating module includes:
[0164] A first determination submodule is configured to determine the number of first anchor frames according to the number of anchor frames and a preset adjustment amount;
[0165] and / or,
[0166] A first determination submodule, configured to determine the first number of anchor frames according to the number of anchor frames and a preset adjustment coefficient;
[0167] The quantity determination submodule is used to determine the updated number of anchor boxes based on the first number of anchor boxes.
[0168] In some embodiments, the quantity determination submodule is configured to:
[0169] If the first anchor frame number is greater than the preset upper limit of the anchor frame number, determining the preset upper limit of the anchor frame number to be the updated anchor frame number;
[0170] If the first number of anchor frames is less than or equal to the preset upper limit of the number of anchor frames, the first number of anchor frames is determined to be the updated number of anchor frames.
[0171] In some embodiments, the target selection module includes:
[0172] A calculation submodule, configured to calculate, for at least one annotation box, similarities between each annotation box and a plurality of anchor boxes;
[0173] A sorting submodule is used to sort the similarities between each annotation box and multiple anchor boxes in descending order to obtain the sorting results corresponding to each annotation box;
[0174] The selection submodule is used to determine the first k anchor boxes corresponding to each annotation box as the target anchor box corresponding to the annotation box based on the number of anchor boxes k and the ranking results corresponding to each annotation box.
[0175] In some embodiments, the threshold unit includes:
[0176] A first calculation module is used to determine the intersection-over-union ratio of the annotation box and each target anchor box according to the target anchor box corresponding to the annotation box;
[0177] The threshold determination module is used to determine the anchor box classification threshold based on the intersection-over-union ratio of the annotation box and each target anchor box.
[0178] In some embodiments, the iteration unit includes:
[0179] Anchor frame classification module, which is used to classify multiple anchor frames according to the anchor frame classification threshold and the annotation frame corresponding to the sample image, and obtain classification results corresponding to the multiple anchor frames, which include positive samples or negative samples;
[0180] The positive detection module is used to perform target detection based on the positive anchor box whose classification result is a positive sample according to the target detection model, and obtain the detection result corresponding to the positive anchor box;
[0181] The model update module is used to iteratively update the target detection model based on the detection results and annotation boxes corresponding to the positive anchor boxes.
[0182] In some embodiments, the anchor box classification module includes:
[0183] The intersection-and-union calculation submodule is used to determine the intersection-and-union ratios corresponding to the multiple anchor boxes and the annotation boxes according to the annotation boxes corresponding to the sample image;
[0184] The first division submodule is used to determine that the classification result of the anchor frame is a negative sample if the intersection-over-union ratio corresponding to the anchor frame is less than the anchor frame classification threshold;
[0185] The second division submodule is used to determine, for each labeled box, if the intersection-over-union ratio of the anchor box to the labeled box is greater than the anchor box classification threshold, then determine the anchor box as a positive sample corresponding to the labeled box.
[0186] In some embodiments, the iteration unit includes:
[0187] The second calculation module is used to determine the intersection-over-union ratios corresponding to the multiple anchor frames according to the annotation frames corresponding to the sample image;
[0188] A quality evaluation module is configured to determine, based on the intersection-and-union ratios corresponding to the multiple anchor frames, a first quality anchor frame whose intersection-and-union ratios among the multiple anchor frames are greater than a quality evaluation threshold;
[0189] a proportion calculation module, configured to determine a proportion of first-quality anchor frames based on the number of first-quality anchor frames and the number of multiple anchor frames;
[0190] The quality evaluation threshold is greater than the anchor box classification threshold.
[0191] In some embodiments, the second computing module is configured to:
[0192] According to at least one annotation box corresponding to the sample image, the intersection-and-union ratio (IoU) of each anchor box and the at least one annotation box is calculated; according to the IoU ratio of each anchor box and the at least one annotation box, the maximum IoU ratio corresponding to each anchor box is determined to determine the IoU ratios corresponding to multiple anchor boxes.
[0193] As shown in FIG9 , it is a flow chart of a target detection model construction apparatus provided by an embodiment of the present disclosure. The target detection model construction apparatus 800 may include:
[0194] Acquisition unit 901: configured to determine an image to be detected in response to a target detection request;
[0195] Detection unit 902: Outputs a detection result of a target object in the image to be detected based on a target detection model. The target detection model is trained based on the target detection model construction method provided in any of the above embodiments.
[0196] The device provided in this embodiment can be used to execute the technical solution of the above method embodiment. Its implementation principle and technical effects are similar and will not be described in detail in this embodiment.
[0197] To implement the above embodiment, the present disclosure further provides an electronic device, including a processor and a memory, wherein the memory stores computer-executable instructions.
[0198] The processor executes the computer-executable instructions stored in the memory, so that the processor executes the target detection model construction and target detection method as described in any of the above embodiments.
[0199] The device provided in this embodiment can be used to execute the technical solution of the above method embodiment. Its implementation principle and technical effects are similar and will not be described in detail in this embodiment.
[0200] Referring to FIG10 , a schematic diagram of the structure of an electronic device 1000 suitable for implementing an embodiment of the present disclosure is shown. The electronic device 1000 may be a terminal device or a server. The terminal device may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, personal digital assistants (PDAs), tablet computers (Portable Android Devices, PADs), portable multimedia players (PMPs), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), and fixed terminals such as digital TVs and desktop computers. The electronic device shown in FIG10 is merely an example and should not limit the functions and scope of use of the embodiments of the present disclosure.
[0201] As shown in Figure 10, the electronic device 1000 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 1001, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage device 1008 into a random access memory (RAM) 1003. Various programs and data required for the operation of the electronic device 1000 are also stored in the RAM 1003. The processing device 1001, the ROM 1002, and the RAM 1003 are connected to each other via a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.
[0202] Typically, the following devices may be connected to the I / O interface 1005: an input device 1006 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 1007 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 1008 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 may allow the electronic device 1000 to communicate with other devices wirelessly or by wire to exchange data. Although FIG10 shows an electronic device 1000 having various devices, it should be understood that it is not required to implement or have all of the devices shown. More or fewer devices may be implemented or have alternatively.
[0203] For example, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network via the communication device 1009, or installed from the storage device 1008, or installed from the ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment of the present disclosure are performed.
[0204] It should be noted that the computer-readable medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, or any combination of the above. Examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, device, or component. In the present disclosure, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to wires, optical cables, RF (radio frequency), etc., or any suitable combination thereof.
[0205] The embodiments of the present disclosure also provide a computer-readable storage medium, in which computer-executable instructions are stored. When a processor executes the computer-executable instructions, target detection model construction and target detection method as in any of the above embodiments are implemented.
[0206] The embodiments of the present disclosure also provide a computer program product, including a computer program, which, when executed by a processor, implements the target detection model construction and target detection method as described in any of the above embodiments.
[0207] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0208] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device executes the method shown in the above embodiment.
[0209] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages, or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet Service Provider).
[0210] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the module, program segment, or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of the boxes in the block diagram and / or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0211] The units described in the embodiments of the present disclosure may be implemented in software or hardware. The name of a unit does not necessarily limit the unit itself. For example, the first acquisition unit may also be described as a "unit for acquiring at least two Internet Protocol addresses."
[0212] The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, and without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chip (SOCs), complex programmable logic devices (CPLDs), and the like.
[0213] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in combination with an instruction execution system, device or equipment. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or equipment, or any suitable combination of the foregoing. Examples of machine-readable storage media can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0214] In a first aspect, according to one or more embodiments of the present disclosure, a method for constructing an object detection model is provided, comprising:
[0215] Based on the target detection model, multiple anchor boxes of the sample image are determined;
[0216] Based on the annotation box of the sample image, a target anchor box that meets the anchor box similarity condition is selected from multiple anchor boxes;
[0217] Determine the anchor box classification threshold based on the annotation box and the target anchor box;
[0218] Iteratively update the target detection model based on the anchor box classification threshold and multiple anchor boxes corresponding to the sample image;
[0219] If the iteration of the target detection model is not terminated, the proportion of first-quality anchor frames in multiple anchor frames is determined according to the quality evaluation threshold. If the proportion of first-quality anchor frames is greater than the preset proportion threshold, the target anchor frame is updated; the quality evaluation threshold is determined based on the anchor frame classification threshold; the first-quality anchor frame is the anchor frame among multiple anchor frames whose intersection-over-union ratio with the label frame is greater than the quality evaluation threshold.
[0220] According to one or more embodiments of the present disclosure, based on the annotation box, selecting a target anchor box that meets the anchor box similarity condition from multiple anchor boxes includes:
[0221] Determine the number of anchor boxes corresponding to the target anchor boxes set for the annotation box;
[0222] According to the number of annotation boxes and anchor boxes, select the target anchor box that meets the anchor box similarity conditions from multiple anchor boxes;
[0223] Update the target anchor box, including:
[0224] Update the number of anchor boxes, and select the target anchor box that meets the anchor box similarity condition from multiple anchor boxes based on the updated number of anchor boxes and the annotation box.
[0225] According to one or more embodiments of the present disclosure, updating the number of anchor boxes includes:
[0226] Determine the number of first anchor frames according to the number of anchor frames and the preset adjustment amount;
[0227] and / or,
[0228] Determine the first number of anchor frames based on the number of anchor frames and the preset adjustment coefficient;
[0229] The updated number of anchor boxes is determined based on the first number of anchor boxes.
[0230] According to one or more embodiments of the present disclosure, determining an updated number of anchor boxes based on the first number of anchor boxes includes:
[0231] If the first anchor frame number is greater than the preset upper limit of the anchor frame number, determining the preset upper limit of the anchor frame number to be the updated anchor frame number;
[0232] If the first number of anchor frames is less than or equal to the preset upper limit of the number of anchor frames, the first number of anchor frames is determined to be the updated number of anchor frames.
[0233] According to one or more embodiments of the present disclosure, selecting a target anchor frame that meets an anchor frame similarity condition from multiple anchor frames based on the number of annotation frames and anchor frames includes:
[0234] For at least one annotation box, calculate the similarity between each annotation box and multiple anchor boxes respectively;
[0235] Sort the similarities between each annotation box and multiple anchor boxes in descending order to obtain the sorting results corresponding to each annotation box;
[0236] Based on the number k of anchor boxes and the ranking results corresponding to each annotation box, the first k anchor boxes corresponding to each annotation box are determined as the target anchor boxes corresponding to the annotation box.
[0237] According to one or more embodiments of the present disclosure, determining an anchor box classification threshold based on a label box and a target anchor box includes:
[0238] According to the target anchor box corresponding to the annotation box, determine the intersection-over-union ratio of the annotation box and each target anchor box;
[0239] The anchor box classification threshold is determined based on the intersection-over-union ratio between the annotation box and each target anchor box.
[0240] According to one or more embodiments of the present disclosure, an object detection model is iteratively updated based on an anchor box classification threshold and multiple anchor boxes corresponding to a sample image, including:
[0241] According to the anchor frame classification threshold and the annotation frame corresponding to the sample image, multiple anchor frames are classified respectively to obtain the classification results corresponding to the multiple anchor frames, which include positive samples or negative samples;
[0242] According to the target detection model, target detection is performed based on the positive class anchor box whose classification result is a positive sample, and the detection result corresponding to the positive class anchor box is obtained;
[0243] The target detection model is iteratively updated based on the detection results and annotation boxes corresponding to the positive anchor boxes.
[0244] According to one or more embodiments of the present disclosure, the anchor box classification step includes:
[0245] According to the annotation box corresponding to the sample image, determine the intersection-over-union ratios corresponding to multiple anchor boxes and the annotation box respectively;
[0246] If the intersection-over-union ratio corresponding to the anchor frame is less than the anchor frame classification threshold, the classification result of the anchor frame is determined to be a negative sample;
[0247] For each annotation box, if the intersection-over-union ratio of the anchor box to the annotation box is greater than the anchor box classification threshold, the anchor box is determined to be the positive sample corresponding to the annotation box.
[0248] According to one or more embodiments of the present disclosure, determining the proportion of first-quality anchor frames in a plurality of anchor frames according to a quality evaluation threshold includes:
[0249] According to the annotation box corresponding to the sample image, determine the intersection-over-union ratio corresponding to multiple anchor boxes;
[0250] Determine, according to the intersection-and-union ratios corresponding to the multiple anchor frames, a first quality anchor frame whose intersection-and-union ratios are greater than a quality evaluation threshold among the multiple anchor frames;
[0251] Determine the proportion of first-quality anchor frames based on the number of first-quality anchor frames and the number of multiple anchor frames;
[0252] The quality evaluation threshold is greater than the anchor box classification threshold.
[0253] According to one or more embodiments of the present disclosure, determining the intersection-over-union ratios corresponding to a plurality of anchor frames, respectively, based on the annotation frames corresponding to the sample image, includes:
[0254] According to at least one annotation box corresponding to the sample image, calculating the intersection-over-union ratio corresponding to each anchor box and at least one annotation box;
[0255] According to the intersection-and-union ratios corresponding to each anchor frame and at least one annotation frame, the maximum intersection-and-union ratio corresponding to each anchor frame is determined to determine the intersection-and-union ratios corresponding to multiple anchor frames.
[0256] In a second aspect, according to one or more embodiments of the present disclosure, a target detection method is provided, including:
[0257] Acquisition unit: used to determine the image to be detected in response to the target detection request;
[0258] Detection unit: Outputs the detection result of the target object in the image to be detected based on the target detection model. The target detection model is trained based on the target detection model construction method provided in any of the above embodiments.
[0259] In a third aspect, according to one or more embodiments of the present disclosure, a device for constructing a target detection model is provided, comprising:
[0260] The determination unit is used to determine multiple anchor boxes of the sample image based on the target detection model.
[0261] A selection unit is used to select a target anchor frame that meets the anchor frame similarity condition from multiple anchor frames based on the annotation frame of the sample image;
[0262] A threshold unit is used to determine the anchor box classification threshold based on the annotation box and the target anchor box;
[0263] An iterative unit, configured to iteratively update the target detection model based on the anchor box classification threshold and multiple anchor boxes corresponding to the sample image;
[0264] An updating unit is configured to determine the proportion of first-quality anchor frames among multiple anchor frames based on a quality evaluation threshold if the iteration of the target detection model has not terminated, and to update the target anchor frame if the proportion of first-quality anchor frames is greater than a preset proportion threshold; the quality evaluation threshold is determined based on the anchor frame classification threshold; the first-quality anchor frame is an anchor frame among multiple anchor frames whose intersection-over-union ratio with the label frame is greater than the quality evaluation threshold.
[0265] In a fourth aspect, according to one or more embodiments of the present disclosure, there is provided an object detection apparatus, comprising:
[0266] Acquisition unit: used to determine the image to be detected in response to the target detection request;
[0267] Detection unit: Outputs the detection result of the target object in the image to be detected based on the target detection model. The target detection model is trained based on the target detection model construction method provided in any of the above embodiments.
[0268] In a fifth aspect, according to one or more embodiments of the present disclosure, there is provided an electronic device, comprising: at least one processor and a memory;
[0269] Memory stores computer-executable instructions;
[0270] At least one processor executes computer-executable instructions stored in the memory, so that at least one processor performs the target detection model construction and target detection method as described in the first aspect and various possible designs of the first aspect.
[0271] In the sixth aspect, according to one or more embodiments of the present disclosure, a computer-readable storage medium is provided, in which computer-executable instructions are stored. When the processor executes the computer-executable instructions, the target detection model construction and target detection method provided in any of the above embodiments are implemented.
[0272] In the seventh aspect, according to one or more embodiments of the present disclosure, a computer program product is provided, including a computer program, which, when executed by a processor, implements the target detection model construction and target detection method provided in any of the above embodiments.
[0273] The above description is merely a preferred embodiment of the present disclosure and an illustration of the technical principles employed. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by the specific combination of the above-mentioned technical features, but also includes other technical solutions formed by any combination of the above-mentioned technical features or their equivalents without departing from the above-mentioned disclosed concepts. For example, a technical solution formed by replacing the above-mentioned features with (but not limited to) technical features with similar functions disclosed in this disclosure.
[0274] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some implementation details have been included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0275] Although the subject matter has been described in language specific to structural features and / or methodological logical acts, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are merely example forms of implementing the claims.
Claims
1. A method for building a target detection model, include: Based on the target detection model, multiple anchor boxes of the sample image are determined; Based on at least one annotation frame of the sample image, selecting a target anchor frame that satisfies an anchor frame similarity condition from the multiple anchor frames; Determining an anchor box classification threshold based on the at least one annotation box and the target anchor box; Iteratively updating the object detection model according to the anchor frame classification threshold and a plurality of anchor frames corresponding to the sample image; In response to the target detection model iteration not being terminated, determining the proportion of first quality anchor frames among the multiple anchor frames according to a quality evaluation threshold, and in response to the proportion of the first quality anchor frames being greater than a preset ratio threshold, updating the target anchor frame, wherein the quality evaluation threshold is determined based on the anchor frame classification threshold, and the first quality anchor frame is an anchor frame whose intersection-over-combination ratio with the at least one annotation frame among the multiple anchor frames is greater than the quality evaluation threshold.
2. The target detection model construction method according to claim 1, in, The selecting, based on the at least one annotation frame, a target anchor frame satisfying an anchor frame similarity condition from the multiple anchor frames comprises: Determine the number of anchor boxes corresponding to the target anchor box set for the at least one annotation box; According to the at least one annotation box and the number of anchor boxes, selecting a target anchor box that satisfies the anchor box similarity condition from the multiple anchor boxes; The updating of the target anchor frame comprises: The number of anchor boxes is updated, and a target anchor box satisfying the anchor box similarity condition is selected from the multiple anchor boxes according to the updated number of anchor boxes and the at least one annotation box.
3. The target detection model construction method according to claim 2, in, The updating of the number of anchor frames comprises: Determining the number of first anchor boxes according to the number of anchor boxes and a preset adjustment amount, and / or determining the number of first anchor boxes according to the number of anchor boxes and a preset adjustment coefficient; An updated number of anchor boxes is determined based on the first number of anchor boxes.
4. The target detection model construction method according to claim 3, in, The determining the updated number of anchor boxes based on the first number of anchor boxes comprises: In response to the first number of anchor boxes being greater than a preset upper limit of the number of anchor boxes, determining the preset upper limit of the number of anchor boxes to be the updated number of anchor boxes; In response to the first anchor box number being less than or equal to the preset upper limit of the anchor box number, determining the first anchor box number as the updated anchor box number.
5. The method for constructing a target detection model according to any one of claims 2 to 4, in, The selecting, according to the at least one annotation frame and the number of anchor frames, a target anchor frame satisfying an anchor frame similarity condition from the multiple anchor frames comprises: For the at least one annotation box, calculating the similarity between each annotation box in the at least one annotation box and the plurality of anchor boxes; Sorting the similarities between each of the annotation boxes and the multiple anchor boxes in descending order to obtain a sorting result corresponding to each of the annotation boxes; Based on the number k of anchor boxes and the ranking results corresponding to the annotation boxes, first k anchor boxes corresponding to the annotation boxes are determined as target anchor boxes corresponding to the annotation boxes.
6. The method for constructing a target detection model according to any one of claims 1 to 5, in, The determining, based on the at least one annotation frame and the target anchor frame, a classification threshold of the anchor frame comprises: Determining an intersection-over-union ratio between the at least one annotation box and each target anchor box according to the target anchor box corresponding to the at least one annotation box; The anchor box classification threshold is determined according to an intersection-over-union ratio between the at least one annotation box and each target anchor box.
7. The method for constructing a target detection model according to any one of claims 1 to 6, in, The iterative updating of the target detection model according to the anchor frame classification threshold and the multiple anchor frames corresponding to the sample image comprises: According to the anchor frame classification threshold and the annotation frame corresponding to the sample image, classify each of the multiple anchor frames to obtain a classification result corresponding to each of the multiple anchor frames, wherein the classification result includes a positive sample or a negative sample; According to the target detection model, target detection is performed based on the positive class anchor frame whose classification result is a positive sample, to obtain a detection result corresponding to the positive class anchor frame; The object detection model is iteratively updated according to the detection result and the annotation box corresponding to the positive class anchor box.
8. The target detection model construction method according to claim 7, in, The anchor frame classification step includes: Determine, according to the annotation box corresponding to the sample image, an intersection-over-union ratio corresponding to each of the plurality of anchor boxes and the annotation box; In response to the intersection-over-union ratio corresponding to the anchor frame being less than the anchor frame classification threshold, determining that the classification result of the anchor frame is negative sample; For the marked box, in response to an intersection-over-union ratio of the anchor box to the marked box being greater than the anchor box classification threshold, determining that the anchor box is a positive sample corresponding to the marked box.
9. The method for constructing a target detection model according to any one of claims 1 to 8, in, The determining, according to the quality evaluation threshold, a proportion of first quality anchor frames in the plurality of anchor frames comprises: Determine, according to the at least one annotation frame corresponding to the sample image, an intersection-over-union ratio corresponding to each of the plurality of anchor frames; Determine, according to each corresponding intersection-and-union ratio of the multiple anchor frames, a first quality anchor frame of an anchor frame whose intersection-and-union ratio among the multiple anchor frames is greater than the quality evaluation threshold; According to the number of the first quality anchor boxes and the number of the multiple anchor boxes, a proportion of the first quality anchor boxes is determined, and the quality evaluation threshold is greater than the anchor box classification threshold.
10. The target detection model construction method according to claim 9, in, The determining, according to the at least one annotation frame corresponding to the sample image, an intersection-over-union ratio corresponding to each of the plurality of anchor frames comprises: According to the at least one annotation box corresponding to the sample image, calculating the intersection-over-union ratio corresponding to each anchor box and the at least one annotation box respectively; According to the intersection-and-union ratios corresponding to each anchor frame and the at least one annotation frame, a maximum intersection-and-union ratio corresponding to each anchor frame is determined to determine the intersection-and-union ratio corresponding to each of the multiple anchor frames.
11. A target detection method, include: In response to a target detection request, determining an image to be detected; Based on the target detection model, the detection result of the target object in the image to be detected is output, and the target detection model is obtained based on the target detection model construction method provided in any one of claims 1 to 10 above.
12. A target detection model building device, include: A determination unit, used to determine multiple anchor frames of the sample image based on the target detection model; A selection unit, configured to select a target anchor frame satisfying an anchor frame similarity condition from the multiple anchor frames based on at least one annotation frame of the sample image; A threshold unit, configured to determine an anchor frame classification threshold based on the at least one annotation frame and the target anchor frame; an iterative unit, configured to iteratively update the object detection model according to the anchor frame classification threshold and a plurality of anchor frames corresponding to the sample image; an updating unit, configured to determine, in response to the target detection model iteration not being terminated, a proportion of first quality anchor frames in the plurality of anchor frames according to a quality evaluation threshold, and in response to the proportion of the first quality anchor frames being greater than a preset proportion A quality evaluation threshold is used to update the target anchor box, wherein the quality evaluation threshold is determined based on the anchor box classification threshold, and the first quality anchor box is an anchor box whose intersection-and-joint ratio with the at least one annotation box is greater than the quality evaluation threshold.
13. A target detection device, include: A response unit, configured to determine an image to be detected in response to a target detection request; An input unit is used to output a detection result of a target object in the image to be detected based on a target detection model, wherein the target detection model is obtained by training based on the target detection model construction method provided in any one of claims 1 to 10.
14. An electronic device, include: Processor, memory; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory, so that the processor is configured with the target detection model building method as claimed in any one of claims 1 to 10 or the target detection method as claimed in claim 11.
15. A computer-readable storage medium, in, The computer-readable storage medium stores computer-executable instructions. When the processor executes the computer-executable instructions, the target detection model construction method according to any one of claims 1 to 10 or the target detection method according to claim 11 is implemented.
16. A computer program product comprising a computer program, It is characterized in that The computer program is executed by a processor to be configured with the target detection model building method according to any one of claims 1 to 10 or the target detection method according to claim 11.
17. A computer program comprising instructions, which, when executed by a processor, cause the processor to perform the target detection model construction method according to any one of claims 1 to 10 or the target detection method according to claim 11.
Citation Information
Patent Citations
Small face detection method based on semantic feature pyramid network
CN111950515A
A lightweight object detection method based on multiple receptive fields and attention feature pyramids
CN114937151A
Object detection and classification in images
US20170206431A1
Cited By
3D point cloud lane line data marking auxiliary method and device based on DPC
CN121459267A
