Training method and device of intrusion detection model based on YOLOv5

CN115223003BActive Publication Date: 2026-11-24FENGTAI SCI & TECH (BEIJING) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210636882.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-07
Publication Date
2026-11-24
Estimated Expiration
2042-06-07

AI Technical Summary

Technical Problem

[0003]本申请实施例提供了基于YOLOv5的入侵检测模型的训练方法及装置,可以解决基于YOLOv5的入侵检测模型的训练的过程中存在大量冗余计算的问题,能够提高对基于YOLOv5的入侵检测模型的训练效果

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115223003B_ABST
    Figure CN115223003B_ABST
Patent Text Reader

Abstract

This application relates to the field of intelligent video surveillance technology and provides a training method for an intrusion detection model based on YOLOv5. The method includes constructing a training set and a validation set. The training set includes multiple training images and multiple training bounding boxes, and the validation set includes multiple validation images and multiple validation bounding boxes. K cluster centers are determined within the multiple training bounding boxes using indices, which indicate the distance between different training bounding boxes. The multiple training bounding boxes are then clustered based on the K cluster centers to obtain K cluster groups. K prior boxes are determined based on the K cluster groups. The YOLOv5-based intrusion detection model is trained on the training and validation sets using the K prior boxes until convergence. This application's embodiment significantly reduces redundant computation during model training by using indices to determine K cluster centers within multiple training bounding boxes, thereby improving the training speed and effectiveness.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of intelligent video surveillance technology, and in particular relates to a training method and apparatus for an intrusion detection model based on YOLOv5. Background Technology

[0002] With the widespread adoption of broadband networks, the development of computer technology, and the improvement of image processing technology, video surveillance technology is increasingly penetrating various fields such as education, government, entertainment, healthcare, and hotels. Especially in the security field, video surveillance is a crucial tool for assisting public security departments in combating crime and maintaining social stability. However, existing video surveillance analysis methods remain at a low level, relying on post-event manual analysis based on the collected surveillance video. This method suffers from a high error rate and is not conducive to the timely detection and handling of intrusions or boundary violations, thus hindering the effective realization of the application value of video surveillance in security and other fields. Summary of the Invention

[0003] This application provides a training method and apparatus for an intrusion detection model based on YOLOv5, which can solve the problem of a large amount of redundant computation in the training process of the intrusion detection model based on YOLOv5 and improve the training effect of the intrusion detection model based on YOLOv5.

[0004] In a first aspect, embodiments of this application provide a training method for an intrusion detection model based on YOLOv5, comprising: constructing a training set and a validation set, wherein the training set includes multiple training images and multiple training bounding boxes, and the validation set includes multiple validation images and multiple validation bounding boxes, wherein the multiple training bounding boxes are used to identify target personnel in the multiple training images, and the multiple validation bounding boxes are used to identify target personnel in the multiple validation images; determining K cluster centers in the multiple training bounding boxes using indices, wherein the indices are used to indicate the distance between different training bounding boxes; clustering the multiple training bounding boxes based on the K cluster centers to obtain K cluster groups; determining K prior boxes based on the K cluster groups; and training the YOLOv5-based intrusion detection model on the training set and validation set until convergence using the K prior boxes; wherein K is greater than 1.

[0005] This application embodiment determines K cluster centers in multiple training frames by using an index, which greatly reduces redundant computation during model training, improves the training speed and effect of the model, and also improves the detection efficiency and accuracy of intrusion detection using the YOLOv5-based intrusion detection model.

[0006] In one possible implementation of the first aspect, determining K cluster centers among multiple training boxes using an index includes: using a first training box as a first cluster center, where the first training box is any one of the multiple training boxes; determining a first distance, which is the distance between a second training box and the first cluster center, where the second training box is any one of the multiple training boxes other than the first training box; establishing a first index to indicate the first distance; determining a first probability that the second training box is selected as a cluster center based on the first distance; and determining the second cluster center according to the first probability. In this implementation, using training boxes farther from the first cluster center as cluster centers improves clustering efficiency, increases the training speed of the YOLOv5-based intrusion detection model, and improves the efficiency of applying the YOLOv5-based intrusion detection model.

[0007] In one possible implementation of the first aspect, the method further includes: determining a second distance, which is the distance between the third training box and K-1 cluster centers, where the third training box is any training box other than the K-1 cluster centers; establishing a second index to indicate the second distance; determining a minimum second distance, which is the minimum value of the second distance; determining a second probability based on the minimum second distance, where the second probability is the probability that the third training box is selected as a cluster center; and determining the Kth cluster center according to the second probability; wherein K is greater than 2, and the minimum second distance is obtained through the first and second indices. In this implementation, the minimum second distance is obtained through the first and second indices, reducing redundant computations during model training and improving the training efficiency of the model.

[0008] In one possible implementation of the first aspect, multiple training boxes are clustered based on K cluster centers to obtain K cluster groups. This includes: determining a third distance, which is the distance between a fourth training box (excluding the K cluster centers) and K-1 cluster centers, as well as the distance between the fourth training box and the Kth cluster center; determining a minimum third distance, which is the minimum value of the third distances; and including the fourth training box in the first cluster group, with the minimum third distance corresponding to the first cluster group. The minimum third distance is obtained through a first index and a second index. In this implementation, the minimum third distance is obtained through the first and second indices, which further reduces redundant computation, improves the training efficiency of the model, and enhances the efficiency of applying YOLOv5-based intrusion detection.

[0009] In one possible implementation of the first aspect, the method further includes: determining the cluster centers of the first cluster group, where the cluster centers of the first cluster group correspond to the average size of the training boxes in the first cluster group; determining a fourth distance, where the fourth distance is the distance between the fifth training box (excluding the K cluster centers) and the K cluster centers; determining a minimum fourth distance, where the minimum fourth distance is the minimum value of the fourth distance; and including the fifth training box in the second cluster group, where the minimum fourth distance corresponds to the second cluster group. In this implementation, by repeatedly clustering the training boxes, the clustering of all training boxes is finally completed, ensuring the training effect of the model.

[0010] In one possible implementation of the first aspect, determining K prior boxes based on K cluster groups includes: determining the average size of multiple training boxes in the first cluster group of the K cluster groups, and using the average size of the multiple training boxes in the first cluster group as the size of the first prior box. In this implementation, training the model using the K cluster groups obtained above significantly reduces the computational load and improves the training effect of the model.

[0011] In one possible implementation of the first aspect, training a YOLOv5-based intrusion detection model to convergence on a training set and a validation set using K prior bounding boxes includes: detecting a first validation image using the YOLOv5-based intrusion detection model to obtain a first detection bounding box, wherein the first validation image includes the first validation bounding box; and using the loss function Loss ciou Train the intrusion detection model based on YOLOv5 until convergence; where the loss function is Loss ciou Calculated using the following formula:

[0012]

[0013]

[0014]

[0015] Where A is the region of the first detection box, B is the region of the first verification box, and b is the center point of the first detection box. gt It is the center point of the first validation box, ρ(b, b). gt ) is the distance between the center points of the first detection box and the first verification box, c is the diagonal length of the smallest bounding rectangle of the first detection box and the first verification box, w is the width of the first detection box, and h is the height of the first detection box. gt It is the width of the first validation box, h gt This is the height of the first validation box. In this implementation, the loss function is used. ciouTraining the model ensures that the model can effectively evaluate the similarity of various detection boxes and validation boxes, thereby improving the effectiveness of model training and application.

[0016] Secondly, embodiments of this application also provide an apparatus including a unit for performing the method as described in the first aspect or any one of the first aspects.

[0017] Thirdly, embodiments of this application also provide an apparatus comprising: at least one processor, a memory, and a computer program stored in the memory and executable on the at least one processor, characterized in that the processor executes the computer program to implement the method as described in the first aspect or any one of the first aspects.

[0018] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program, characterized in that the computer program, when executed by a processor, implements the method as described in the first aspect or any one of the first aspects.

[0019] Fifthly, embodiments of this application provide a computer program product that, when run on an electronic device, causes the electronic device to perform the method described in the first aspect or any one of the first aspects.

[0020] Sixthly, embodiments of this application also provide an intrusion detection method, which can use an artificial intelligence model trained by the training method of the YOLOv5-based intrusion detection model described in the first aspect or any one of the first aspects to perform personnel intrusion detection, thereby improving the effectiveness of personnel intrusion detection.

[0021] In a seventh aspect, embodiments of this application also provide an intrusion detection device that can perform personnel intrusion detection using the intrusion detection method described in the sixth aspect, thereby improving the effectiveness of personnel intrusion detection.

[0022] It is understood that the beneficial effects of the second to seventh aspects mentioned above can be found in the relevant descriptions in the first aspect mentioned above, and will not be repeated here.

[0023] The beneficial effects of the embodiments of this application compared with the prior art are:

[0024] This application embodiment determines K cluster centers in multiple training frames by using an index, which greatly reduces redundant computation during model training, improves the training speed and effect of the model, and also improves the detection efficiency and accuracy of intrusion detection using the YOLOv5-based intrusion detection model. Attached Figure Description

[0025] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0026] Figure 1 This is a flowchart illustrating the training method of the YOLOv5-based intrusion detection model in this application;

[0027] Figure 2 This is a flowchart illustrating the process of obtaining two cluster centers in one embodiment of this application;

[0028] Figure 3 This is a schematic diagram illustrating the process of obtaining two cluster centers in one embodiment of this application;

[0029] Figure 4 This is a schematic diagram of the process for obtaining K cluster centers in one embodiment of this application;

[0030] Figure 5 This is a flowchart illustrating the clustering process provided in one embodiment of this application;

[0031] Figure 6 This is a schematic diagram showing the relationship between detection box A and verification box B in one embodiment of this application;

[0032] Figure 7 This is a schematic diagram of an apparatus provided in an embodiment of this application. Detailed Implementation

[0033] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.

[0034] It should be understood that, when used in this application specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or a collection thereof.

[0035] It should also be understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.

[0036] As used in this application specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrase "if determined" or "if detected [the described condition or event]" may be interpreted, depending on the context, as meaning "once determined," "in response to determination," "once detected [the described condition or event]," or "in response to detection [the described condition or event]."

[0037] Furthermore, in the description of this application and the appended claims, the terms "first," "second," "third," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0038] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.

[0039] Automatic target detection in video surveillance using object detection models can improve the intelligence of video surveillance. The YOLO series of object detection models are single-stage models. When an image is input into the model, it can simultaneously detect the location and category of targets within a single detection stage. Here, "target" refers to the object the model needs to detect in the image. The location of the detected target can be represented by a rectangle in the image, and the category of the detected target can be indicated in the upper left corner of the rectangle representing the target's location.

[0040] To improve object detection performance, an object detection model can first be trained using a dataset to obtain a model applicable to real-world detection scenarios. The training dataset contains multiple training images, each labeled with information about the location, size, and category of the bounding box used to select the target within the training image.

[0041] The size of the initial bounding box (i.e., the bounding box used to select the target in the image during training) of the YOLO series of object detection models has a significant impact on the accuracy of the training results. The closer the size of the initial bounding box is to the size of the target's bounding box in the training image, the faster the model converges and the more accurate the model's target detection results.

[0042] In YOLOv2 and later versions of the object detection model, a mechanism was introduced to obtain initial bounding boxes of appropriate sizes through clustering. This involves clustering the bounding boxes in multiple training images to obtain multiple bounding boxes of different sizes. These different sized bounding boxes are then used as initial bounding boxes to train the model, improving training performance. These initial bounding boxes are also called prior boxes. However, the process of obtaining prior boxes through clustering requires repeated calculation of the intersection-union ratio (IUU) between the bounding boxes in each training image, resulting in a large amount of redundant computation and reducing the model's training efficiency.

[0043] In view of this, embodiments of this application provide a training method and apparatus for an intrusion detection model based on YOLOv5. During the training process of the intrusion detection model based on YOLOv5, prior boxes of appropriate size are obtained according to the indexed K-means++ clustering algorithm, which greatly reduces redundant calculations in the process of obtaining prior boxes through clustering. Then, the intrusion detection model based on YOLOv5 is trained based on the prior boxes, thereby improving the training efficiency of the intrusion detection model based on YOLOv5.

[0044] In some scenarios, the YOLOv5-based intrusion detection model trained in the embodiments of this application can be applied to the security system of public places. By efficiently training the intrusion detection model and performing intrusion detection on key areas of public places based on the trained intrusion detection model, the security effect of public places can be improved.

[0045] In some scenarios, the YOLOv5-based intrusion detection model trained in this application embodiment can be applied to home monitoring devices. By quickly training the intrusion detection model and using the trained intrusion detection model to detect moving targets or regional intrusions in the home environment, the intelligence and security of the home environment can be improved.

[0046] The training method and apparatus for the YOLOv5-based intrusion detection model in this application are illustrated below with specific examples.

[0047] Figure 1 This is a flowchart illustrating the training method of the YOLOv5-based intrusion detection model in this application, including steps S101 to S103. Steps S101 to S103 are explained below with specific examples.

[0048] S101. Construct the training set and validation set.

[0049] The training set is used to train the intrusion detection model, which learns from the training set and continuously reduces training error. The validation set is used to verify the state and convergence of the intrusion detection model during training.

[0050] The training and validation sets each contain multiple images. Images in the training set are called training images, and images in the validation set are called validation images. During the construction of the training and validation sets, cameras can be used to capture on-site surveillance images of the locations requiring intrusion detection. These captured images are then used as training images in the training set and validation images in the validation set.

[0051] When acquiring on-site monitoring images, cameras can be used to capture on-site video. Then, frame extraction can be used to obtain image data from the video data. This image data is then processed to obtain validation images for both the training and validation sets. The cameras can transmit the on-site monitoring video data via the RTSP protocol.

[0052] Furthermore, in the actual deployment of cameras, various factors such as light intensity and environmental obstruction need to be considered. Therefore, when installing cameras, interference from the external environment on the camera's video and image acquisition should be avoided or reduced as much as possible to improve the quality of images in the training and validation sets and enhance the training effect.

[0053] Furthermore, when constructing the training and validation sets, it is necessary to filter the images, removing those that do not meet the training requirements to improve the model's training performance. For example, blurry images or images that do not contain people can be removed.

[0054] In some embodiments, to improve the detection performance of the intrusion detection model, multiple training images and multiple verification images can be collected at different collection times to improve the identification of intruders at different times. For example, the collection times can be distributed between 8:00 and 9:00 in the morning, 11:30 and 12:30 in the afternoon, 17:30 and 18:30 in the evening, and 20:00 and 21:00 at night.

[0055] When constructing training and validation sets, images need to be labeled to obtain training and validation images. For example, the labelImg tool (an image labeling tool) can be used to label the training images, resulting in labeled training images. Each labeled training image contains the target person, and the target person is identified by a label on the training image. Similarly, labeled validation images can be obtained, each containing the target person, and the target person is identified by a label on the validation image.

[0056] For example, the first training image has a first training label, which contains location, size, and category information. The first training label allows for the location of a first training bounding box within the first training image. This first training bounding box selects the target person within the first training image, indicating the target person's location, size, and category. Each training image has at least one first training label identifying the target person.

[0057] For example, the first verification image has a first verification label. The first verification label contains location, size, and category information. The first verification label allows the location of the first verification box in the first verification image. The first verification box selects the target person in the first verification image, indicating the target person's location, size, and category. Each verification image must have at least one first verification label identifying the target person.

[0058] Specifically, the first training label or the first verification label is stored in a txt file. The top-left corner of the first training box or the first verification box is located at (x, y), the width of the first training box or the first verification box is w, and the height of the first training box or the first verification box is h. Since the target category in the first training box or the first verification box is only "person", only a single number representing the category is needed to represent "person". For example, the category "person" can be represented by the number 0. Therefore, the first training box or the first verification box can be represented in the first training image or the first verification image using (x, y, w, h, 0) as the label.

[0059] S102. Cluster the training boxes in multiple training images using the indexed K-means++ algorithm to obtain multiple prior boxes.

[0060] The bounding boxes used to select different detection targets often have different aspect ratios and sizes. For example, in tasks involving detecting personnel and vehicles, the aspect ratios and sizes of the bounding boxes selecting personnel and vehicles often differ significantly. For instance, the aspect ratio of the bounding box selecting personnel is close to 1 / 2, while the aspect ratio of the bounding box selecting vehicles is close to 1. Therefore, when detecting different types of targets, selecting prior boxes of appropriate sizes can improve the training speed of the model during subsequent training and increase the accuracy of personnel detection.

[0061] To obtain prior boxes suitable for training the intrusion detection model, this embodiment uses an indexed K-means++ algorithm to cluster training boxes from multiple training images. Clustering is an analytical process that groups a set of physical or abstract objects into multiple classes composed of similar objects. In this embodiment, clustering training boxes from multiple training images yields multiple training box groups. These training box groups are also called cluster groups. The training boxes in each group are of similar size. Then, by calculating the average size of the training boxes in each group, prior boxes with the average size can be obtained. The size of these prior boxes is similar to the target in the image to be detected in terms of aspect ratio and size.

[0062] The specific number of prior boxes can be an empirical value. For example, the specific number of prior boxes can be 1, 3, or 5.

[0063] Specifically, the sizes of the prior boxes are different. For example, the multiple prior boxes obtained from clustering can be named prior box A, prior box B, and prior box C, where the size of prior box A is (w a h a The size of the prior box B is (w b h b The size of the prior box C is (w c h c ), where w a w b and w c h represents the width of the prior bounding box. a h b and h c This indicates the height of the prior bounding box.

[0064] S103. Train the YOLOv5-based intrusion detection model on the training and validation sets until convergence using multiple prior boxes.

[0065] The intrusion detection model based on YOLOv5 is trained using multiple prior bounding boxes and multiple training images, and then validated using multiple validation images in the validation set. The training continues until the model converges, resulting in a fully trained intrusion detection model based on YOLOv5.

[0066] In this embodiment, the intrusion detection model based on YOLOv5 includes an input layer, multiple convolutional layers, multiple pooling layers, a fully connected layer, and an output layer. The input layer is used to crop, normalize, or augment the input image to obtain input data. Multiple convolutional layers perform convolution operations on the input data processed by the input layer to extract feature information for subsequent classification and localization. Multiple pooling layers downsample the data input from the multiple convolutional layers in the feature space. Two fully connected layers connect the last pooling layer to the output layer, converting the extracted two-dimensional feature matrix into a one-dimensional feature matrix. The output layer obtains the prediction result based on the one-dimensional feature matrix and outputs the target detection result.

[0067] When validating an intrusion detection model based on YOLOv5 using a validation set, the validation images in the validation set are input into the intrusion detection model for target detection. This allows the model to obtain the bounding boxes at the target locations detected in the images. Then, the accuracy between the bounding boxes and the boxes in the images is evaluated using a loss function. The model is continuously adjusted and trained until it converges.

[0068] Figure 2 This is a schematic diagram of the process for obtaining two cluster centers in an embodiment of this application, as shown below. Figure 2 As shown, multiple prior boxes can be obtained through clustering via steps S201 to S205. Steps S201 to S205 are explained in detail below. The required number of prior boxes is K.

[0069] S201. Use the first training box as the first cluster center.

[0070] Here, the first training box can be randomly selected from the training boxes in multiple training images, and the size (w, h) of the first training box is the parameter of the first cluster center.

[0071] It should be understood that a training image may contain one training bounding box or multiple training bounding boxes, which can be used to label one or more targets in a training image.

[0072] S202. Determine the first distance, which is the distance between the second training box and the first cluster center.

[0073] The second training box is any training box in the training set other than the first training box (i.e., the first cluster center). The second training box can also be described as any training box that was not selected as a cluster center. The first distance can be represented by the intersection-over-union (IoU) ratio between the second training box and the first cluster center. Specifically, the first distance can be represented by formula (1):

[0074] D = 1 - IoU (1)

[0075] In formula (1), D represents the first distance between the second training box and the first cluster center, and IoU is the cross-union ratio between the second training box and the first cluster center.

[0076] When calculating the Intersection over Union (IoU), first move either the first cluster center A or the second training box B so that the rectangular region of the first cluster center A and the lower left corner of the second training box B coincide. The IoU can then be calculated using formula (2):

[0077]

[0078] In formula (2), A is the rectangular region of the first cluster center, B is the region of the second training box, A∩B represents the area of ​​the intersection of the rectangular region of the first cluster center A and the second training box B, and A∪B represents the area of ​​the region formed by the union of the rectangular region of the first cluster center A and the second training box B.

[0079] S203. Establish a first index, which is used to indicate a first distance.

[0080] To improve computational efficiency, a first index for the first distance can be established. The first index indicates the first distance, and in subsequent calculations, the first distance between the second training box and the first cluster center can be obtained through the first index, effectively improving computational efficiency and increasing the training speed of the model.

[0081] Specifically, when establishing the first index, for the nth training box, the first intersection-union ratio (IoU) between the nth training box and the first cluster center is... n1 The first distance between the nth training box and the first cluster center is D. n1 The corresponding first index number is n1. When we need to obtain the first distance D between the nth training box and the first cluster center... n1 At that time, only the first index number n1 is needed to obtain the first distance D between the nth training box and the first cluster center. n1 .

[0082] Specifically, the first index can be represented in tabular form. Table 1 is an example table showing the first index of the first distance between the second training box and the first cluster center, as shown in Table 1:

[0083] Table 1

[0084] First Index Number 11 21 31 … n1 First distance 1 <![CDATA[D 21 ]]> <![CDATA[D 31 ]]> … <![CDATA[D n1 ]]>

[0085] It should be understood that the first index number can also be calculated using the coordinates of the first cluster center and the remaining training boxes. The first index number can also be recorded in the form of a table, array, or matrix. This application embodiment does not limit the method of obtaining the first index number or the form of recording it.

[0086] S204. Based on the first distance, determine the first probability that the second training box is selected as the cluster center.

[0087] When selecting other cluster centers, training boxes that are far from the first cluster center can be used as second cluster centers to improve the subsequent clustering speed.

[0088] Based on the first distance, the first probability that the second training box is selected as the second cluster center can be calculated. Specifically, the calculation process of the first probability can be expressed by formula (3):

[0089]

[0090] In formula (3), D(x) represents the first distance from the second training box to the first cluster center. x∈X D(x) 2 Let P(x) represent the sum of squared distances from all training boxes other than the first cluster center (i.e., all second training boxes) to the first cluster center, and let P(x) represent the first probability that a second training box is selected as the second cluster center.

[0091] According to formula (3), when the first distance D(x) from the second training box to the first cluster center is large, the probability of the second training box being selected as the second cluster center is larger. This can increase the distance between each cluster center and improve the clustering efficiency.

[0092] Since a first index has already been established in S202 based on the first distance between the second training box and the first cluster center, when calculating the probability that the second training box is selected as the cluster center according to formula (3), the first distance between the second training box and the first cluster center can be obtained based on the first index, without having to calculate the first distance between the second training box and the first cluster center again, thus improving the clustering efficiency.

[0093] S205. Determine the second cluster center based on the first probability.

[0094] In S201, the first cluster center has already been obtained. Based on the first probability, the second cluster center is selected from the remaining training boxes, resulting in two cluster centers: the first cluster center and the second cluster center. The second training box with the higher first probability is more likely to be selected as the second cluster center. This increases the probability of selecting second training boxes that are farther from the first cluster center, thus improving clustering efficiency.

[0095] in, Figure 3 This is a schematic diagram illustrating the process of obtaining two cluster centers in S201 to S205, as shown below. Figure 3 As shown in Figures a and b, the training boxes include training box x1, training box x2, training box x3, training box x4, training box x5, and training box x6. Figure 3 As shown in Figure a, firstly, training box x1 is randomly selected as the first cluster center from training boxes x1, x2, x3, x4, x5, and x6. Then, the first distance from the remaining training boxes x2, x3, x4, x5, and x6 to training box x1 is calculated. Training box x4 has the largest first distance to training box x1, therefore, training box x4 has the highest probability of being selected as the second cluster center. Training boxes x2, x3, x4, x5, and x6 can be denoted as the second training boxes.

[0096] In some embodiments, if only two prior boxes are required, then only two cluster centers are needed. After obtaining the two cluster centers, the prior boxes other than the cluster centers are clustered according to the first and second cluster centers to obtain multiple cluster groups. The average size of the training boxes of the multiple cluster groups is the size of the prior boxes.

[0097] In some embodiments, if it is necessary to select K cluster centers (K > 2), K-1 cluster centers can be randomly selected according to S205. For example, if it is necessary to select 3 cluster centers, 2 cluster centers can be randomly selected according to S205 to obtain K cluster centers.

[0098] In other embodiments, selecting the training box that is furthest from each cluster center from the training box that was not selected as a cluster center can improve clustering efficiency.

[0099] Figure 4 This is a flowchart illustrating the process of obtaining K cluster centers, as follows: Figure 4 As shown, S401 to S403 is the process of selecting the training box that is furthest from the K-1 cluster centers from the training box that was not selected as a cluster center, which will be described in detail below.

[0100] Specifically, let's take the selection of the Kth cluster center as an example. In selecting the Kth cluster center, K-1 cluster centers have already been selected.

[0101] S401. Determine the second distance, which is the distance between the third training box and the K-1 cluster centers.

[0102] Here, we can first calculate the distance from the training boxes that were not selected as cluster centers to each cluster center, and then use this distance as the second distance. The third training box is any one of the training boxes other than the K-1 cluster centers.

[0103] Specifically, the distance from a training box that was not selected as a cluster center to the nearest cluster center can be represented as D(x). D(x) can be quickly obtained through the first index in S202, thus improving computational efficiency. The second distance can be obtained through D(x). min express.

[0104] S402. Establish a second index, which is used to indicate a second distance.

[0105] In S402, a second index can be created for the distance (i.e., the second distance) from the training boxes that are not selected as cluster centers to each cluster center. In subsequent calculations, redundant calculations can be reduced by using the second index.

[0106] The second index can have the same form as the first index, which will not be elaborated here.

[0107] S403. Determine the minimum second distance, which is the minimum value of the second distance.

[0108] When selecting new cluster centers, by calculating the minimum second distance, training boxes that are farther away can be used as new cluster centers in the future, thereby improving clustering efficiency.

[0109] S404. Determine the second probability based on the minimum second distance. The second probability is the probability that the third training box is selected as the cluster center.

[0110] The second probability is determined by the second distance. The second probability can be calculated using formula (4):

[0111]

[0112] In formula (4), X represents the set of multiple training boxes that were not selected as cluster centers (i.e., all third training boxes), x represents any one of the multiple training boxes that were not selected as cluster centers (i.e., the third training box), and D(x) min∑ represents the distance (i.e., the least second distance) from any training bounding box that was not selected as a cluster center to the nearest cluster center. x∈X D(x) min 2 Let P(x) represent the sum of squared distances from the nearest cluster center to each of the training boxes that were not selected as cluster centers, and let P(x) represent the second probability that a training box that was not selected as a cluster center is selected as a cluster center.

[0113] S405. Determine the Kth cluster center based on the second probability.

[0114] Repeat steps S401 to S405 to obtain all K cluster centers.

[0115] The minimum second distance can be obtained using the first and second indices, further improving computational efficiency. For example... Figure 3 As shown in Figure b, when selecting the third cluster center, we can first calculate the second distances from training boxes x2, x3, x5, and x6 to training box x4. Combined with the first index established in S203, we obtain the first distances from training boxes x2, x3, x5, and x6 to training box x1. Then, we minimize D(x) by finding the minimum value of the first distances from training boxes x2, x3, x5, and x6 to training box x1, and the minimum value of the second distances from training boxes x2, x3, x5, and x6 to training box x4. min As input to formula (4), the second probability of training boxes x2, x3, x5 and x6 being selected as cluster centers is calculated, and then the third cluster center is selected from training boxes x2, x3, x5 and x6 according to the second probability, which improves computational efficiency.

[0116] Specifically, the process of selecting the third cluster center from multiple training boxes that have not been selected as cluster centers is completed through a second probability selection, which makes the probability of the more distant third training box being selected as the third cluster center greater, thereby improving clustering efficiency.

[0117] By using S201 to S205 and S401 to S405, we can select K cluster centers, thus achieving the selection of all cluster centers. Next, we cluster multiple training boxes to obtain prior boxes.

[0118] Here, in order to further reduce redundant calculations in subsequent processes, the distance between the last cluster center (i.e. the Kth cluster center) obtained in S401 to S405 and the training boxes that were not selected as cluster centers can be calculated, and the distance between the last cluster center obtained in S401 to S405 and the training boxes that were not selected as cluster centers can be included in the second index, thereby further reducing redundant calculations in subsequent processes.

[0119] Figure 5 This is a flowchart illustrating the clustering process, such as... Figure 5 As shown, this includes S501 to S505. The following section provides a detailed explanation of S501 to S505 using specific examples.

[0120] S501. Determine the third distance, which is the distance between the fourth training box (excluding the K cluster centers) and the K-1 cluster centers, as well as the distance between the fourth training box and the Kth cluster center.

[0121] The fourth training box is any one of the training boxes in the training set other than the K cluster centers, that is, any one of the training boxes in the training set that has not been selected as a cluster center.

[0122] Specifically, the third distance is the distance of the fourth training box relative to any cluster center. Therefore, for the fourth training box, there are K third distances. The values ​​of the K third distances between the fourth training box and the K cluster centers can be quickly obtained using the first and second indices, thus improving computational efficiency.

[0123] Here, we can first obtain the first distance based on the first index established in S203, that is, we can obtain the first distance D between the nth training box and the first cluster center based on the first index number n1 established in S203. n1 Then, based on the first distance, the third distance between the fourth training box and the first cluster center is obtained, further reducing redundant calculations.

[0124] Optionally, since a second index has been established in S301 to S305 for the distances from the training boxes that were not selected as cluster centers to each cluster center (i.e., the K cluster centers), the third distance between the fourth training box and each cluster center can be obtained based on the second index, further reducing redundant calculations.

[0125] S502. Determine the minimum third distance, which is the minimum value of the third distance.

[0126] The clustering process involves grouping training boxes into multiple clusters based on their distances to different cluster centers. The fourth training box has K third distances relative to the K cluster centers. By determining the third distance with the smallest value among the K third distances (i.e., the minimum third distance), it becomes easier to cluster the fourth training box.

[0127] S503. Add the fourth training box to the first cluster group, and the minimum third distance corresponds to the first cluster group.

[0128] Here, the fourth training box is included in the first cluster group corresponding to the cluster center closest to the fourth training box, thereby obtaining K first cluster groups corresponding to K cluster centers, and completing the first clustering.

[0129] By calculating the minimum third distance to the fourth training box, we can determine the cluster center closest to the fourth training box, denoted as the third cluster center, and the minimum third distance corresponds to the third cluster center. Then, we can include the fourth training box in the first cluster group corresponding to the third cluster center. Repeating this process, we finally achieve the first cluster grouping of all training boxes except the cluster centers (i.e., all fourth training boxes).

[0130] S504. Determine the cluster center of the first cluster group. The cluster center of the first cluster group is the average value of the training box size in the first cluster group.

[0131] Here, the first cluster group is any one of multiple cluster groups. The cluster center can be represented as (w 1, h 1, Clustering grouping centers (w 1, h 1, ) represents the average size of training boxes with similar sizes in the cluster group center.

[0132] Through steps S501 to S504, multiple cluster groups and their respective cluster centers are obtained. Then, according to S501, the distances from the training boxes in each cluster group to their respective cluster centers are calculated. If the distances from the training boxes in the first cluster group to their respective cluster centers are less than or equal to the distances from the training boxes in the first cluster group to the centers of other cluster groups, then the first cluster group has completed clustering, and its cluster center is used as the final prior box. If the distances from the training boxes in the first cluster group to their respective cluster centers are greater than the distances from the training boxes in the first cluster group to the centers of other cluster groups, then the clustering of the training boxes in the first cluster group is not yet complete, and further clustering is needed to reassign the training boxes in the first cluster group to other cluster groups, thus completing the clustering process. The process of re-clustering the training boxes is explained in steps S505 to S507.

[0133] S505. Determine the fourth distance, which is the distance between the fifth training box (excluding the K cluster centers) and the K cluster group centers in the training boxes.

[0134] Here, since the first clustering of the fourth training box has already been completed in S502, resulting in K first cluster groups and calculating the cluster centers of these K groups, the fourth distance from the training boxes (excluding the K cluster centers) to each cluster center is calculated again. Based on this fourth distance, it is determined whether the training boxes need to be regrouped. Here, the training boxes in each cluster group can be denoted as the fifth training box. By calculating the fourth distance, it is possible to determine whether the distance between the training boxes in each cluster group and their respective cluster centers has reached its minimum value, thus allowing for further regrouping and improving the clustering effect.

[0135] S506. Determine the minimum fourth distance, which is the minimum value of the fourth distance.

[0136] Here, the minimum fourth distance corresponds to the cluster group in which the fifth training box should be included. Specifically, the fifth training box can be clustered again using the minimum fourth distance. If the fifth training box has already been grouped into the cluster group corresponding to the minimum fourth distance, then it does not need to be clustered again. If the fifth training box has not been grouped into the cluster group corresponding to the minimum fourth distance, then it needs to be clustered again.

[0137] S507. Add the fifth training box to the second cluster group, and the minimum fourth distance corresponds to the second cluster group.

[0138] By re-clustering the training boxes, they can be regrouped into the clusters corresponding to the nearest cluster centers. The fourth distance is the distance from the training box to the cluster centers of the K clusters. It is then determined whether the training box is closest to the cluster center of its own cluster. If not, the training box is regrouped into the cluster corresponding to the nearest cluster center, thus achieving a second clustering of the training boxes.

[0139] Repeat steps S505 through S507 until the clustering of the training boxes no longer changes.

[0140] Specifically, the determination that the grouping of training boxes no longer changes can be made by the following condition: If the cluster center of the second cluster group is determined, and the distance from the fifth training box to the cluster center of the second cluster group is the smallest of the K fourth distances of the fifth training box, then the fifth training box has completed clustering. Here, the cluster center of the second cluster group is the rectangle corresponding to the average size of the training boxes in the second cluster group.

[0141] Through the above steps, the final clustering results are obtained, and the cluster centers of the final clusters are used as the sizes of the final prior boxes. Then, the YOLOv5-based intrusion detection model is trained using these prior boxes, resulting in the trained YOLOv5-based intrusion detection model.

[0142] When training an intrusion detection model based on YOLOv5, the similarity between the detection boxes and the verification boxes in the verification image needs to be calculated to detect bounding boxes from the verification image. This similarity is the accuracy of the intrusion detection model's detection results.

[0143] The similarity between the detection bounding box and the verification bounding box in the verification image is calculated using a loss function. To improve the model training effect, a suitable loss function is needed to determine the model convergence condition. The following describes the loss function used in the training process of the YOLOv5-based intrusion detection model in the application embodiment.

[0144] Specifically, the intersection-over-union (IoU) ratio between the detection box and the verification box in the verification image can be calculated, and the distance between the detection box and the verification box in the verification image can be calculated based on the IoU ratio. Then, the distance between the detection box and the verification box in the verification image can be used as the loss function.

[0145] The Intersection over Union (IoU) is calculated as follows: First, align the detection box with the lower left corner of the verification box in the verification image, and then calculate the IoU. The IoU can be calculated using formula (5):

[0146]

[0147] In formula (5), A is the region of the detection box, B is the region of the validation box, A∩B represents the intersection region of the detection box A and the validation box B, and A∪B represents the region formed by the union of the detection box A and the validation box B.

[0148] It should be understood that in actual target detection tasks, detection box A is the region of the rectangular box of the detection result, and rectangular box B is the region of the rectangular box of the actual target.

[0149] When training an intrusion detection model based on YOLOv5, the calculation process of using the distance between the detection box and the verification box in the verification image as the loss function can be expressed by formula (6):

[0150] Loss iou =1-IoU (6)

[0151] In formula (6), IoU is the crossover-union ratio, which can be calculated using formula (5). iou It is the calculated value of the loss function.

[0152] Figure 6 Figure a shows a schematic diagram illustrating the calculation process of the intersection-union ratio (IU) of detection box A and validation box B. Figure 6 As shown in Figure a, the detection box is represented by rectangle A, and the validation box is represented by rectangle B. However, measuring the accuracy of the detection result solely based on the intersection-union ratio (IUGR) of detection boxes A and B does not consider the distance between detection boxes A and B, nor does it take into account the length and width of detection boxes A and B. Therefore, the loss function Loss iou It cannot accurately measure the similarity between detection box A and validation box B.

[0153] Additionally, if the detection box A and the validation box B have no intersection, then the loss function Loss iou The obtained value is a constant 0, and cannot measure the similarity between the detection box A and the validation box B.

[0154] To accurately calculate the case where the detection box A and the validation box B do not intersect, the minimum bounding rectangle can be used to measure the case where the detection box A and the validation box B do not intersect. Figure 6 This is a schematic diagram showing that the detection box A and the validation box B do not intersect, as shown below. Figure 6 As shown in Figure b, the detection box is represented by rectangle A, and the verification box is represented by rectangle B. Rectangle A c This is a schematic diagram of the minimum bounding rectangle of the detection box A and the validation box B. The minimum bounding rectangle A is shown below.c It is the smallest rectangle that encloses the detection box A and the verification box B.

[0155] By setting the minimum bounding rectangle A c For the loss function Loss iou With improvements, a loss function, Loss, can be obtained to measure the similarity between detection box A and validation box B. Giou Loss function Giou It can be expressed by formula (7):

[0156]

[0157] In formula (7), Loss Giou The loss function is the calculated value. IoU is the intersection-union ratio of the detection box A and the validation box B, calculated using formula (4). U is the area of ​​the union region of the detection box A and the validation box B. c It is the area of ​​the smallest bounding rectangle of the detection box A and the verification box B.

[0158] Through the loss function Loss Giou It can take into account the case where there is no intersection between the detection box A and the validation box B, and thus measure the similarity between the detection box A and the validation box B when there is no intersection, thereby improving the training effect of the model.

[0159] However, through the loss function Loss Giou When training the model, if there is an inclusion relationship between the detection box A and the validation box B, the loss function Loss iou and loss function Loss Giou Neither of them can measure the similarity between the result detection box A and the validation box B.

[0160] Figure 6 Figure c is a schematic diagram showing that the detection box A includes the verification box B, as shown below. Figure 6 As shown in Figure c, the detection box A includes the validation box B, and the loss function Loss Giou The similarity between detection box A and validation box B cannot be measured.

[0161] To solve the above problems, we combine the loss function Loss Giou By considering the distance between the center points of detection box A and validation box B, and also considering the length and width of the bounding boxes of detection box A and validation box B, the similarity between detection box A and validation box B is measured, resulting in the loss function Loss. ciou Among them, the loss function Loss ciou It can be calculated using formula (8):

[0162]

[0163] In formula (8), b is the center point of the detection box A. gt It is the center point of the validation box B, ρ(b, b) gt ρ is the distance between the center points of detection box A and validation box B. 2 (b,b gt ) is the square of the distance between the center points of the detection box A and the validation box B, and c is the minimum bounding rectangle A of the detection box A and the validation box B. c The length of the diagonal. Wherein, IoU is the intersection-union ratio, which can be calculated by formula (4).

[0164] In formula (7), v is the similarity of the aspect ratio between the detection box A and the validation box B, and v is calculated using formula (9):

[0165]

[0166] In formula (9), w is the width of the detection box A, h is the height of the detection box A, and w gt It is the width of the validation box B, h gt It is the height of the validation box B.

[0167] Using the loss function Loss ciou It takes into account various factors of the detection box A and the validation box B, and uses the loss function Loss ciou Once the model is trained, the trained YOLOv5-based intrusion detection model can be used to detect intruders.

[0168] Specifically, when intrusion is detected, the detection results are saved in the database. Table 4 shows the content of the stored detection results in the database. As shown in Table 2, the specific content stored in the database is as follows:

[0169] Table 2

[0170] ID people detector warning_info type time 1 1 JK1 JK1 found 1 person 1 20220325 2 6 JK2 JK2 discovered 6 people 2 20220325 3 10 JK3 JK3 discovered 10 people 3 20220326

[0171] In Table 2, ID is the detection result number, people is the number of people detected, detector is the camera number, warning_info is the detailed information of the detection result, type is the alarm level, and time is the alarm time.

[0172] When it is necessary to store specific content in the database, the backend retrieves the detection result data from the database, and the frontend displays the detection result data in real time. At the same time, alarm information is displayed on the frontend, thus achieving the goal of obtaining and displaying the detection results in real time, thereby improving the monitoring effect.

[0173] This application also provides an apparatus comprising units or modules for performing the steps described in the various method embodiments above. Figure 7 This is a schematic diagram of a device provided in an embodiment of this application, such as... Figure 7 As shown, the apparatus 700 includes a processing unit 710, a storage unit 720, and a transceiver unit 730. The processing unit 710 is used to process data and train a YOLOv5-based intrusion detection model. The storage unit 720 is used to store the YOLOv5-based intrusion detection model. The transceiver unit 730 is used to transmit data. The apparatus described in this embodiment can improve the training efficiency of the YOLOv5-based intrusion detection model.

[0174] This application also provides an apparatus comprising: at least one processor, a memory, and a computer program stored in the memory and executable on the at least one processor, wherein the processor executes the computer program to implement the methods described in this application.

[0175] It should be noted that the information interaction and execution process between the above-mentioned devices / units are based on the same concept as the method embodiments of this application. For details on their specific functions and technical effects, please refer to the method embodiments section, and they will not be repeated here.

[0176] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0177] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps described in the various method embodiments above.

[0178] This application provides a computer program product that, when run on a mobile terminal, enables the mobile terminal to implement the steps described in the above-described method embodiments.

[0179] This application also provides an intrusion detection method that can use the artificial intelligence model trained by the YOLOv5-based intrusion detection model training method provided in this application to perform personnel intrusion detection, thereby improving the effectiveness of personnel intrusion detection.

[0180] This application also provides an intrusion detection device that can perform personnel intrusion detection using the intrusion detection method described above in this application, thereby improving the effectiveness of personnel intrusion detection.

[0181] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments of this application can be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include at least: any entity or device capable of carrying computer program code to a photographing device / terminal device, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium. Examples include USB flash drives, portable hard drives, magnetic disks, or optical disks. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electrical carrier signals or telecommunication signals.

[0182] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0183] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0184] In the embodiments provided in this application, it should be understood that the disclosed apparatus / network devices and methods can be implemented in other ways. For example, the apparatus / network device embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

[0185] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0186] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.

Claims

1. A training method for an intrusion detection model based on YOLOv5, characterized in that, The method includes: Construct a training set and a validation set. The training set includes multiple training images and multiple training bounding boxes. The validation set includes multiple validation images and multiple validation bounding boxes. The multiple training bounding boxes are used to mark target personnel in the multiple training images. The multiple validation bounding boxes are used to mark target personnel in the multiple validation images. K cluster centers are determined using an index among the plurality of training boxes, the index indicating the distance between different training boxes. The process includes: designating a first training box as the first cluster center, where the first training box is any one of the plurality of training boxes; determining a first distance, which is the distance between a second training box and the first cluster center, where the second training box is any one of the plurality of training boxes other than the first training box; establishing a first index, which indicates the first distance; determining a first probability that the second training box is selected as a cluster center based on the first distance; and determining the second cluster center according to the first probability. Wherein, when establishing the first index, for the nth training box, the first distance between the nth training box and the first cluster center is... The corresponding first index number is According to the first index number Obtain the first distance between the nth training box and the first cluster center. The process involves: determining a second distance, where the second distance is the distance between the third training box and K-1 cluster centers, and the third training box is any training box among the training boxes excluding the K-1 cluster centers; establishing a second index to indicate the second distance; determining a minimum second distance, where the minimum second distance is the minimum value of the second distance; determining a second probability based on the minimum second distance, where the second probability is the probability that the third training box is selected as a cluster center; determining the Kth cluster center according to the second probability; wherein, the distance from the training box not selected as a cluster center to each cluster center is calculated, and the distance from the training box not selected as a cluster center to each cluster center is used as the second distance; wherein, the third training box is any training box among the training boxes excluding the K-1 cluster centers; K is greater than 2, and the minimum second distance is obtained through the first index and the second index; Based on the K cluster centers, the multiple training boxes are clustered to obtain K cluster groups; K prior boxes are determined based on the K clustering groups; The intrusion detection model based on YOLOv5 is trained on the training set and the validation set using the K prior boxes until convergence. Where K is greater than 1.

2. The method as described in claim 1, characterized in that, The process of clustering the multiple training boxes based on the K cluster centers to obtain K cluster groups includes: A third distance is determined, which is the distance between the fourth training box (excluding the K cluster centers) and the K-1 cluster centers, and the distance between the fourth training box and the Kth cluster center. Determine the minimum third distance, where the minimum third distance is the minimum value of the third distance; The fourth training box is included in the first cluster group, and the minimum third distance corresponds to the first cluster group; The minimum third distance is obtained through the first index and the second index.

3. The method as described in claim 2, characterized in that, Also includes: Determine the cluster center of the first cluster group, where the cluster center of the first cluster group corresponds to the average value of the training box size in the first cluster group; Determine a fourth distance, which is the distance between a fifth training box (excluding the K cluster centers) and the K cluster grouping centers within the plurality of training boxes; Determine the minimum fourth distance, where the minimum fourth distance is the minimum value of the fourth distance; The fifth training box is included in the second cluster group, and the minimum fourth distance corresponds to the second cluster group.

4. The method as described in claim 1, characterized in that, The step of determining K prior boxes based on the K cluster groups includes: Determine the average size of multiple training boxes in the first cluster group of the K cluster groups, and use the average size of multiple training boxes in the first cluster group as the size of the first prior box.

5. The method as described in claim 1, characterized in that, The step of training a YOLOv5-based intrusion detection model to convergence using the K prior boxes on the training and validation sets includes: The first verification image is detected using the YOLOv5-based intrusion detection model to obtain a first detection box, wherein the first verification image includes the first verification box. Using loss function Train the intrusion detection model based on YOLOv5 until convergence; Wherein, the loss function Calculated using the following formula: Where A is the region of the first detection box, and B is the region of the first verification box. It is the center point of the first detection frame. It is the center point of the first verification box. is the distance between the center points of the first detection box and the first verification box, and c is the diagonal length of the smallest bounding rectangle of the first detection box and the first verification box. It is the width of the first detection frame. It is the height of the first detection frame. It is the width of the first verification box. It is the height of the first verification box.

6. An apparatus, characterized in that, Includes a unit for performing the method as described in any one of claims 1 to 5.

7. An apparatus comprising: At least one processor, a memory, and a computer program stored in the memory and executable on the at least one processor, characterized in that the processor, when executing the computer program, implements the method according to any one of claims 1 to 5.

8. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Self-adapting preferred fuzzy kernel clustering based naphtha attribute clustering method

    CN103235894A

  • Student classroom behavior detection method, system and terminal based on deep learning

    CN114359606A