A method and device for optimizing network security image target detection model algorithm
By correcting orthogonally and comparing and adopting new loss functions, the problem of low detection accuracy of irregular bounding box in the prior art is solved, the robustness and scalability of the image object detection model is improved, and a higher network security image is achieved Object detection accuracy.
Patent Information
- Application Number
- CN202410500397.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-24
- Publication Date
- 2024-12-03
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing intercombination ratio scheme is poor in detecting irregular bounding boxes, resulting in a decrease in the accuracy of the network security image object detection model, and an even better algorithm optimization solution is urgently needed.
By obtaining the distance error between the predicted bounding box and the target bounding box, correcting orthogonal ratio, using a new loss function to train the image object detection model, providing a new crossover comparison calculation method, reducing the calculation difficulty and improving the calculation Accuracy.
It improves the scalability and robustness of the image object detection model, enhances the detection accuracy of irregular shape bounding boxes, and improves the accuracy of network security image object detection.
Smart Images

Figure CN118298002B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of electronic digital processing technology, and in particular to a method and device for optimizing an algorithm of a network security image target detection model. Background Art
[0002] In recent years, with the rapid development of Internet technology, network security issues have become increasingly prominent. Among them, various non-compliant images such as exposing personal privacy have seriously affected network security. In the detection of non-compliant images, object detection methods based on deep learning have become one of the main solutions.
[0003] As an important intermediate result of the algorithm, Intersection over Union (IoU) plays a decisive role in the accuracy of the model. However, the existing IoU solutions have problems such as being not robust enough, especially in certain specific cases (such as irregular bounding boxes, etc.), the existing IoU solutions have poor effects. Therefore, there is an urgent need to provide a better algorithm optimization solution for network security image object detection models. Summary of the invention
[0004] The embodiments of this specification provide a method and device, an electronic device, and a storage medium for optimizing a network security image target detection model algorithm, so as to provide a better solution for optimizing a network security image target detection model algorithm.
[0005] In a first aspect, one or more embodiments of this specification provide a method for optimizing a network security image target detection model algorithm, including:
[0006] Obtain a predicted bounding box predicted by an image target detection model, wherein the predicted bounding box is used to represent the predicted position of the detection target in the sample image, the predicted bounding box has the same number of vertices as the target bounding box of the sample image, and the target bounding box is used to represent the actual position of the detection target in the sample image;
[0007] determining a distance error between the target bounding box and the predicted bounding box according to a distance between a first target vertex of the target bounding box and a second target vertex of the predicted bounding box, wherein the first target vertex matches the second target vertex;
[0008] Correcting the first intersection-and-union ratio based on the distance error to obtain a second intersection-and-union ratio, wherein the first intersection-and-union ratio is an area ratio between an intersection area and a union area of a first region and a second region, wherein the first region and the second region are regions occupied by the target bounding box and the predicted bounding box in the sample image, respectively;
[0009] The image object detection model is trained according to the loss function corresponding to the second intersection-over-union ratio to obtain parameters of the trained image object detection model.
[0010] Optionally, before determining the distance error, the method includes:
[0011] Taking any vertex of the target bounding box as a starting vertex, sorting the vertices of the target bounding box using a preset sorting method to obtain a target sorting result corresponding to the target bounding box;
[0012] In this way, each vertex of the predicted bounding box is used as a starting vertex, and the vertices of the predicted bounding box are sorted using the sorting method to obtain a plurality of candidate sorting results corresponding to the predicted bounding box, wherein the number of the candidate sorting results is the same as the number of vertices of the predicted bounding box;
[0013] Determining a predicted sorting result that matches the target sorting result from the candidate sorting results based on the distances between vertices having the same order in the candidate sorting results and the target sorting result;
[0014] The vertices in the predicted sorting result that have the same order as the first target vertex in the target sorting result are used as the second target vertices that match the first target vertex.
[0015] Optionally, determining a predicted sorting result matching the target sorting result from the candidate sorting results based on the distances between vertices having the same order in the candidate sorting results and the target sorting result includes:
[0016] Determine the absolute values of distances between vertices having the same order from the candidate sorting results and the target sorting results;
[0017] The absolute values are summed up respectively according to the candidate sorting results to which they belong, to obtain the distance errors corresponding to the candidate sorting results;
[0018] Based on the distance error, the predicted sorting result is determined from the candidate sorting results.
[0019] Optionally, the preset sorting method is a clockwise vertex-by-vertex sorting method or a counterclockwise vertex-by-vertex sorting method.
[0020] Optionally, the first intersection-and-union ratio is corrected based on the distance error to obtain a second intersection-and-union ratio, including:
[0021] Obtaining a constraint value based on the length and width of the sample image;
[0022] Normalizing the distance error using the constraint value to obtain a correction value corresponding to the first intersection-over-combination ratio;
[0023] The first intersection-and-union ratio is corrected using the correction value to obtain the second intersection-and-union ratio.
[0024] Optionally, the process of determining the first intersection-over-union ratio includes:
[0025] Using a preset unit structure, filling the overlapping area and the non-overlapping area of the target bounding box and the predicted bounding box respectively;
[0026] Determine the sum of the numbers of the unit structures in the overlapping area and the non-overlapping area as a first number, where the first number is used to represent the area of a union of the areas included in the target bounding box and the predicted bounding box;
[0027] Determine the number of the unit structures in the overlapping area as a second number, where the second number is used to represent the area of the intersection of the area included in the target bounding box and the area included in the prediction bounding box;
[0028] The first intersection-over-union ratio is determined according to the first number and the second number.
[0029] Optionally, the detection target includes a detection target related to network security, and the method further includes:
[0030] The trained image target detection model is used to detect network security-related content in the image to be detected to obtain the detection result.
[0031] In a second aspect, an embodiment of the present application provides a device for optimizing a network security image target detection model algorithm, including:
[0032] An acquisition module is used to acquire a predicted bounding box predicted by an image target detection model, wherein the predicted bounding box is used to represent the predicted position of the detection target in the sample image, the number of vertices of the predicted bounding box and the target bounding box of the sample image is the same, and the target bounding box is used to represent the actual position of the detection target in the sample image;
[0033] an error module, configured to determine a distance error between the target bounding box and the predicted bounding box according to a distance between a first target vertex of the target bounding box and a second target vertex of the predicted bounding box, wherein the first target vertex matches the second target vertex;
[0034] an IoU module, configured to correct a first IoU based on the distance error to obtain a second IoU, wherein the first IoU is an area ratio between an intersection area and a union area of a first area and a second area, wherein the first area and the second area are areas occupied by the target bounding box and the predicted bounding box in the sample image, respectively;
[0035] A training module is used to train the image target detection model according to the loss function corresponding to the second intersection-over-union ratio to obtain parameters of the trained image target detection model.
[0036] Optionally, a device for optimizing a network security image object detection model algorithm includes:
[0037] A first sorting module is used to use any vertex of the target bounding box as a starting vertex and use a preset sorting method to sort the vertices of the target bounding box to obtain a target sorting result corresponding to the target bounding box;
[0038] A second sorting module is used to sequentially use each vertex of the predicted bounding box as a starting vertex and use the sorting method to sort the vertices of the predicted bounding box to obtain a plurality of candidate sorting results corresponding to the predicted bounding box, wherein the number of the candidate sorting results is the same as the number of vertices of the predicted bounding box;
[0039] A prediction module, configured to determine a predicted sorting result matching the target sorting result from the candidate sorting results based on the distances between vertices having the same order in the candidate sorting results and the target sorting result;
[0040] The vertex determination module is used to use the vertex in the predicted sorting result that has the same order as the first target vertex in the target sorting result as the second target vertex matched with the first target vertex.
[0041] Optional, prediction module, including:
[0042] an absolute value unit, used to determine the absolute values of distances between vertices having the same order from the candidate sorting result and the target sorting result;
[0043] A summing unit, used to sum the absolute values according to the candidate sorting results to which they belong, to obtain the distance errors corresponding to the candidate sorting results;
[0044] A prediction unit is used to determine the predicted sorting result from the candidate sorting results based on the distance error.
[0045] Optionally, the preset sorting method is a clockwise vertex-by-vertex sorting method or a counterclockwise vertex-by-vertex sorting method.
[0046] Optional, intersection-over-union module, including:
[0047] A constraint unit, used for obtaining a constraint value based on the length and width of the sample image;
[0048] a correction value unit, configured to normalize the distance error using the constraint value to obtain a correction value corresponding to the first intersection-over-union ratio;
[0049] A correction unit is used to correct the first intersection-and-union ratio by using the correction value to obtain the second intersection-and-union ratio.
[0050] Optionally, the process of determining the first intersection-over-union ratio includes:
[0051] Using a preset unit structure, filling the overlapping area and the non-overlapping area of the target bounding box and the predicted bounding box respectively;
[0052] Determine the sum of the numbers of the unit structures in the overlapping area and the non-overlapping area as a first number, where the first number is used to represent the area of a union of the areas included in the target bounding box and the predicted bounding box;
[0053] Determine the number of the unit structures in the overlapping area as a second number, where the second number is used to represent the area of the intersection of the area included in the target bounding box and the area included in the prediction bounding box;
[0054] The first intersection-over-union ratio is determined according to the first number and the second number.
[0055] Optionally, the detection target includes a detection target related to network security, and the device for optimizing the network security image target detection model algorithm further includes:
[0056] The detection module is used to use the trained image target detection model to detect the content related to network security in the image to be detected and obtain the detection result.
[0057] In a third aspect, an embodiment of the present application provides an electronic device, including:
[0058] A processor; and a memory arranged to store computer executable instructions, wherein the executable instructions are configured to be executed by the processor, and the executable instructions include steps for executing the method for optimizing the network security image target detection model algorithm provided in the first aspect above.
[0059] In a fourth aspect, an embodiment of the present application provides a storage medium, which is used to store computer-executable instructions, and the executable instructions enable a computer to execute the method for optimizing the network security image target detection model algorithm provided in the first aspect above.
[0060] In a fifth aspect, an embodiment of the present application provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, it implements the method for optimizing the network security image object detection model algorithm provided in the first aspect above.
[0061] In an embodiment of the present specification, the distance between the matched first target vertex and the second target vertex is used to determine the distance error, and then the first intersection-and-union ratio is corrected using the distance error. According to the corrected second intersection-and-union ratio, a loss function is determined and the image target detection model is trained according to the loss function. This process provides a new intersection-and-union ratio calculation method, in which the determination of the distance error only needs to consider the distance between the matched first target vertex and the second target vertex, without considering the shape of the target bounding box and the predicted bounding box, effectively reducing the difficulty of the intersection-and-union ratio calculation process and improving the accuracy of the second intersection-and-union ratio calculation process, thereby improving the scalability and robustness of the image target detection model trained using the loss function corresponding to the second intersection-and-union ratio. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] In order to more clearly illustrate one or more embodiments of this specification or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in one or more embodiments of this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0063] Figure 1 It is a schematic flowchart of a method for optimizing a network security image target detection model algorithm according to an embodiment of this specification.
[0064] Figure 2 It is a schematic diagram of the relationship between a target bounding box and a predicted bounding box according to an embodiment of the present specification.
[0065] Figure 3 It is a schematic diagram of a conventional intersection-over-union ratio calculation method according to an embodiment of this specification.
[0066] Figure 4 It is a schematic diagram of the relationship between a target bounding box and a predicted bounding box according to an embodiment of the present specification.
[0067] Figure 5It is a schematic diagram of an application scenario of a method for optimizing a network security image target detection model algorithm according to an embodiment of the present specification.
[0068] Figure 6 It is a schematic diagram of a sorting result obtained after sorting the vertices of a bounding box according to an embodiment of the present specification.
[0069] Figure 7 It is a structural schematic diagram of a device for optimizing a network security image target detection model algorithm according to an embodiment of this specification.
[0070] Figure 8 It is a structural schematic diagram of an electronic device according to an embodiment of this specification. DETAILED DESCRIPTION
[0071] The following will be combined with the drawings in the embodiments of this specification to clearly and completely describe the technical solutions in the embodiments of this specification. Obviously, the described embodiments are part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0072] The terms "first", "second", etc. in the specification and claims of this application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable when appropriate, so that the embodiments of this specification can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of the same type, and "first", "second", etc. do not limit the number of objects, for example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated before and after are in an "or" relationship.
[0073] The following, in conjunction with the accompanying drawings, describes in detail the method, device, and electronic device for optimizing the network security image target detection model algorithm provided by the embodiments of this specification through specific embodiments and their application scenarios.
[0074] Figure 1 A method for optimizing a network security image target detection model algorithm provided by an embodiment of the present invention is shown. The method can be executed by an electronic device, and the electronic device may include: a server and / or a terminal device, wherein the terminal device may be a vehicle-mounted terminal or a mobile phone terminal, etc. In other words, the method can be executed by software or hardware installed in the aforementioned electronic device, and the method includes the following steps:
[0075] S102: Obtain a predicted bounding box predicted by the image object detection model.
[0076] Among them, the sample image is an image in the image data set used to train the image target detection model. The sample image may contain one or more detection targets, and the detection target in the sample image may be content or elements that violate network ideological security. The target bounding box is used to characterize the actual position of the detection target in the sample image. The method for obtaining the target bounding box is not specifically limited in this specification, and it can be determined according to actual conditions. For example, the target bounding box in the sample image can be annotated manually or with related software. After obtaining the target bounding box in the sample image, the target bounding box information of each detection target in the sample image can be set in the label of the sample image.
[0077] Object detection, also known as object extraction, is an image segmentation method based on the geometric and statistical features of the object. Object detection not only needs to classify the detected object, but also needs to solve the problem of locating the detected object, that is, obtaining the position information of the detected object in the original image. Image object detection models usually use predicted bounding boxes to represent the predicted position of the detected object in the sample image. Figure 2 A schematic diagram showing the relationship between a target bounding box and a predicted bounding box is shown, Figure 2 As shown, the outer frame is the target bounding box representing the actual position of the detection target "bird" in the image, and the inner frame is the predicted bounding box of the position of the detection target "bird" in the image predicted by the image target detection model. Figure 2 The positioning of the inner frame in the image may be inaccurate. Even if the object in the inner frame is recognized as a "bird" by the classifier, the image does not achieve accurate detection of the "bird" because the position of the "bird" is not accurately detected.
[0078] If the predicted bounding box in the image is fine-tuned so that the fine-tuned predicted bounding box is closer to the target bounding box, the accuracy of locating the detected object in the image will be improved. In the target detection task, bounding box regression is usually used to predict (correct) the bounding box of the object to improve the final detection accuracy. A good loss function is crucial to the performance of bounding box regression. The accuracy of the bounding box regression process is usually improved by introducing the intersection-over-union loss function.
[0079] The intersection-to-union ratio is used to represent the ratio of the intersection area and the union area of the predicted bounding box to the true bounding box, which can be expressed as the following formula:
[0080] IoU=(p red ∩g t ) / (p red ∪g t ) (Formula 1)
[0081] Among them, p red is the area occupied by the predicted bounding box, g t is the area occupied by the target bounding box, p red ∩g t is the area of the intersection between the predicted bounding box and the target bounding box, p red ∪g t It is the area of the region where the predicted bounding box and the target bounding box are combined, and IoU is the intersection over union ratio.
[0082] Figure 3 FIG. 1 is a schematic diagram showing a conventional method for calculating the intersection-and-union ratio. Figure 3 As shown, B is p in formula 1 red ∩g t , A+B+C is p in formula 1 red ∪g t , then IoU=B / (A+B+C). Generally, the IoU calculation method has the disadvantage of not being robust enough, partly because the IoU calculation method can generally only be used for bounding boxes with relatively regular shapes such as triangles, rectangles, circles or ellipses, and cannot be extended to bounding boxes with irregular polygonal shapes. At the same time, the IoU calculation method also has certain requirements on the angle of the bounding box. For example, when the bounding box is a rectangle, the IoU calculation method can only be applied to non-rotated rectangles.
[0083] The shape of the prediction bounding box is not specifically limited in this specification and can be determined according to actual conditions, that is, the prediction bounding box can be a relatively regular border of a triangle, rectangle, circle or ellipse, or a border of an irregular polygonal shape. However, to ensure the consistency between the predicted prediction bounding box and the actual target bounding box, the prediction bounding box and the target bounding box in this specification have the same number of vertices and the same number of edges. At the same time, the angle of the prediction bounding box is not specifically limited in this specification and can be determined according to actual conditions, that is, the prediction bounding box can be a border rotated at any angle. The shape relationship between the prediction bounding box and the target bounding box is also not specifically limited in this specification, that is, the shape of the prediction bounding box and the target bounding box can be the same or different.
[0084] Figure 4 A schematic diagram showing the relationship between a target bounding box and a predicted bounding box is shown, Figure 4 As shown, the solid line box is the target bounding box, the dotted line box is the predicted bounding box, the target bounding box and the predicted bounding box can be both rectangles, but the rotation angles of the rectangles representing the target bounding box and the predicted bounding box are different.
[0085] S104: Determine a distance error between the target bounding box and the predicted bounding box according to a distance between a first target vertex of the target bounding box and a second target vertex of the predicted bounding box.
[0086] The first target vertex is any vertex of the target bounding box, and the second target vertex is a vertex of the predicted bounding box that matches the first target vertex. Specifically, the target bounding box and the predicted bounding box have the same number of vertices, and for the same detection target in the sample image, the matched first target vertex and the second target vertex are used to indicate the same position of the detection target.
[0087] The distance error is used to characterize the distance between the target bounding box and the predicted bounding box. Specifically, the distance between the vertices (i.e., the first target vertex and the second target vertex) that match the target bounding box and the predicted bounding box can be calculated based on the coordinates of each vertex of the target bounding box and the predicted bounding box. The process of determining the second target vertex that matches the first target vertex can refer to the subsequent embodiments and will not be repeated here. The method for calculating the distance between the matched vertices is not specifically limited in this specification and can be determined according to actual conditions. For example, the distance calculation method can be Euclidean distance, Manhattan distance, or Minkowski distance, etc. The distance between the matched first target vertex and the second target vertex can be calculated according to Formula 2:
[0088] f(P i , G j )= |x i -x j | k + |y i -y j | k (Formula 2)
[0089] Among them, (x i ,y i ) is the second target vertex P i The coordinates of (x j ,y j ) is the first target vertex G j coordinates, f(.) is used to solve the distance between the first target vertex and the second target vertex, and k is a custom power exponent.
[0090] Since there are multiple groups of matching first target vertices and second target vertices in the target bounding box and the predicted bounding box, and the number of groups is consistent with the number of vertices of the target bounding box and / or the predicted bounding box, after obtaining the distance between the matched first target vertex and the second target vertex, the distances between each group of matching first target vertex and the second target vertex can be added to obtain the distance error.
[0091] S106: Correct the first intersection-over-union ratio based on the distance error to obtain a second intersection-over-union ratio.
[0092] S108: Training the image object detection model according to the loss function corresponding to the second intersection-over-union ratio to obtain parameters of the trained image object detection model.
[0093] The first intersection-over-union ratio is the area ratio between the intersection area and the union area of the first area and the second area, and the first area and the second area are the areas occupied by the target bounding box and the predicted bounding box in the sample image, respectively. This specification does not specifically limit the calculation method of the first intersection-over-union ratio, and it can be determined according to actual conditions.
[0094] Since the distance between the matched first target vertex and the second target vertex can reflect the degree of overlap between the target bounding box and the predicted bounding box, and thus affect the value of the intersection-and-union ratio, in one example, the distance between the matched first target vertex and the second target vertex can be used to correct the first intersection-and-union ratio to obtain a second intersection-and-union ratio, and the second intersection-and-union ratio can be used to define the loss function of the image target detection model, and then the weight parameters of the image target detection model can be updated according to the loss function using a back propagation algorithm, etc.
[0095] The degree of influence of distance error on the detection accuracy of sample images is related to the size of sample images. Assume that there are two sample images, namely the first sample image and the second sample image, where the first sample image corresponds to the set of bounding boxes (first target bounding box, first predicted bounding box), and the second sample image corresponds to the set of bounding boxes (second target bounding box, second predicted bounding box). When the distance errors corresponding to the two sets of bounding boxes are the same (assuming they are both A), and the area of the first sample image is larger than that of the second sample image, it is obvious that A has a greater influence on the detection accuracy of the second sample image.
[0096] In one example, the method of using the distance error to correct the first intersection-and-union ratio to obtain the second intersection-and-union ratio can be to use the distance error and the size of the sample image at the same time to correct the first intersection-and-union ratio. The size of the sample image can be measured using the area of the sample image, or can be measured using the length and width of the sample image. The method of determining the second intersection-and-union ratio based on the first intersection-and-union ratio can be expressed as Formula 3:
[0097] IoU2= IoU1–αR (Formula 3)
[0098] Among them, IoU1 is the first intersection-over-union ratio, IoU2 is the second intersection-over-union ratio, and α is an adjustment coefficient related to the size of the sample image.
[0099] Furthermore, the loss function of the image target detection model can be calculated using Formula 4:
[0100] L = 1 - IoU2 (Formula 4)
[0101] Among them, IoU2 is the second intersection-over-union ratio, and L is the loss function of the image target detection model.
[0102] In an embodiment of the present specification, the distance between the matched first target vertex and the second target vertex is used to determine the distance error, and then the first intersection-and-union ratio is corrected using the distance error. According to the corrected second intersection-and-union ratio, a loss function is determined and the image target detection model is trained according to the loss function. This process provides a new intersection-and-union ratio calculation method, in which the determination of the distance error only needs to consider the distance between the matched first target vertex and the second target vertex, without considering the shape of the target bounding box and the predicted bounding box, effectively reducing the difficulty of the intersection-and-union ratio calculation process and improving the accuracy of the second intersection-and-union ratio calculation process, thereby improving the scalability and robustness of the image target detection model trained using the loss function corresponding to the second intersection-and-union ratio.
[0103] Figure 5 A schematic diagram of the application scenario of the method for optimizing the algorithm of network security image target detection model is provided, such as Figure 5 As shown, the image detection server 501 sends an instruction to the training server 502 to train the image target detection model. After receiving the training instruction, the training server 502 reads the image target detection model and the training image set in the first database 503, and uses the image target detection model algorithm optimization method in this specification to train the image target detection model. After the training is completed, the training result is returned to the image detection server 501, and the parameters of the trained image target detection model are stored in the second database 504. Then, the image detection server 501 can read the parameters of the trained image target detection model from the second database 504 to detect the image sent by the client 505, obtain the detection result, and return the detection result to the client 505.
[0104] In one implementation, before determining the distance error, a method for optimizing a network security image object detection model algorithm includes:
[0105] Taking any vertex of the target bounding box as the starting vertex, sorting the vertices of the target bounding box using a preset sorting method to obtain a target sorting result corresponding to the target bounding box;
[0106] In this way, each vertex of the predicted bounding box is used as a starting vertex, and the vertices of the predicted bounding box are sorted using a sorting method to obtain multiple candidate sorting results corresponding to the predicted bounding box;
[0107] Determine a predicted sorting result that matches the target sorting result from the candidate sorting results based on the distances between vertices having the same order in the candidate sorting results and the target sorting result;
[0108] The vertex in the predicted sorting result that has the same order as the first target vertex in the target sorting result is used as the second target vertex that matches the first target vertex.
[0109] Among them, the number of candidate sorting results is the same as the number of vertices of the predicted bounding box. Specifically, the process of determining the second target vertex that matches the first target vertex mentioned in step S104 can be: using a preset sorting method to sort the vertices of the target bounding box and the predicted bounding box, and obtaining a target sorting result corresponding to the target bounding box and multiple candidate sorting results corresponding to the predicted bounding box, each sorting result includes each vertex of the bounding box and the sorting order of each vertex; then the degree of matching between the target sorting result and the vertices of the same order in the candidate sorting results can be determined, and the predicted sorting result can be determined from the multiple candidate sorting results; finally, the vertex in the predicted sorting result with the same order as the first target vertex can be used as the second target vertex.
[0110] To avoid confusion and repeated calculations in the sorting process, the target bounding box and the predicted bounding box can use the same sorting method to sort their respective vertices. In one implementation, the preset sorting method can be a clockwise vertex-by-vertex sorting method or a counterclockwise vertex-by-vertex sorting method. Specifically, the sorting process corresponding to the vertices of the target bounding box can be to randomly determine a vertex from the vertices of the target bounding box as the starting vertex, and sort the vertices of the target bounding box vertex by vertex in a counterclockwise direction, starting from the randomly determined vertex. Correspondingly, the process of sorting the vertices of the predicted bounding box to obtain the candidate sorting result is similar to the above-mentioned sorting process of the target bounding box, which will not be repeated here.
[0111] Since there are multiple vertices in the predicted bounding box, the candidate sorting results may not necessarily match the vertices in the same order in the target sorting results. In one example, the predicted bounding box may be sorted multiple times to obtain the same number of candidate sorting results as the number of vertices in the predicted bounding box, and each candidate sorting result is different from other candidate sorting results. Specifically, the vertices of the predicted bounding box may be sorted as the starting vertices. Further, the predicted sorting result may be determined from multiple candidate sorting results. Figure 6 The sorting results of the target bounding box and the predicted bounding box are shown. Figure 6 As shown in a, after sorting the vertices of the predicted bounding box of a pentagon, 5 candidate sorting results are obtained, such as Figure 6 As described in b, after sorting the vertices of the target bounding box of the pentagon, a target sorting result is obtained, and it can be seen that Figure 6 The fifth candidate ranking result of a in Figure 6 The target sorting result of b matches.
[0112] A vertex A is randomly determined from the target sorting result, and then a vertex A' with the same order as vertex A in the target sorting result can be determined from the candidate sorting results that match the target sorting result, and a vertex A'' with the same order as vertex A in the target sorting result can be determined from the candidate sorting results that do not match the target sorting result. Figure 6 It can be seen that in most cases, the distance between vertex A and vertex A' is smaller than the distance between vertex A and vertex A''. In one implementation, based on the distances between vertices having the same order in the candidate sorting results and the target sorting results, determining a predicted sorting result matching the target sorting result from the candidate sorting results includes:
[0113] Determine the absolute values of distances between vertices having the same order from the candidate sorting results and the target sorting results;
[0114] The absolute values are summed up respectively according to the candidate sorting results to which they belong, to obtain the distance errors corresponding to the candidate sorting results;
[0115] Based on the distance error, the predicted sorting result is determined from the candidate sorting results.
[0116] Specifically, the distance between vertices with the same order can be determined from the candidate sorting results and the target sorting results, wherein the two vertices related to the distance are one from the candidate sorting results and the other from the target sorting results. Further, when the distances are all positive, the candidate sorting result to which the smallest distance corresponding to the same order belongs can be determined as the predicted sorting result; when the distances are all negative, the candidate sorting result to which the largest distance corresponding to the same order belongs can be determined as the predicted sorting result; when the distances are both positive and negative, the absolute value of the distance can be calculated, and further the candidate sorting result to which the smallest distance corresponding to the same order belongs can be determined as the predicted sorting result.
[0117] As mentioned before, the distance error is used to characterize the distance between the target bounding box and the predicted bounding box, such as Figure 5 As shown, for the same set of target bounding boxes and predicted bounding boxes (used to determine the target bounding boxes and predicted bounding boxes of the same target object), when the absolute value of the above distance is calculated, the distance error corresponding to the matched target sorting result and the candidate sorting result should be smaller than the distance error corresponding to the unmatched target sorting result and the candidate sorting result.
[0118] Furthermore, the absolute values of the distances corresponding to the vertices in the candidate sorting results can be added up according to the candidate sorting results to which they belong, to obtain the distance errors corresponding to the candidate sorting results. The process of solving the distance errors corresponding to the candidate sorting results can be shown in Formula 5:
[0119] D i =g((P1,P2,P3,...,P n ),(G1,G2,G3,...,G n ))=f(P i ,G1)+f(P i+1 , G2)+....+f(P i-1 ,G n ) (Formula 5)
[0120] Among them, D i is the distance error corresponding to the i-th candidate sorting result, (P1, P2, P3, ..., P n ) are the vertices in the i-th candidate sorting result, (G1, G2, G3, ..., G n ) are the vertices in the target sorting result, i∈1,2,... ,n, n is the number of vertices in the target bounding box, g(.) is used to solve the distance error corresponding to the i-th candidate sorting result, and f(.) is used to solve the distance between the first target vertex and the second target vertex (refer to Formula 2). In particular, when i is 1, i-1 is n.
[0121] Since the distance errors are all positive values, and the smaller the distance error, the more similar the target bounding box and the candidate bounding box are, and the larger the distance error, the less similar the target bounding box and the candidate bounding box are, in one example, the candidate sorting result to which the smallest distance error belongs can be determined as the predicted sorting result.
[0122] The above process uses distance error to determine the predicted sorting results. Since the distance error is obtained based on the distance between each vertex in the candidate sorting results and the vertices of the same order in the target sorting results, this process can avoid the incorrect selection of predicted sorting results when determining the predicted sorting results from the candidate sorting results because the distances corresponding to some vertices are insufficient to determine the matching degree between the candidate sorting structure and the target sorting results. This improves the accuracy of the predicted sorting results, thereby improving the detection accuracy of the trained image object detection model.
[0123] Furthermore, the distance errors corresponding to the candidate ranking results can be sorted from small to large, and the candidate ranking result ranked first in the ranking result can be determined as the predicted ranking result. Specifically, the distance error solution process can be shown in Formula 6:
[0124] R=min(D1, D2,... , D i ,. ..,D n ) (Formula 6)
[0125] Among them, R is the distance error corresponding to the predicted sorting result, D i is the distance error corresponding to the i-th candidate sorting result, min(.) is used to solve the minimum value, i∈1,2,... ,n, n is the number of vertices in the target bounding box.
[0126] For any vertex of the target bounding box, when a vertex of the candidate bounding box is far from the arbitrary vertex, the vertex of the candidate bounding box far from the arbitrary vertex is less likely to match the arbitrary vertex. In one implementation, based on the distance error, determining the predicted sorting result from the candidate sorting results includes:
[0127] Determine the order of the first target vertex in the target sorting result as the target order;
[0128] Determine a second target vertex whose distance to the first target vertex is less than a preset distance as a screening vertex;
[0129] Based on the distance error, a predicted sorting result is determined from the candidate sorting results having the screening vertices in the target order.
[0130] Specifically, a first target vertex can be used as the center to determine the screening vertices whose distance from the first target vertex is less than a preset distance, and then the predicted sorting result can be determined in the candidate sorting results whose target order has the screening vertex. This process only needs to calculate the distance error corresponding to the candidate sorting results whose target order has the screening vertex, which reduces the screening range of the predicted sorting result, improves the speed of determining the predicted sorting result, and thus improves the training speed of the image object detection model.
[0131] In the embodiment of the present specification, the vertices of the target bounding box and the predicted bounding box are first sorted using a preset sorting method, and then based on the distance between the target sorting result and the vertices of the same order in multiple candidate sorting results, the predicted sorting result matching the target sorting result is found in the candidate sorting results. This process achieves fast matching of the vertices of the target bounding box and the vertices of the predicted bounding box representing the same position of the target object based on the distance between the vertices in different sorting results, which can effectively improve the speed of calculating the second intersection-over-union ratio, and thus effectively improve the training speed of the image target detection model.
[0132] In one implementation, the first intersection-over-union ratio is corrected based on the distance error to obtain a second intersection-over-union ratio, including:
[0133] Based on the length and width of the sample image, a constraint value is obtained;
[0134] The distance error is normalized using the constraint value to obtain the correction value corresponding to the first intersection-over-union ratio;
[0135] The first intersection-over-union ratio is corrected using the correction value to obtain a second intersection-over-union ratio.
[0136] As mentioned above, the size of the sample image can be used to correct the first intersection-and-union ratio. In one example, a constraint value can be obtained based on the length and width of the sample image that determine the size of the sample image, and then the constraint value can be used to normalize the distance error to obtain a correction value. Further, the correction value can be used to correct the first intersection-and-union ratio to obtain a second intersection-and-union ratio. Specifically, the length and width of the sample image can be directly added to obtain the constraint value, or the length and width of the sample image can be added to the nth power to obtain the constraint value. The process of correcting the first intersection-and-union ratio using the length and width of the sample image can be shown as Formula 7:
[0137] IoU2 = IoU1–R / (H+W) Z (Formula 7)
[0138] Among them, IoU1 is the first intersection-over-union ratio, IoU2 is the second intersection-over-union ratio, R is the distance error, H is the length of the sample image, W is the width of the sample image, z is the custom power index used to balance the proportion of distance error R in IoU2, (H+W) is the constraint value, R / (H+W) Z is the correction value, and z is a custom parameter.
[0139] Specifically, z in Formula 7 and k in Formula 2 may be both 1 or 2.
[0140] In the embodiment of this specification, the distance error is normalized using the length and width that characterize the size of the sample image, and then the first intersection-and-union ratio is corrected using the correction value obtained after normalization to obtain the second intersection-and-union ratio. This process normalizes the distance error, avoids the interference of the image scale change on the second intersection-and-union ratio, improves the accuracy of the second intersection-and-union ratio, and thus improves the accuracy of the image target detection model.
[0141] In one implementation, the process of determining the first intersection-over-union ratio includes:
[0142] Use the preset unit structure to fill the overlapping area and non-overlapping area of the target bounding box and the predicted bounding box respectively;
[0143] Determine the sum of the numbers of unit structures in the overlapping area and the non-overlapping area as a first number;
[0144] Determine the number of unit structures in the overlapping area as a second number;
[0145] A first intersection-over-union ratio is determined based on the first quantity and the second quantity.
[0146] After the target bounding box and the predicted bounding box are filled using a preset unit structure, a first quantity may be used to represent the area of the union of the areas included in the target bounding box and the predicted bounding box, and a second quantity may be used to represent the area of the intersection of the areas included in the target bounding box and the predicted bounding box.
[0147] Specifically, for the first intersection-and-union ratio corresponding to the target bounding box and the predicted bounding box of regular shapes such as rectangles, the conventional intersection-and-union ratio calculation method can be used for calculation, which will not be described in detail here. For target bounding boxes and predicted bounding boxes of regular or irregular shapes, the area occupied by the target bounding box and the predicted bounding box can be segmented using a unit structure of a preset shape (square or triangle, etc.), and the first intersection-and-union ratio is determined based on the number of unit structures in the intersecting area and the number of unit structures in the merged area. For example, when the number of unit structures in the intersecting area (the second number) is 595 and the number of unit structures in the merged area (the first number) is 817, the first number is divided by the second number to obtain a first intersection-and-union ratio of 0.73 (=595 / 817).
[0148] In the embodiment of the present specification, a unit structure is used to fill the area in the target bounding box and the predicted bounding box, and then the first intersection-and-union ratio is determined according to the first number and the second number determined after filling. This process does not need to consider the shape of the target bounding box and the predicted bounding box, so that the method for solving the first intersection-and-union ratio is applicable to bounding boxes of any shape, which improves the robustness of the first intersection-and-union ratio solution method, and thus can improve the robustness of the trained image target detection model.
[0149] In one implementation, the above method for optimizing the algorithm of the image target detection model can be used for an image target detection model related to network security. Specifically, the sample objects in the sample image may include detection targets related to network security, and then the trained image target detection model can be used to detect the content related to network security in the image to be detected to obtain the detection result. The detection accuracy of the image target detection model for detection targets related to network security can be improved by the aforementioned method for optimizing the algorithm of the image target detection model. The application field of the image target detection model is not limited in this specification and can be expanded according to actual conditions.
[0150] It should be noted that the execution subject of the method for optimizing the network security image target detection model algorithm provided in the embodiments of this specification may be a device for optimizing the network security image target detection model algorithm, or a control module in the device for optimizing the network security image target detection model algorithm for executing the method for optimizing the network security image target detection model algorithm. In the embodiments of this specification, the device for optimizing the network security image target detection model algorithm provided in the embodiments of this specification is described by taking the method for optimizing the network security image target detection model algorithm executed by the device for optimizing the network security image target detection model algorithm as an example.
[0151] Figure 7 Schematic diagram of the structure of the device for optimizing the network security image target detection model algorithm according to an embodiment of the present invention. Figure 7 As shown, the device 700 for optimizing the network security image target detection model algorithm includes:
[0152] An acquisition module 710 is used to acquire a predicted bounding box predicted by an image target detection model, wherein the predicted bounding box is used to represent the predicted position of the detection target in the sample image, the number of vertices of the predicted bounding box and the target bounding box of the sample image is the same, and the target bounding box is used to represent the actual position of the detection target in the sample image;
[0153] an error module 720 for determining a distance error between the target bounding box and the predicted bounding box based on a distance between a first target vertex of the target bounding box and a second target vertex of the predicted bounding box, wherein the first target vertex matches the second target vertex;
[0154] An IoU module 730 is used to correct the first IoU based on the distance error to obtain a second IoU, where the first IoU is an area ratio between an intersection area and a union area of a first area and a second area, where the first area and the second area are areas occupied by a target bounding box and a predicted bounding box in the sample image, respectively;
[0155] The training module 740 is used to train the image object detection model according to the loss function corresponding to the second intersection-over-union ratio to obtain parameters of the trained image object detection model.
[0156] In one embodiment, a device 700 for optimizing a network security image object detection model algorithm includes:
[0157] A first sorting module is used to use any vertex of the target bounding box as a starting vertex and use a preset sorting method to sort the vertices of the target bounding box to obtain a target sorting result corresponding to the target bounding box;
[0158] A second sorting module is used to use the sorting method to sort the vertices of the predicted bounding box using each vertex of the predicted bounding box as a starting vertex, to obtain a plurality of candidate sorting results corresponding to the predicted bounding box, wherein the number of the candidate sorting results is the same as the number of vertices of the predicted bounding box;
[0159] A prediction module, configured to determine a predicted sorting result matching the target sorting result from the candidate sorting results based on the distances between vertices having the same order in the candidate sorting results and the target sorting result;
[0160] The vertex determination module is used to use the vertex in the predicted sorting result that has the same order as the first target vertex in the target sorting result as the second target vertex that matches the first target vertex.
[0161] In one embodiment, the prediction module includes:
[0162] An absolute value unit, used to determine the absolute values of distances between vertices having the same order from the candidate sorting results and the target sorting results;
[0163] A summing unit, used to sum the absolute values according to the candidate sorting results to which they belong, to obtain the distance error corresponding to each candidate sorting result;
[0164] The prediction unit is used to determine a predicted sorting result from the candidate sorting results based on the distance error.
[0165] In one embodiment, the preset sorting method is a clockwise vertex-by-vertex sorting method or a counterclockwise vertex-by-vertex sorting method.
[0166] In one embodiment, the intersection-and-union ratio module includes:
[0167] A constraint unit, used for obtaining a constraint value based on the length and width of the sample image;
[0168] A correction value unit, used to normalize the distance error using the constraint value to obtain a correction value corresponding to the first intersection-over-union ratio;
[0169] The correction unit is used to correct the first intersection-and-union ratio using the correction value to obtain a second intersection-and-union ratio.
[0170] In one embodiment, the process of determining the first intersection-over-union ratio includes:
[0171] Use the preset unit structure to fill the overlapping area and non-overlapping area of the target bounding box and the predicted bounding box respectively;
[0172] The sum of the numbers of unit structures in the overlapping area and the non-overlapping area is determined as a first number, where the first number is used to represent the area of the union of the area included in the target bounding box and the area included in the predicted bounding box;
[0173] Determine the number of unit structures in the overlapping area as a second number, where the second number is used to represent the area of the intersection of the area included in the target bounding box and the area included in the prediction bounding box;
[0174] A first intersection-over-union ratio is determined based on the first quantity and the second quantity.
[0175] In one embodiment, the detection target includes a detection target related to network security, and the device for optimizing the network security image target detection model algorithm further includes:
[0176] The detection module is used to use the trained image target detection model to detect the content related to network security in the image to be detected and obtain the detection result.
[0177] The device for optimizing the algorithm of the network security image target detection model provided by the embodiment of the present application uses the distance between the matched first target vertex and the second target vertex to determine the distance error, and then uses the distance error to correct the first intersection-and-union ratio, and determines the loss function according to the corrected second intersection-and-union ratio and trains the image target detection model according to the loss function. In this process, a new intersection-and-union ratio calculation method is provided, in which the determination of the distance error only needs to consider the distance between the matched first target vertex and the second target vertex, without considering the shape of the target bounding box and the predicted bounding box, effectively reducing the difficulty of the intersection-and-union ratio calculation process and improving the accuracy of the second intersection-and-union ratio calculation process, thereby improving the scalability and robustness of the image target detection model trained using the loss function corresponding to the second intersection-and-union ratio.
[0178] Each module in the above-mentioned network security image target detection model algorithm optimization device can be implemented in whole or in part by software, hardware and their combination. The above-mentioned modules can be embedded in or independent of the processor in the terminal device or the processor on the server in the form of hardware, or can be stored in the memory in the terminal device or the memory on the server in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0179] Furthermore, corresponding to the above-described method for optimizing the network security image target detection model algorithm, based on the same technical concept, one or more embodiments of the present application further provide an electronic device, which is used to execute the above-described method for optimizing the network security image target detection model algorithm. Figure 8 A schematic diagram of the structure of an electronic device provided for one or more embodiments of the present application.
[0180] Based on the same idea, one or more embodiments of this specification also provide an electronic device, such as Figure 8 As shown. The electronic device may have relatively large differences due to different configurations or performances, and may include one or more processors 801 and memory 802, and the memory 802 may store one or more storage applications or data. Among them, the memory 802 can be a temporary storage or a permanent storage. The application stored in the memory 802 may include one or more modules (not shown in the figure), and each module may include a series of computer executable instructions in the electronic device. Furthermore, the processor 801 can be configured to communicate with the memory 802 to execute a series of computer executable instructions in the memory 802 on the electronic device. The electronic device may also include one or more power supplies 803, one or more wired or wireless network interfaces 804, one or more input and output interfaces 805, and one or more keyboards 806.
[0181] In a specific embodiment, the electronic device includes a memory and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs may include one or more modules, and each module may include a series of computer executable instructions for the electronic device, and the one or more programs configured to be executed by one or more processors include the following computer executable instructions:
[0182] Obtain the predicted bounding box predicted by the image target detection model. The predicted bounding box is used to represent the predicted position of the detection target in the sample image. The number of vertices of the predicted bounding box and the target bounding box of the sample image is the same. The target bounding box is used to represent the actual position of the detection target in the sample image.
[0183] determining a distance error between the target bounding box and the predicted bounding box according to a distance between a first target vertex of the target bounding box and a second target vertex of the predicted bounding box, wherein the first target vertex matches the second target vertex;
[0184] The first intersection-and-union ratio is corrected based on the distance error to obtain a second intersection-and-union ratio, where the first intersection-and-union ratio is an area ratio between an intersection area and a union area of the first area and the second area, where the first area and the second area are areas occupied by the target bounding box and the predicted bounding box in the sample image, respectively;
[0185] The image object detection model is trained according to the loss function corresponding to the second intersection-over-union ratio to obtain parameters of the trained image object detection model.
[0186] The electronic device provided by one or more embodiments of the present application uses the distance between the matched first target vertex and the second target vertex to determine the distance error, and then uses the distance error to correct the first intersection-and-union ratio, and determines the loss function based on the corrected second intersection-and-union ratio and trains the image target detection model based on the loss function. In this process, a new intersection-and-union ratio calculation method is provided, in which the determination of the distance error only needs to consider the distance between the matched first target vertex and the second target vertex, without considering the shape of the target bounding box and the predicted bounding box, effectively reducing the difficulty of the intersection-and-union ratio calculation process and improving the accuracy of the second intersection-and-union ratio calculation process, thereby improving the scalability and robustness of the image target detection model trained using the loss function corresponding to the second intersection-and-union ratio.
[0187] It should be noted that the embodiment of the electronic device in the present application and the embodiment of the method for optimizing the network security image target detection model algorithm in the present application are based on the same inventive concept. Therefore, the specific implementation of this embodiment can refer to the implementation of the aforementioned corresponding method for optimizing the network security image target detection model algorithm, and the repeated parts will not be repeated.
[0188] Furthermore, corresponding to the method for optimizing the network security image target detection model algorithm described above, based on the same technical concept, one or more embodiments of the present application further provide a storage medium for storing computer executable instructions. In a specific embodiment, the storage medium may be a USB flash drive, an optical disk, a hard disk, etc. When the computer executable instructions stored in the storage medium are executed by the processor, the following process can be implemented:
[0189] Obtain the predicted bounding box predicted by the image target detection model. The predicted bounding box is used to represent the predicted position of the detection target in the sample image. The number of vertices of the predicted bounding box and the target bounding box of the sample image is the same. The target bounding box is used to represent the actual position of the detection target in the sample image.
[0190] determining a distance error between the target bounding box and the predicted bounding box according to a distance between a first target vertex of the target bounding box and a second target vertex of the predicted bounding box, wherein the first target vertex matches the second target vertex;
[0191] The first intersection-and-union ratio is corrected based on the distance error to obtain a second intersection-and-union ratio, where the first intersection-and-union ratio is an area ratio between an intersection area and a union area of the first area and the second area, where the first area and the second area are areas occupied by the target bounding box and the predicted bounding box in the sample image, respectively;
[0192] The image object detection model is trained according to the loss function corresponding to the second intersection-over-union ratio to obtain parameters of the trained image object detection model.
[0193] When the computer executable instructions stored in the storage medium provided by one or more embodiments of the present application are executed by the processor, the distance error is determined by using the distance between the matched first target vertex and the second target vertex, and then the first intersection-and-union ratio is corrected using the distance error. According to the corrected second intersection-and-union ratio, the loss function is determined and the image target detection model is trained according to the loss function. In this process, a new intersection-and-union ratio calculation method is provided, in which the determination of the distance error only needs to consider the distance between the matched first target vertex and the second target vertex, without considering the shape of the target bounding box and the predicted bounding box, effectively reducing the difficulty of the intersection-and-union ratio calculation process and improving the accuracy of the second intersection-and-union ratio calculation process, thereby improving the scalability and robustness of the image target detection model trained using the loss function corresponding to the second intersection-and-union ratio.
[0194] It should be noted that the embodiment of the storage medium in the present application and the method for optimizing the network security image target detection model algorithm in the present application are based on the same inventive concept. Therefore, the specific implementation of this embodiment can refer to the implementation of the corresponding method for optimizing the network security image target detection model algorithm mentioned above, and the repeated parts will not be repeated.
[0195] Furthermore, corresponding to the method for optimizing the network security image target detection model algorithm described above, based on the same technical concept, one or more embodiments of the present application also provide a computer program product, which includes a computer program. When the computer program is executed by a processor, the following process can be implemented:
[0196] Obtain the predicted bounding box predicted by the image target detection model. The predicted bounding box is used to represent the predicted position of the detection target in the sample image. The number of vertices of the predicted bounding box and the target bounding box of the sample image is the same. The target bounding box is used to represent the actual position of the detection target in the sample image.
[0197] determining a distance error between the target bounding box and the predicted bounding box according to a distance between a first target vertex of the target bounding box and a second target vertex of the predicted bounding box, wherein the first target vertex matches the second target vertex;
[0198] The first intersection-and-union ratio is corrected based on the distance error to obtain a second intersection-and-union ratio, where the first intersection-and-union ratio is an area ratio between an intersection area and a union area of the first area and the second area, where the first area and the second area are areas occupied by the target bounding box and the predicted bounding box in the sample image, respectively;
[0199] The image object detection model is trained according to the loss function corresponding to the second intersection-over-union ratio to obtain parameters of the trained image object detection model.
[0200] When the computer program in the computer program product provided by one or more embodiments of the present application is executed by the processor, the distance between the matched first target vertex and the second target vertex is used to determine the distance error, and then the first intersection-and-union ratio is corrected using the distance error. According to the corrected second intersection-and-union ratio, the loss function is determined and the image target detection model is trained according to the loss function. In this process, a new intersection-and-union ratio calculation method is provided, in which the determination of the distance error only needs to consider the distance between the matched first target vertex and the second target vertex, without considering the shape of the target bounding box and the predicted bounding box, effectively reducing the difficulty of the intersection-and-union ratio calculation process and improving the accuracy of the second intersection-and-union ratio calculation process, thereby improving the scalability and robustness of the image target detection model trained using the loss function corresponding to the second intersection-and-union ratio.
[0201] It should be noted that the embodiment of the computer program product in the present application and the embodiment of the method for optimizing the network security image target detection model algorithm in the present application are based on the same inventive concept. Therefore, the specific implementation of this embodiment can refer to the implementation of the aforementioned corresponding method for optimizing the network security image target detection model algorithm, and the repeated parts will not be repeated.
[0202] The above describes specific embodiments of the present application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0203] In the 1990s, it was very clear whether the improvement of a technology was hardware improvement (for example, improvement of the circuit structure of diodes, transistors, switches, etc.) or software improvement (improvement of the method flow). However, with the development of technology, many improvements of the method flow today can be regarded as direct improvements of the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that the improvement of a method flow cannot be implemented with a hardware entity module. For example, a programmable logic device (PLD) (such as a field programmable gate array (FPGA)) is such an integrated circuit whose logical function is determined by the user's programming of the device. Designers can "integrate" a digital system on a PLD by programming themselves, without having to ask chip manufacturers to design and make dedicated integrated circuit chips. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented by "logic compiler" software, which is similar to the software compiler used when developing and writing programs, and the original code before compilation must also be written in a specific programming language, which is called hardware description language (HDL). There is not only one kind of HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also know that it is only necessary to program the method flow slightly in the above-mentioned hardware description languages and program it into the integrated circuit, and then it is easy to obtain the hardware circuit that implements the logic method flow.
[0204] The controller may be implemented in any suitable manner, for example, the controller may take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (e.g., software or firmware) executable by the (micro)processor, a logic gate, a switch, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller, examples of which include but are not limited to the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320, and the memory controller may also be implemented as part of the control logic of the memory. It is also known to those skilled in the art that, in addition to implementing the controller in a purely computer-readable program code manner, the controller may be implemented in the form of a logic gate, a switch, an application-specific integrated circuit, a programmable logic controller, and an embedded microcontroller by logically programming the method steps. Therefore, such a controller may be considered as a hardware component, and the devices for implementing various functions included therein may also be considered as structures within the hardware component. Or even, the devices for implementing various functions may be considered as both software modules for implementing the method and structures within the hardware component.
[0205] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0206] For the convenience of description, the above devices are described in terms of functions and are divided into various units. Of course, when implementing the embodiments of the present application, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0207] Those skilled in the art will appreciate that one or more embodiments of the present application may be provided as a method, system or computer program product. Therefore, one or more embodiments of the present application may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0208] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0209] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0210] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0211] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0212] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
[0213] Computer readable media include permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0214] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, an element defined by the sentence "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity or device including the element.
[0215] One or more embodiments of the present application may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. One or more embodiments of the present application may also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.
[0216] Each embodiment in this application is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0217] The above description is only an embodiment of this document and is not intended to limit this document. For those skilled in the art, this document may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of this document should be included in the scope of the claims of this document.
Claims
1. A method for optimizing a network security image target detection model algorithm, characterized in that: include: Obtain a predicted bounding box predicted by an image target detection model, wherein the predicted bounding box is used to represent the predicted position of the detection target in the sample image, the predicted bounding box has the same number of vertices as the target bounding box of the sample image, and the target bounding box is used to represent the actual position of the detection target in the sample image; Taking any vertex of the target bounding box as a starting vertex, sorting the vertices of the target bounding box using a preset sorting method to obtain a target sorting result corresponding to the target bounding box; In this way, each vertex of the predicted bounding box is used as a starting vertex, and the vertices of the predicted bounding box are sorted using the sorting method to obtain a plurality of candidate sorting results corresponding to the predicted bounding box, wherein the number of the candidate sorting results is the same as the number of vertices of the predicted bounding box; Determining a predicted sorting result that matches the target sorting result from the candidate sorting results based on the distances between vertices having the same order in the candidate sorting results and the target sorting result; Using a vertex in the predicted sorting result that has the same order as the first target vertex of the target bounding box in the target sorting result as a second target vertex that matches the first target vertex; Determining a distance error between the target bounding box and the predicted bounding box according to a distance between the first target vertex and the second target vertex; Correcting the first intersection-and-union ratio based on the distance error to obtain a second intersection-and-union ratio, wherein the first intersection-and-union ratio is an area ratio between an intersection area and a union area of a first region and a second region, wherein the first region and the second region are regions occupied by the target bounding box and the predicted bounding box in the sample image, respectively; The image object detection model is trained according to the loss function corresponding to the second intersection-over-union ratio to obtain parameters of the trained image object detection model.
2. The method according to claim 1, characterized in that Determining a predicted sorting result matching the target sorting result from the candidate sorting results based on the distances between vertices having the same order in the candidate sorting results and the target sorting result, comprising: Determine the absolute values of distances between vertices having the same order from the candidate sorting results and the target sorting results; The absolute values are summed up respectively according to the candidate sorting results to which they belong, to obtain the distance errors corresponding to the candidate sorting results; Based on the distance error, the predicted sorting result is determined from the candidate sorting results.
3. The method according to claim 1, characterized in that: The preset sorting method is a clockwise vertex-by-vertex sorting method or a counterclockwise vertex-by-vertex sorting method.
4. The method according to claim 1, characterized in that: The first intersection-over-union ratio is corrected based on the distance error to obtain a second intersection-over-union ratio, including: Obtaining a constraint value based on the length and width of the sample image; Normalizing the distance error using the constraint value to obtain a correction value corresponding to the first intersection-over-combination ratio; The first intersection-and-union ratio is corrected using the correction value to obtain the second intersection-and-union ratio.
5. The method according to claim 1, characterized in that The process of determining the first intersection-over-union ratio includes: Using a preset unit structure, filling the overlapping area and the non-overlapping area of the target bounding box and the predicted bounding box respectively; Determine the sum of the numbers of the unit structures in the overlapping area and the non-overlapping area as a first number, where the first number is used to represent the area of a union of the areas included in the target bounding box and the predicted bounding box; Determine the number of the unit structures in the overlapping area as a second number, where the second number is used to represent the area of the intersection of the area included in the target bounding box and the area included in the prediction bounding box; The first intersection-over-union ratio is determined according to the first number and the second number.
6. The method according to any one of claims 1 to 5, characterized in that: The detection target includes a detection target related to network security, and the method further includes: The trained image target detection model is used to detect network security-related content in the image to be detected to obtain the detection result.
7. A device for optimizing a network security image target detection model algorithm, characterized in that: include: An acquisition module is used to acquire a predicted bounding box predicted by an image target detection model, wherein the predicted bounding box is used to represent the predicted position of the detection target in the sample image, the number of vertices of the predicted bounding box and the target bounding box of the sample image is the same, and the target bounding box is used to represent the actual position of the detection target in the sample image; A first sorting module is used to use any vertex of the target bounding box as a starting vertex and use a preset sorting method to sort the vertices of the target bounding box to obtain a target sorting result corresponding to the target bounding box; A second sorting module is used to sequentially use each vertex of the predicted bounding box as a starting vertex and use the sorting method to sort the vertices of the predicted bounding box to obtain a plurality of candidate sorting results corresponding to the predicted bounding box, wherein the number of the candidate sorting results is the same as the number of vertices of the predicted bounding box; A prediction module, configured to determine a predicted sorting result matching the target sorting result from the candidate sorting results based on the distances between vertices having the same order in the candidate sorting results and the target sorting result; a vertex determination module, configured to use a vertex in the predicted sorting result that has the same order as a first target vertex of the target bounding box in the target sorting result as a second target vertex that matches the first target vertex; an error module, configured to determine a distance error between the target bounding box and the predicted bounding box according to a distance between the first target vertex and the second target vertex; an IoU module, configured to correct a first IoU based on the distance error to obtain a second IoU, wherein the first IoU is an area ratio between an intersection area and a union area of a first area and a second area, wherein the first area and the second area are areas occupied by the target bounding box and the predicted bounding box in the sample image, respectively; A training module is used to train the image target detection model according to the loss function corresponding to the second intersection-over-union ratio to obtain parameters of the trained image target detection model.
8. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; The processor is configured to implement the method described in any one of claims 1 to 6 when executing the instructions stored in the memory.
9. A non-volatile computer-readable storage medium having computer program instructions stored thereon, characterized in that: When the computer program instructions are executed by a processor, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Construction method and application of ship target directed detection model
CN113191372A
Escalator passenger posture anomaly detection method based on improved SSD model
CN115273146A
Target detection method based on normalized angular point distance and target foreground information
CN116229191A
Text detection method and device, electronic equipment and storage medium
CN116434210A
Target detection method and system for improving bounding box regression loss and medium
CN117315224A
