A production safety anomaly identification method and device, electronic equipment and storage medium
By dividing production videos into video frame packets with a fixed number of frames and using a self-attention mechanism model, the problem of difficulty in identifying various production safety anomalies when computing resources are limited in existing technologies is solved, achieving efficient and low-power anomaly identification and reducing the false positive rate.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA ACAD OF SAFETY SCI & TECH
- Filing Date
- 2022-09-15
- Publication Date
- 2026-04-28
AI Technical Summary
Existing technologies struggle to identify multiple production safety anomalies simultaneously with limited computing resources, and they also have difficulty identifying abnormal behaviors over time, which can easily lead to misjudgments or missed judgments.
The production video is divided into a fixed number of video frame packets, and a pre-trained production safety anomaly identification model is used for identification. The spatiotemporal separation self-attention mechanism model is combined for feature extraction and identification, and the false positive rate is reduced by temporal smoothing.
It reduces the consumption of computing resources, lowers computing power and power consumption, can cover all abnormal production safety scenarios, reduces the possibility of false positives and false negatives, and improves the accuracy of identification.
Smart Images

Figure CN115565101B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of deep learning technology, and in particular to a method, apparatus, electronic device, and storage medium for identifying production safety anomalies. Background Technology
[0002] The use of artificial intelligence technology to monitor abnormal environments or behaviors in the field of production safety through video recognition has gradually become widespread. The current method of production safety anomaly identification is to identify specific targets by using pre-trained specific models, such as open flame identification models, smoke identification models, and helmet-wearing identification models, to identify specific abnormal targets.
[0003] In current technical solutions, if multiple abnormal targets are identified through the same camera, more computing resources and a large number of anomaly recognition models need to be stacked on the analysis and processing server or edge computing device. Each recognition model requires a large amount of system resources (10-50G MACs). With limited computing resources and memory, a hardware system can only support a limited number of models. Therefore, with a fixed number of connected cameras, the abnormal targets identified by each camera in the existing technical solution are of a fixed type and limited, making it difficult to identify all abnormal targets in different scenarios with limited computing resources. In addition, the existing technical solution identifies abnormal behaviors in production safety by extracting a frame from the video, which is difficult to identify in the time dimension and may easily lead to misjudgment or missed judgment of production safety anomalies. Summary of the Invention
[0004] This invention provides a method, apparatus, electronic device, and storage medium for identifying production safety anomalies, in order to save computing power and power consumption of the production safety anomaly identification device and reduce the complexity of training set labeling.
[0005] According to one aspect of the present invention, a method for identifying production safety anomalies is provided, comprising:
[0006] Obtain production videos;
[0007] The production video is divided into several video frame packets with a preset first number of frames;
[0008] The video frame packet is input into a pre-trained production safety anomaly identification model to obtain the production identification result corresponding to the video frame packet.
[0009] According to another aspect of the present invention, a production safety anomaly detection device is provided, comprising:
[0010] The production video acquisition module is used to acquire production videos;
[0011] A video frame packet segmentation module is used to segment the production video into several video frame packets with a preset first number of frames.
[0012] The production identification result generation module is used to input the video frame packet into a pre-trained production safety anomaly identification model to obtain the production identification result corresponding to the video frame packet.
[0013] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0014] At least one processor; and
[0015] A memory communicatively connected to the at least one processor; wherein,
[0016] The memory stores a computer program that can be executed by the at least one processor, which enables the at least one processor to perform the production safety anomaly identification method according to any embodiment of the present invention.
[0017] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions for causing a processor to execute and implement the production safety anomaly identification method according to any embodiment of the present invention.
[0018] The technical solution of this invention involves acquiring a production video; dividing the production video into several video frame packets with a preset first number of frames; and inputting the video frame packets into a pre-trained production safety anomaly identification model to obtain the production identification result corresponding to the video frame packets. By dividing the video into video frame packets with a fixed number of frames, this invention can reduce the computing power and power consumption in the process of identifying production safety anomalies. Furthermore, this invention only requires the deployment of a single production safety anomaly identification model, reducing the computing resources occupied, and can cover all production safety anomaly scenarios, reducing the possibility of false positives and false negatives.
[0019] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description
[0020] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1A This is a flowchart of a production safety anomaly identification method provided in Embodiment 1 of the present invention;
[0022] Figure 1B This is a flowchart of a production safety anomaly identification method applicable to Embodiment 1 of the present invention;
[0023] Figure 2 This is a flowchart of a training method for a production safety anomaly identification model provided in Embodiment 2 of the present invention;
[0024] Figure 3 This is a schematic diagram of a production safety anomaly identification device according to Embodiment 3 of the present invention;
[0025] Figure 4 This is a schematic diagram of the structure of an electronic device that implements the production safety anomaly identification method of this invention. Detailed Implementation
[0026] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0027] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0028] Example 1
[0029] Figure 1AThis is a flowchart of a production safety anomaly identification method provided in Embodiment 1 of the present invention. This embodiment is applicable to situations where the computing power and power consumption of the production safety anomaly identification device are reduced, and the complexity of training set labeling is decreased. This method can be executed by a production safety anomaly identification device, which can be implemented in hardware and / or software, and can be configured in a computer or server. Figure 1A As shown, the method includes:
[0030] S101. Obtain production video.
[0031] In typical production safety monitoring scenarios, multiple camera devices are deployed to continuously monitor and generate a large amount of production video. This large volume of video footage is then used for subsequent identification of production safety anomalies.
[0032] The present invention provides only examples of the methods and intervals for acquiring production videos, and does not limit them. In some embodiments of the present invention, production videos can be acquired at preset intervals or continuously.
[0033] S102. Divide the production video into several video frame packets with a preset first number of frames.
[0034] Abnormal production safety behaviors include at least the following: open flames, smoke, object removal detection, abnormal placement of fire extinguishers, climbing over fences, touching anti-static balls, traffic congestion, running, raising hands for help, someone carrying a knife, not wearing a safety helmet, etc. Since some abnormal production safety behaviors occur within a short period of time, such as raising hands for help, climbing over fences, and traffic congestion, it is necessary to analyze these behaviors within a certain time frame to determine whether they constitute abnormal production safety behaviors. Therefore, it is necessary to identify abnormal production safety behaviors in both spatial and temporal dimensions.
[0035] The acquired production video is divided into several equal-length video frame packets, each containing a pre-set number of consecutive video images. Dividing the video frame packets into equal-length packets facilitates subsequent input into a pre-trained production safety anomaly recognition model for identifying abnormal production safety behaviors.
[0036] For example, a production video is divided into several video frame packets with a frame count of 32 frames each.
[0037] It should be noted that the specific number of frames in the video frame packet in the embodiments of the present invention is only an example and is not limited. In other embodiments of the present invention, the first number of video frame packets can be adjusted according to the actual situation and the usage of computing resources.
[0038] S103. Input the video frame packet into the pre-trained production safety anomaly identification model to obtain the production identification result corresponding to the video frame packet.
[0039] The production safety anomaly identification model is used to identify abnormal production safety behaviors in production videos. This production safety anomaly identification model can identify a variety of abnormal production safety behaviors, reduce the occupation of system resources, reduce the use of computing resources, and reduce the computing power and consumption in the process of identifying production safety anomalies.
[0040] Several video frame packets of fixed length are sequentially input into a pre-trained production safety anomaly recognition model to obtain the production recognition result corresponding to each video frame packet.
[0041] For example, a video frame packet with 32 frames is input into a pre-trained production safety anomaly recognition model to obtain the production recognition result corresponding to the video frame packet. The recognition result includes whether the video frame packet indicates normal production or production anomaly and the corresponding probability value.
[0042] It should be noted that the embodiments of the present invention provide only examples of how to train the production safety anomaly identification model and the specific structure of the production safety anomaly identification model, and do not limit the scope of the invention.
[0043] Because the algorithm may be unstable during the identification of production safety anomalies, false alarms may occur. Therefore, it is necessary to try to avoid false alarms. Figure 1B This is a flowchart of a production safety anomaly identification method applicable to Embodiment 1 of the present invention, as shown in Figure 1B. In some embodiments of the present invention, the production safety anomaly identification method further includes:
[0044] S104. Obtain the production recognition results corresponding to the preset second number of video frame packets.
[0045] Obtain the production recognition results corresponding to a pre-set second number of video frame packets, and use them to perform time smoothing on the production recognition results to increase the accuracy of the final production recognition results.
[0046] For example, the production recognition results corresponding to 11 consecutive video frame packets are used for time smoothing.
[0047] It should be noted that the production identification results corresponding to 11 video frame packets in this embodiment of the invention are exemplary illustrations of this invention. In other embodiments of the invention, other numbers of video frame packets may be used. This embodiment of the invention is only an example and is not intended to limit the scope.
[0048] S105. Extract the abnormal probability corresponding to the preset second number of production identification results.
[0049] From the second number of production identification results, the probability value corresponding to the production identification result being a production anomaly is extracted as the anomaly probability, thus obtaining the second number of anomaly probabilities.
[0050] The example provided in this embodiment of the invention, which extracts the abnormal probability corresponding to a preset second number of production identification results, is merely illustrative and not intended to limit the scope of the invention.
[0051] S106. Calculate the average of the pre-set second number of abnormal probabilities.
[0052] Calculate the average of the second number of abnormal probability values, and use this average as the production identification result after time-smooth classification.
[0053] S107. Determine whether the average value is greater than the preset abnormal threshold; if the average value is greater than the preset abnormal threshold, then execute S108.
[0054] S108. Generate a production safety anomaly warning and send the warning to the staff.
[0055] The abnormal threshold is a critical value for judging whether a production safety abnormality has occurred. The average value after time smoothing is compared with the preset abnormal threshold to determine whether the average value is greater than the preset abnormal threshold. If the average value after time smoothing is still greater than the preset abnormal threshold, it means that a production safety abnormality has indeed occurred. Execute S108 to generate a production safety abnormality warning and send the warning to the staff.
[0056] For example, the average value is compared with 50%, and if the average value is greater than 50%, then S108 is executed to generate a production safety anomaly warning.
[0057] By applying event smoothing to multiple classification probabilities, the accuracy of production identification results can be further improved, and the possibility of false alarms can be reduced.
[0058] The abnormal thresholds described in this embodiment are merely examples and are not intended to be limiting.
[0059] The technical solution of this invention involves acquiring a production video; dividing the production video into several video frame packets with a preset first number of frames; and inputting the video frame packets into a pre-trained production safety anomaly identification model to obtain the production identification result corresponding to the video frame packets. By dividing the video into video frame packets with a fixed number of frames, this invention can reduce the computing power and power consumption in the process of identifying production safety anomalies. Furthermore, this invention only requires the deployment of a single production safety anomaly identification model, reducing the computing resources occupied, and can cover all production safety anomaly scenarios, reducing the possibility of false positives and false negatives.
[0060] Example 2
[0061] Figure 2 This is a flowchart of a production safety anomaly identification method provided in Embodiment 2 of the present invention. Figure 2 This is a flowchart of a production safety anomaly identification model training method provided in Embodiment 2 of the present invention. This embodiment is a supplement to the above embodiments, such as... Figure 2 As shown, the method includes:
[0062] S201. Select several videos from the sample library as sample videos.
[0063] The sample library contains a large set of videos pre-stored for training the production safety anomaly identification model. Several videos are randomly selected from the sample library as sample videos for training.
[0064] The specific sample videos used in this embodiment of the invention are merely examples and are not intended to be limiting.
[0065] S202. Divide the sample video into several sample video frame packets with a preset number of frames.
[0066] The sample video is divided into several sample video frame packets with the same number of frames, which is the first number of frames, for use in training the initial production safety anomaly identification model.
[0067] In some embodiments of the present invention, S202 includes:
[0068] S2021. Divide the sample video into several sample video frame packets with a preset first number of frames.
[0069] S2022, Cut the images in the sample video frame packet into a preset third number of image patches.
[0070] The images in the sample video frame packet are segmented to obtain a preset third number of image patches, which are used as multiple features extracted from the sample video frame packet.
[0071] For example, each sample video frame packet contains 32 frames of images, each frame being H×W in size. The images are then divided into P×P image patches, each patch being H / P×W / P in size.
[0072] It should be noted that the third number of image segments and the specific segmentation method in the embodiments of the present invention are merely examples and are not intended to limit the scope.
[0073] S2023. Establish a location vector to store the location information of image patches in the sample video frame packet, where the formula for the location vector is:
[0074]
[0075] Where p represents the spatial location information of the image patch, t represents the temporal location information of the image patch, pos represents the position of the image patch in the sample video frame packet, and R... D All image patches for the sample video frame packet.
[0076] A location vector is established to store the location information of multiple image patches in the sample video frame packet. A spatiotemporal separation self-attention mechanism is used to extract features from each frame image, extracting the spatial location information of all image patches related to a certain image patch in space, as well as the temporal location information of the image patch at different times in the same space. This preserves both the temporal and spatial information of the image patch and reduces computational consumption.
[0077] S203. The sample video frame packet containing abnormal production segments is regarded as an abnormal production sample.
[0078] Since a production anomaly video frame packet contains both normal production segments and anomaly production segments, while a normal production video frame packet contains only normal production segments, a sample video frame packet containing anomaly production segments is considered a production anomaly sample.
[0079] S204. Sample video frame packets that do not contain abnormal production segments are treated as normal production samples.
[0080] Sample video frame packets that do not contain abnormal production segments are classified as normal production samples.
[0081] Annotating video frame packets as a whole can save time and improve annotation efficiency.
[0082] S205. Use normal production samples and abnormal production samples to train the self-attention mechanism model to obtain the production safety anomaly identification model.
[0083] The essence of the self-attention mechanism model is to find the correlation between existing data and then highlight certain important features.
[0084] Specifically, embodiments of this invention use a Transformer model based on a spatiotemporal separation self-attention mechanism as the initial self-attention mechanism model. To extract higher-quality features, some embodiments of this invention use the open-source ImageNet and Kinetics datasets to pre-train the Transformer self-attention mechanism. This invention uses a spatiotemporal separation self-attention mechanism to extract features, achieving higher accuracy than existing technologies using CNN models, and also reducing computational consumption to some extent.
[0085] The self-attention mechanism model is trained using image patches extracted from both real-labeled normal and abnormal production samples. Through continuous training, the loss function converges, resulting in a production safety anomaly identification model capable of recognizing abnormal production behaviors in different production scenarios. Weakly supervised learning reduces the workload of sample labeling.
[0086] It should be noted that in some embodiments of the present invention, other models can also be used as self-attention mechanism models. The embodiments of the present invention are only examples and are not intended to limit the scope.
[0087] Furthermore, the abnormal production segment in the embodiments of the present invention can be a series of consecutive abnormal production images or a single abnormal production image. The embodiments of the present invention are merely examples and are not intended to limit the scope.
[0088] In some embodiments of the present invention, S205 includes:
[0089] S2051. Based on the location information of image patches, sample tensors from normal and abnormal production samples are extracted using a feature extraction structure. The formula for the feature extraction structure is as follows:
[0090]
[0091] in, Let E be the tensor corresponding to a certain image patch, and let E be the weight parameter. (p,t) The input image patch vector, This is the position vector of the image patch.
[0092] The weight parameter E is displayed as a randomly generated value. Several image patches are input into the feature extraction structure, and the corresponding tensors are calculated through the feature extraction structure.
[0093] During the training of the production safety anomaly identification model, the weight parameter E also changes continuously, and then gradually stabilizes.
[0094] It should be noted that the formulas for specific feature extraction structures in the embodiments of the present invention are merely examples and are not intended to limit the scope. Other feature extraction structures can also be used to extract sample tensors in other embodiments of the present invention.
[0095] Furthermore, the embodiments of the present invention do not limit the specific method of how to gradually stabilize the weight parameter E.
[0096] S2052. Input the sample tensor into the self-attention mechanism model for training to obtain the production result tensor.
[0097] The self-attention mechanism model contains several encoder layers, each containing several feature vectors to extract features from each patch.
[0098] The sample tensors are input into the self-attention mechanism model for training, resulting in several production result tensors after passing through several layers of encoders.
[0099] It should be noted that the specific structure of the self-attention mechanism model is an exemplary illustration of the embodiments of the present invention. Depending on the actual function and purpose, there may be other structures of the self-attention mechanism model in other embodiments of the present invention. The embodiments of the present invention are only examples and are not intended to limit the scope.
[0100] In some embodiments of the present invention, S2052 includes:
[0101] S521. Set the feature vectors of an encoder with several layers, where the feature vectors are used to extract features from image patches. The specific formula for the feature vectors is:
[0102]
[0103]
[0104]
[0105] Where l represents the encoder of the l-th layer, a is the a-th head of the multi-head attention mechanism, p is the spatial location information of the image patch, t is the temporal location information of the image patch, and W Q W K W V Let L be the weight matrix, and LN be the layer normalization function. The total extent of the potential feature space dimensions for each attention head.
[0106] The three feature vectors are used to extract features from each image patch. Each encoder layer contains these three feature vectors. Used to query the relationship between itself and other inputs; Used to find the relationship between other inputs and itself. Represents input features, used for... and The weights are linearly combined.
[0107] Using sample tensors to analyze W Q W K W V The weight matrix is trained and redefined.
[0108] The self-attention mechanism model used in this invention combines multi-head attention, which selects multiple sets of production information in parallel from the sample tensor through multiple query-corresponding feature vectors. Each attention head focuses on different production safety parts in the sample tensor, so that the production safety anomaly identification model can be more accurate and more easily identify different types of production safety anomalies.
[0109] It should be noted that the feature vectors of encoders with several layers in this embodiment of the invention are merely examples and are not intended to be limiting.
[0110] S522. Calculate the self-attention weights based on the feature vectors using the following formula:
[0111]
[0112] Where SM is the softmax activation function. Let F be the total range of the potential feature space dimensions for each attention head, where F is the first quantity and N is the third quantity.
[0113] Based on the values of the three feature vectors obtained from training, the self-attention weights corresponding to the image patch with current spatial location information p and temporal location information t are calculated in the l-th layer encoder a-th attention head of the self-attention mechanism model. This can both normalize the data and increase the differences between the data, thereby increasing attention and thus increasing the differentiation in the generation of security anomalies.
[0114] Wherein, the first quantity F is the number of frames in the sample video frame packet, and the third quantity is the total number of image patches in a single image.
[0115] It should be noted that the formula for calculating self-attention weights in the embodiments of the present invention is only an example and is not limited. In other embodiments of the present invention, other calculation formulas may be used.
[0116] S523. The production result tensor is calculated based on the self-attention weights using the following formula:
[0117]
[0118] Where p' = 1…N, t' = 1…F.
[0119] The obtained self-attention weights and sample tensors A weighted summation is performed to obtain the final production result tensor, which is generated after passing through the l-layer encoding layer of the self-attention mechanism model. This production result tensor represents the production safety self-attention output result corresponding to the image patch with a certain temporal and spatial location information in each sample video frame packet.
[0120] S2053. Use the first multilayer perceptron to classify the production result tensor to obtain the production training result.
[0121] A multilayer perceptron (MLP) is a feedforward artificial neural network model that maps multiple input datasets to a single output dataset.
[0122] The production result tensor is input into the first multilayer perceptron. The first multilayer perceptron classifies the production result tensor to determine the final classification tensor that can represent the production training result, which is then used as the production training result.
[0123] It should be noted that the specific structure of the first sensor and the specific classification method of the production result tensor in the embodiments of the present invention are only examples and are not limited.
[0124] In some embodiments of the present invention, S2053 includes:
[0125] S531. Input the production result tensor into the first multilayer perceptron, and obtain the training production tensor using the following formula:
[0126]
[0127]
[0128] Among them, W O It is the output layer function. For the production result components, To train the production tensor, MLP is the first multilayer perceptron function, and LN is the layer normalization function.
[0129] Output layer function W O Located in the perception layer, it is used to integrate the production safety self-attention output results corresponding to the image patches representing all temporal and spatial location information in each sample video frame packet.
[0130] Through the output layer function W O The information of multiple production result components obtained from multiple attention heads is merged to obtain multiple training production tensors in each layer encoder, and the training production tensor integrates the training results corresponding to multiple attention heads.
[0131] The training production video tensor can contain the temporal and spatial information of the production process contained in an entire video frame packet.
[0132] S532, Extract the training production tensor from The production training result is the image patch corresponding to the image patch with spatial location information p” and temporal location information t” in the video frame packet.
[0133] Extract tensors from several training production tensors that can be used to determine whether an image patch in a video frame packet has a production safety anomaly at a certain moment. This represents the production training result corresponding to an image patch with spatial location information p” in a video frame packet at temporal location information t”.
[0134] Where p” is in the range of 1…N, representing the position of all image patches in the video frame packet, and t” is in the range of 1…F, representing the range of the number of frames in the video frame packet.
[0135] For example, in the training production tensor that fully represents a video frame packet Extract The image patch at position 0 represents the production training result at time 0 of the video frame packet.
[0136] It should be noted that the extraction method used in the embodiments of the present invention is as follows. As the production training result is used as an example, other tensors can also be used as the production training result in other embodiments of the present invention. The embodiments of the present invention are only examples and are not limited.
[0137] S2054. Based on normal production samples, abnormal production samples, and production training results, calculate the classification loss of the self-attention mechanism, where the classification loss represents the difference between the sample video frame packets and the production training results.
[0138] During the training of the self-attention mechanism model, it is necessary to evaluate the training effect. Therefore, a classification loss is introduced to evaluate the training effect of the self-attention mechanism model. Specifically, the classification loss is the difference between the video annotation value of the sample video frame packet and the probability of the production safety anomaly predicted by the model trained through the self-attention mechanism. This difference is calculated based on the training results from the sample video frame packet.
[0139] The embodiments of the present invention do not limit how to calculate the classification loss of the self-attention mechanism model.
[0140] In some embodiments of the present invention, S2054 includes:
[0141] S541. Input the production training results into the second multilayer perceptron to calculate the binary classification loss function value of the self-attention mechanism model. The formula for the second multilayer perceptron is:
[0142]
[0143] in, For production training results, LN is the layer normalization function.
[0144] The second multilayer perceptron is a multilayer perceptron with only one hidden layer. The production training results obtained from the sample tensor are input into the second multilayer perceptron to calculate the binary classification loss function value of the self-attention mechanism model.
[0145] For example, if the calculated binary classification loss function value is less than 0.3, it indicates that the self-attention mechanism model has identified normal production safety; if the calculated binary classification loss function value is greater than 0.7, it indicates that the self-attention mechanism model has identified abnormal production safety; if the calculated binary classification loss function value is less than 0.7 and greater than 0.3, it indicates that the self-attention mechanism model has poor recognition performance.
[0146] It should be noted that the specific structure of the second multilayer sensor in the embodiments of the present invention is an exemplary description of the embodiments of the present invention. In other embodiments of the present invention, the second multilayer sensor may have other structures. The embodiments of the present invention are only examples and are not intended to limit the scope.
[0147] Furthermore, the specific numerical range of the binary classification loss function and the corresponding recognition effect in the embodiments of the present invention are merely examples and are not limited thereto.
[0148] S542. Calculate the difference between the binary classification loss function value and the labeled value of the sample video frame packet as the classification loss, where the labeled value is whether the sample video frame packet is a normal production sample or an abnormal production sample.
[0149] Specifically, if a sample video frame is a normal production sample, its corresponding label value is 0; if a sample video frame is an abnormal production sample, its corresponding label value is 1. Based on the binary classification loss function value calculated by the second multilayer perceptron, the standard deviation between the binary classification loss function and the pre-labeled sample video frame values is calculated and used as the classification loss value of this self-attention mechanism model.
[0150] The classification loss is used to determine whether the current binary classification loss function value has converged to the labeled value, in order to further determine the recognition result of the self-attention mechanism model.
[0151] It should be noted that, in the embodiments of the present invention, the difference between the binary classification loss function and the labeled value of the pre-labeled sample video frame packet is calculated as the classification loss value of the self-attention mechanism model. This is an exemplary illustration of the embodiments of the present invention. In other embodiments of the present invention, other loss functions may also be used as a reference for judging the recognition effect of the self-attention mechanism. The present invention is only an example and is not limited.
[0152] S2055. Determine whether the classification loss is less than the preset convergence threshold. If the classification loss is less than the preset convergence threshold, execute S2055. If the classification loss is greater than the preset convergence threshold, return to execute S2052.
[0153] S2056. Use the self-attention mechanism model as the trained production safety anomaly identification model.
[0154] The convergence threshold is used to determine the training progress of the self-attention mechanism model. If the calculated classification loss is less than the preset convergence threshold, it means that the current self-attention mechanism model can accurately identify whether a video frame packet has a production safety anomaly. In this case, the current self-attention mechanism model is used as a trained production safety anomaly recognition model, so that it can be directly used to identify abnormal production safety behaviors in the actual production safety anomaly recognition process. If the calculated classification loss is greater than the preset convergence threshold, it means that the recognition effect of the current self-attention mechanism model is poor, and it is necessary to return to S2052 to continue training.
[0155] For example, with a preset convergence threshold of 50%, if the classification loss of the self-attention mechanism model is less than 50%, then the self-attention mechanism model is used as the trained production safety anomaly identification model.
[0156] It should be noted that the specific values of the convergence thresholds in the embodiments of the present invention are merely examples and are not intended to limit the scope. In some embodiments of the present invention, other convergence thresholds may be set to adjust the accuracy of the production safety anomaly identification model. The embodiments of the present invention are merely examples and are not intended to limit the scope.
[0157] In this embodiment of the invention, several videos are selected from a sample library as sample videos; the sample videos are divided into several sample video frame packets with a preset first number of frames; sample video frame packets containing abnormal production segments are designated as abnormal production samples; sample video frame packets without abnormal production segments are designated as normal production samples; a self-attention mechanism model is trained using normal production samples and abnormal production samples to obtain a production safety anomaly identification model; this embodiment of the invention uses a spatiotemporal self-attention mechanism model to improve the accuracy of feature extraction and can reduce computing power and power consumption to a certain extent; at the same time, dividing the sample videos into several video frame packets and labeling the video frame packets for weakly supervised learning reduces the time cost of the labeling process, and the trained model can identify production safety anomalies that occur over a period of time.
[0158] Example 3
[0159] Figure 3 This is a schematic diagram of a production safety anomaly identification device provided in Embodiment 3 of the present invention. Figure 3 As shown, the device includes:
[0160] Production video acquisition module 301 is used to acquire production videos;
[0161] The video frame packet segmentation module 302 is used to segment the production video into several video frame packets with a preset first number of frames.
[0162] The production identification result generation module 303 is used to input video frame packets into a pre-trained production safety anomaly identification model to obtain the production identification result corresponding to the video frame packets.
[0163] Optionally, the production safety anomaly detection device may also include:
[0164] The production identification result acquisition module 304 is used to acquire the production identification results corresponding to a preset second number of video frame packets;
[0165] The anomaly probability extraction module 305 extracts the anomaly probability corresponding to the preset second number of production identification results;
[0166] The average value calculation module 306 is used to calculate the average value of the preset second number of abnormal probabilities;
[0167] An abnormal threshold comparison module 307 is used to determine whether the average value is greater than a preset abnormal threshold.
[0168] The production safety anomaly warning module 308 is used to generate production safety anomaly warnings and send the production safety anomaly warnings to the staff.
[0169] Optional, the production safety anomaly identification model training module includes:
[0170] The sample video selection submodule is used to select several videos from the sample library as sample videos;
[0171] The sample video frame packet division submodule is used to divide the sample video into a number of sample video frame packets, where the number of frames is a preset first number.
[0172] The production anomaly sample selection submodule is used to select the sample video frame packet containing the anomaly production segment as the production anomaly sample.
[0173] The normal production sample selection submodule is used to select the sample video frame packets that do not contain the abnormal production segments as normal production samples.
[0174] The self-attention mechanism model training submodule is used to train the self-attention mechanism model using the normal production samples and the abnormal production samples to obtain the production safety anomaly identification model.
[0175] Optionally, the sample video frame packet partitioning submodule includes:
[0176] The sample video frame packet division unit is used to divide the sample video into a number of sample video frame packets with a preset number of frames.
[0177] The image patch cutting unit is used to cut the images in the sample video frame packet into a preset third number of image patches;
[0178] A position vector establishment unit is used to establish position vectors to store the position information of the image patches in the sample video frame packet, wherein the formula for the position vector is:
[0179]
[0180] Where p represents the spatial location information of the image patch, t represents the temporal location information of the image patch, pos represents the position of the image patch within the sample video frame packet, and R... D For all image patches of the sample video frame packet.
[0181] Optionally, the self-attention mechanism model training submodule includes:
[0182] The sample tensor extraction unit is used to extract sample tensors from the normal production samples and the abnormal production samples based on the location information of the image patches, using a feature extraction structure. The formula for the feature extraction structure is:
[0183]
[0184] in, Let E be the tensor corresponding to a certain image patch, and let E be the weight parameter. (p,t) The input image patch vector, The location vector of the image patch;
[0185] The production result tensor generation unit is used to input the sample tensor into the self-attention mechanism model for training to obtain the production result tensor.
[0186] A production training result generation unit is used to classify the production result tensor using a first multilayer perceptron to obtain the production training result;
[0187] The classification loss calculation unit is used to calculate the classification loss of the self-attention mechanism based on the normal production samples, the abnormal production samples, and the production training results, wherein the classification loss represents the difference between the sample video frame packets and the production training results;
[0188] The convergence threshold comparison unit is used to determine whether the classification loss is less than the preset convergence threshold.
[0189] A production safety anomaly identification model generation unit is used to use the self-attention mechanism model as a trained production safety anomaly identification model.
[0190] The retraining unit is used to return to the execution of inputting the sample tensor into the self-attention mechanism model for training, and obtain the production result tensor.
[0191] Optionally, the production result tensor generation unit includes:
[0192] The feature vector setting subunit is used to set the feature vectors of the encoder for several layers, wherein the feature vectors are used to extract features from the image patch, and the specific formula of the feature vectors is as follows:
[0193]
[0194]
[0195]
[0196] Where l represents the encoder of the l-th layer, a is the a-th head of the multi-head attention mechanism, p is the spatial location information of the image patch, t is the temporal location information of the image patch, and W Q W K W V Let L be the weight matrix, and LN be the layer normalization function. The total extent of the potential feature space dimensions for each attention head;
[0197] The self-attention weight calculation subunit is used to calculate the self-attention weights based on the feature vector using the following formula:
[0198]
[0199] Where SM is the softmax activation function. Let F be the total range of the potential feature space dimensions for each attention head, where F is the first quantity and N is the third quantity.
[0200] The production result tensor calculation subunit is used to calculate the production result tensor based on the self-attention weights using the following formula:
[0201]
[0202] Where p' = 1…N, t' = 1…F.
[0203] Optionally, the production training result generation unit includes:
[0204] The training production tensor computation subunit is used to input the production result tensor into the first multilayer perceptron, and obtain the training production tensor using the following formula:
[0205]
[0206]
[0207] Among them, W O Output layer function, The production result component, To train the production tensor, MLP is the first multilayer perceptron function, and LN is the layer normalization function.
[0208] The production training result extraction subunit is used to extract the training production tensor from the training production tensor. The production training result is the image patch corresponding to the image patch with spatial location information p' and temporal location information t' in the video frame packet.
[0209] Optionally, the classification loss calculation unit includes:
[0210] The binary classification loss function calculation subunit is used to input the production training results into the second multilayer perceptron and calculate the binary classification loss function value of the self-attention mechanism model, wherein the formula of the second multilayer perceptron is:
[0211]
[0212] in, For the production training results, LN is the layer normalization function;
[0213] The classification loss calculation subunit is used to calculate the difference between the binary classification loss function value and the labeled value of the sample video frame packet as the classification loss, wherein the labeled value is whether the sample video frame packet is a normal production sample or an abnormal production sample.
[0214] The production safety anomaly identification device provided in this embodiment of the invention can execute the production safety anomaly identification method provided in any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the method.
[0215] Example 4
[0216] Figure 4A schematic diagram of an electronic device 10 that can be used to implement embodiments of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0217] like Figure 4 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 may also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0218] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0219] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as production security anomaly detection methods.
[0220] In some embodiments, the production safety anomaly identification method may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the production safety anomaly identification method described above may be performed. Alternatively, in other embodiments, processor 11 may be configured to perform the production safety anomaly identification method by any other suitable means (e.g., by means of firmware).
[0221] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transferring data and instructions to the storage system, the at least one input device, and the at least one output device.
[0222] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0223] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0224] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0225] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or computing systems that include middleware components (e.g., application servers), or computing systems that include frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.
[0226] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.
[0227] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.
[0228] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A method for identifying production safety anomalies, characterized in that, include: Obtain production videos; The production video is divided into several video frame packets with a preset first number of frames; The video frame packet is input into a pre-trained production safety anomaly identification model to obtain the production identification result corresponding to the video frame packet; The training process of the production safety anomaly identification model includes: Several videos were selected from the sample library as sample videos; The sample video is divided into several sample video frame packets with a preset number of frames; The sample video frame packet containing the abnormal production segment is regarded as the production abnormal sample. The sample video frame packets that do not contain the abnormal production segments are regarded as normal production samples. Based on the location information of the image patches, sample tensors are extracted from the normal production samples and the abnormal production samples using a feature extraction structure; wherein, the formula for the feature extraction structure is: in, For a given image patch, the tensor For weight parameters, The input image patch vector, The location vector of the image patch; The sample tensor is input into the self-attention mechanism model for training to obtain the production result tensor; The production result tensor is classified using a first multilayer perceptron to obtain the production training result; Based on the normal production samples, the abnormal production samples, and the production training results, the classification loss of the self-attention mechanism is calculated; wherein, the classification loss represents the difference between the sample video frame packets and the production training results; Determine whether the classification loss is less than the preset convergence threshold; If the classification loss is less than the convergence threshold, then the self-attention mechanism model is used as the trained production safety anomaly identification model. If the classification loss is greater than the convergence threshold, then return to the previous step and input the sample tensor into the self-attention mechanism model for training to obtain the production result tensor.
2. The method according to claim 1, characterized in that, After inputting the video frame packet into the pre-trained production safety anomaly identification model to obtain the production identification result corresponding to the video frame packet, the method further includes: Obtain the production identification results corresponding to a preset second number of video frame packets; Extract the anomaly probability corresponding to the preset second number of production identification results; Calculate the average of the preset second number of abnormal probabilities; Determine whether the average value is greater than a preset abnormal threshold; If the average value is greater than the abnormal threshold, a production safety abnormality warning is generated and sent to the staff.
3. The method according to claim 1, characterized in that, The step of dividing the sample video into several sample video frame packets with a preset number of frames includes: The sample video is divided into several sample video frame packets with a preset number of frames; The images in the sample video frame packet are cut into a preset third number of image patches; A position vector is established to store the position information of the image patch in the sample video frame packet; wherein the formula for the position vector is: Where p represents the spatial location information of the image patch, t represents the temporal location information of the image patch, and pos represents the position of the image patch within the sample video frame packet. For all image patches of the sample video frame packet.
4. The method according to claim 1, characterized in that, The step of inputting the sample tensor into the self-attention mechanism model for training to obtain the production result tensor includes: A feature vector of several layers of encoder is set, wherein the feature vector is used to extract features of the image patch, and the specific formula of the feature vector is as follows: Where l represents the encoder of the l-th layer, a is the a-th head of the multi-head attention mechanism, p is the spatial location information of the image patch, and t is the temporal location information of the image patch. , , Let L be the weight matrix, and LN be the layer normalization function. The total extent of the potential feature space dimensions for each attention head; The self-attention weights are calculated based on the feature vector using the following formula: Where SM is the softmax activation function. Let F be the total range of the potential feature space dimensions for each attention head, where F is the first quantity and N is the third quantity. The production result tensor is calculated based on the self-attention weights using the following formula: Where p'=1…N, t'=1…F.
5. The method according to claim 1, characterized in that, The process of classifying the production result tensor using a first multilayer perceptron to obtain production training results includes: The production result tensor is input into the first multilayer perceptron, and the training production tensor is obtained using the following formula: in, It is the output layer function. Let the production result tensor be... To train the production tensor, MLP is the first multilayer perceptron function, and LN is the layer normalization function. Extracting the training production tensor from The production training result corresponds to the image patch with spatial location information p'' and temporal location information t'' in the video frame packet.
6. The method according to claim 5, characterized in that, The step of calculating the classification loss of the self-attention mechanism based on the normal production samples, the abnormal production samples, and the production training results includes: The production training results are input into the second multilayer perceptron to calculate the binary classification loss function value of the self-attention mechanism model; wherein, the formula of the second multilayer perceptron is: in, For the production training results, LN is the layer normalization function; The difference between the binary classification loss function value and the labeled value of the sample video frame packet is calculated as the classification loss; wherein the labeled value is whether the sample video frame packet is a normal production sample or an abnormal production sample.
7. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the production safety anomaly identification method according to any one of claims 1-6.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that are used to cause a processor to execute the production safety anomaly identification method according to any one of claims 1-6.
Citation Information
Patent Citations
Digital production management system, video processing method, equipment and storage medium
CN113487247A