Behavior recognition model training method and system integrating 3DCNN and attention mechanism

By integrating the behavior recognition model of 3DCNN and attention mechanism, combined with low-rank decomposition technology, the problem of high computational complexity of ViT-like models is solved, and efficient behavior recognition on small computing power devices is achieved, with reduced parameter volume and computational complexity. , the accuracy rate is improved.

CN118334752BActive Publication Date: 2024-08-30HANGZHOU ZENOINTEL TECH CO LTD +2
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410742021.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-11
Publication Date
2024-08-30
Estimated Expiration
2044-06-11

AI Technical Summary

Technical Problem

Existing visual Transformer (ViT) models have high computational complexity when processing large-size images, and are difficult to adapt to terminal devices with limited computing resources, and optimization methods such as sparse attention mechanisms and knowledge distillation still have large parameters and high complexity. question.

Method used

Using a behavior recognition model that integrates 3DCNN and attention mechanism, local features are extracted through 3DCNN and combined with Transformer network to obtain global features, and low-rank decomposition is used to reduce the computational complexity of the attention mechanism from O(n²) to O(n). And feature fusion is performed through the feature processing layer and FusionBlock module.

Benefits of technology

It reduces the computational complexity while improving the accuracy of behavior recognition. It is suitable for devices with limited computing resources. The amount of model parameters and computational complexity are reduced by 15%, and the accuracy is increased by at least 1%.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118334752B
    Figure CN118334752B
Patent Text Reader

Abstract

The present application relates to a behavior recognition model training method and system that integrates 3DCNN and attention mechanism. Compared with the related art through the deep behavior recognition method of ViT-like, this embodiment uses 3DCNN and Transformer Block combined with attention mechanism for feature extraction, which can achieve accurate personnel behavior recognition under the premise of low computational complexity and low computing power consumption.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of behavior recognition, and in particular to a behavior recognition model training method, system, computer device, and computer-readable storage medium that integrates 3DCNN and attention mechanism. Background Art

[0002] With the rapid development of artificial intelligence technology, deep learning models have achieved remarkable results in the field of computer vision. In recent years, the Visual Transformer (ViT) model has become the mainstream choice due to its superior performance and flexibility. The ViT model captures long-range dependencies in images through the attention mechanism, improving the accuracy of tasks such as image classification and object detection. However, the computational complexity of the attention mechanism is O(n²), which means that when the input image size increases, the demand for computing resources rises sharply. This poses a huge challenge to terminal devices with limited processing power, such as mobile devices and embedded systems. Therefore, how to reduce the computational complexity while ensuring model performance has become an important research direction.

[0003] At present, there are many attempts to optimize the computational complexity of ViT-like deep learning models. Some studies reduce the amount of computation by introducing sparse attention mechanisms or hierarchical structures, while others use techniques such as knowledge distillation to compress the model. However, these methods still face the problem of large number of model parameters and high complexity to a certain extent, and are not completely suitable for devices with limited computing resources.

[0004] Therefore, finding a solution that takes into account both performance and computational complexity, which can not only give full play to the advantages of the attention mechanism but also effectively reduce the demand for computing resources, becomes the key to solving this problem. Summary of the invention

[0005] The embodiments of the present application provide a behavior recognition model training method, system, computer device and computer-readable storage medium that integrate 3DCNN and attention mechanism, so as to at least solve the problem of high computational complexity of behavior recognition models in related technologies.

[0006] In a first aspect, an embodiment of the present application provides a method for training a behavior recognition model integrating 3DCNN and an attention mechanism, the method comprising:

[0007] Receiving a training set, wherein the training set is video data containing human behavior labels;

[0008] Separately extracting spatial features from each image frame in the training set to obtain an initial behavior feature map;

[0009] Extracting local features from the initial behavior feature map through a 3DCNN network, obtaining global features based on the initial behavior feature map through a Transformer network combined with an attention mechanism, and fusing the local features with the global features to obtain a behavior feature vector;

[0010] The Softmax values ​​of the behavior feature vectors are obtained respectively through the classification head, and the Softmax values ​​are compared with the label values ​​to obtain the behavior classification results corresponding to each image frame.

[0011] In some embodiments, the model includes a plurality of feature processing layers, wherein each feature processing layer of the first interval includes a plurality of invertedResidual modules, and each feature processing layer of the second interval includes a plurality of invertedResidual modules and a FusionBlock module;

[0012] The residual connection between different feature processing layers is used to maintain information transmission between different feature layers. After the image frames in the training set are subjected to feature extraction by each feature processing layer in the first interval, the initial behavior feature map is output. After the initial behavior feature map is subjected to feature extraction and fusion by each feature processing layer in multiple second intervals, the feature vector is output.

[0013] In some embodiments, separate spatial extraction is performed on each image frame in the training set to obtain an initial behavior feature map, including:

[0014] Through multiple invertedResidual modules, using deep convolution, spatial features are extracted from each video frame of the training set to obtain spatial features.

[0015] And perform point-by-point convolution on each video frame of the training set, linearly combine the spatial features obtained from different channels, and obtain an initial behavior feature map.

[0016] In some embodiments, local features are extracted from the initial behavior feature map through a 3DCNN network, and global features are obtained based on the initial behavior feature map through a Transformer network combined with an attention mechanism, and the local features and the global features are fused to obtain a behavior feature vector including:

[0017] Extracting local spatial features from the initial behavior feature map through a 3DCNN network to obtain local features;

[0018] And, the local behavior features are serialized, and global features are extracted from the serialized local behavior features through a Transformer network to obtain global features;

[0019] The local features and the global features are fused through a 1×1×1 convolution kernel to obtain the behavior feature vector.

[0020] In some embodiments, in the process of obtaining the global features based on the initial behavior feature graph by combining a Transformer network with an attention mechanism, the method further includes:

[0021] Through the attention mechanism, the weights of various features are dynamically adjusted in the time dimension. Among them, through low-rank decomposition, the computational complexity of the attention mechanism is reduced from O(n 2 ) is reduced to O(n), where the attention calculation formula is as follows:

[0022]

[0023] Where Q, K, and V represent query, key, and value, and d represents the dimension.

[0024] In some embodiments, before performing separation spatial feature extraction on each image frame in the training set, the method further includes:

[0025] Acquire source data, and perform data cleaning on the source data;

[0026] Dividing the source data after data cleaning into training data, verification data and test data;

[0027] According to a preset time interval and a preset number of frames, the image frames of the training data are respectively extracted, and according to a preset size, random spatial sampling is performed on each of the extracted video frames, and data enhancement and regularization are performed to obtain the training set.

[0028] In some embodiments, the behavior recognition model is trained using the Adam optimizer and the OneCycle scheduler, with a learning rate of 3e-4, and a cross entropy loss function is used to calculate the loss:

[0029]

[0030] Among them, yi is the true label value, i is the sample, and pi is the probability distribution of the sample.

[0031] In a second aspect, an embodiment of the present application provides a behavior recognition model training system integrating 3DCNN and attention mechanism, the system comprising: a receiving module and a training module, wherein;

[0032] The receiving module is used to receive a training set, wherein the training set is video data containing human behavior labels;

[0033] The training module is used to extract separate spatial features from each image frame in the training set to obtain an initial behavior feature map.

[0034] And, extracting local features from the initial behavior feature map through a 3DCNN network, obtaining global features based on the initial behavior feature map through a Transformer network combined with an attention mechanism, and fusing the local features with the global features to obtain a behavior feature vector;

[0035] The Softmax values ​​of the behavior feature vectors are obtained respectively through the classification head, and the Softmax values ​​are compared with the label values ​​to obtain the behavior classification results corresponding to each image frame.

[0036] In a third aspect, an embodiment of the present application provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method of the first aspect described above when executing the computer program.

[0037] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method of the first aspect described above.

[0038] Compared with the related art, the behavior recognition model training method that integrates 3DCNN and attention mechanism provided in the embodiment of the present application is compared with the deep behavior recognition model of ViT-like in the related art. In this embodiment, 3DCNN and Transformer combined with attention mechanism are used for feature extraction. It can obtain more accurate behavior feature vectors under the premise of low computational complexity and low computing power consumption, thereby improving the model recognition accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0040] Figure 1 It is a flow chart of a behavior recognition model training method integrating 3DCNN and attention mechanism according to an embodiment of the present application;

[0041] Figure 2 is a schematic diagram of a model structure according to an embodiment of the present application;

[0042] Figure 3 is a flow chart of a FusionBlock module according to an embodiment of the present application;

[0043] Figure 4 is a schematic diagram of serializing local features according to the present application;

[0044] Figure 5 It is a structural block diagram of a behavior recognition model training system integrating 3DCNN and attention mechanism according to an embodiment of the present application;

[0045] Figure 6 It is a schematic diagram of the internal structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0046] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is described and illustrated below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. Based on the embodiments provided in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.

[0047] Obviously, the drawings described below are only some examples or embodiments of the present application. For ordinary technicians in this field, the present application can also be applied to other similar scenarios based on these drawings without creative work. In addition, it can also be understood that although the efforts made in this development process may be complicated and lengthy, for ordinary technicians in this field related to the content disclosed in this application, some changes in design, manufacturing or production based on the technical content disclosed in this application are just conventional technical means, and should not be understood as insufficient content disclosed in this application.

[0048] Reference to "embodiments" in this application means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those of ordinary skill in the art that the embodiments described in this application may be combined with other embodiments without conflict.

[0049] Unless otherwise defined, the technical terms or scientific terms involved in this application should be understood by people with ordinary skills in the technical field to which this application belongs. The words "one", "a", "a", "the" and the like involved in this application do not indicate a quantity limitation, and may indicate the singular or plural. The terms "include", "comprise", "have" and any of their variations involved in this application are intended to cover non-exclusive inclusions; for example, a process, method, system, product or device that includes a series of steps or modules (units) is not limited to the listed steps or units, but may also include steps or units that are not listed, or may also include other steps or units inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there may be three relationships, for example, "A and / or B" can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects before and after are in an "or" relationship. The terms "first", "second", "third", etc. involved in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.

[0050] In the traditional way, ViT-like deep learning models have made various attempts to optimize computational complexity. Some studies reduce the amount of computation by introducing sparse attention mechanisms or hierarchical structures, while others use techniques such as knowledge distillation to compress the model. However, these methods still face the problem of large number of model parameters and high complexity to a certain extent, and are not completely suitable for devices with limited computing resources.

[0051] Based on the above situation, the embodiment of the present application provides a behavior recognition model training method that integrates 3DCNN and attention mechanism. Figure 1 is a flow chart of a behavior recognition model training method integrating 3DCNN and attention mechanism according to an embodiment of the present application. Figure 1 As shown, the process includes the following steps:

[0052] S101, receiving a training set, wherein the training set is video data containing human behavior labels;

[0053] Before this step, it is necessary to download source data from the kinetics400 dataset. Each dataset contains a large number of short video clips, and each video clip is related to a specific action category.

[0054] Considering that some videos in the Kinetics400 dataset are damaged due to the long time and invalid video links, video processing tools (such as ffmpeg) can be used to verify whether each downloaded video file is complete and can be played normally. If not, the source data needs to be cleaned.

[0055] Furthermore, the dataset can be divided into training set, validation set and test set for model training and performance evaluation.

[0056] Optionally, 80% of the videos are usually used as training sets, 10% as validation sets, and 10% as test sets. In actual applications, this ratio can be adjusted according to specific needs to ensure that the division of the data set is random to avoid deviation; it can be understood that the training set is used to train the model, the validation set is used to verify the performance of the evaluation model, and the model hyperparameters (such as learning rate, regularization parameters, etc.) are adjusted based on the verification results, and the test set is used to evaluate the performance of the model on unseen data;

[0057] Furthermore, in order to be suitable for model training and improve training efficiency and model recognition accuracy, it is necessary to preprocess each video frame in the training set. Specifically, the preprocessing of the training set includes the following steps:

[0058] S1, extracting video frames from a training set, a validation set, and a test set according to a preset time interval and a preset number of frames to obtain a first training set;

[0059] The continuous extraction of video frames in a random time region includes: randomly selecting a time point from the video as a starting point for frame extraction, and continuously extracting a certain number of frames (eg, 50 frames) starting from the starting point.

[0060] S2, randomly spatially sampling each video frame in the first training set according to a preset resolution, and performing data enhancement and regularization representation to obtain a training set.

[0061] Specifically, the video frames extracted in each step S1 may be randomly sampled to a resolution of 224x224 in the spatial dimension, and this step may be achieved by random cropping;

[0062] Furthermore, in order to further improve the subsequent model training effect, the video frames can also be enhanced. For example, random horizontal flipping is performed, that is, the horizontal position of the frame is randomly flipped with a certain probability (such as 50%) to enhance the diversity of the data; in addition, color jittering, rotation and other methods can be used to further enhance each video frame.

[0063] Finally, the frame pixel values ​​are normalized to a certain range (usually [0, 1]) and the mean is subtracted and divided by the standard deviation to speed up model convergence.

[0064] It can be understood that after the above steps, a training set for inputting the model is obtained. Using this training set for model training can avoid common problems such as missing data or poor sample richness, which lead to poor model training efficiency and accuracy.

[0065] S102, performing separation space extraction on each image frame in the training set to obtain an initial behavior feature map;

[0066] Specifically, Figure 2 is a schematic diagram of a model structure according to an embodiment of the present application, such as Figure 2 As shown, the model consists of multiple feature processing layers, wherein the feature processing layers in the first interval (Layer1 and Layer2) are respectively composed of multiple invertedResidual modules, and each feature processing layer in the second interval (Layer3, Layer4, Layer5) includes multiple invertedResidual modules and invertedResidual modules;

[0067] Among them, the InvertedResidual module mainly uses Depthwise SeparableConvolution to efficiently extract spatial features, while maintaining the transmission of feature information through residual connections;

[0068] Specifically, multiple invertedResidual modules first use deep convolution to extract spatial features of each video frame in the training set to obtain spatial features; further, each video frame is convolved point by point, and the spatial features obtained from different channels are linearly combined to obtain the initial behavior feature map.

[0069] It should be noted that, for each video frame in the training set, this embodiment divides the ordinary convolution into two independent steps - deep convolution (convolution for each channel separately) and point-by-point convolution (merging features across channels through 1x1 convolution). Deep convolution extracts the spatial features of each channel, and point-by-point convolution performs feature interaction between different channels. This method effectively reduces the computational complexity of behavioral feature extraction.

[0070] Specifically, the following is a comparative explanation with specific examples:

[0071] In standard convolution, for a size (For example, 3x3) convolution kernel, the input feature map is M channels, and the output feature map has N channels, the computational complexity of standard convolution is relatively large. Assuming the spatial dimension of the input feature map is , then the computational cost of standard convolution is: ;

[0072] In this embodiment, for an input image frame containing human behavior, a separate convolution kernel is used for each input channel of the depthwise convolution operation, and the size of the convolution kernel is , the computational cost of depth convolution is: ;

[0073] Furthermore, pointwise convolution uses a 1x1 convolution kernel to linearly combine feature maps of different channels. The computational cost of pointwise convolution is: ;

[0074] Combining these two steps, the total computational effort of depthwise separable convolution is: .

[0075] It can be clearly seen that the convolution operation is decomposed into two steps, which is significantly lower than the standard convolution. This makes the backbone network of the model more lightweight in the behavioral feature extraction process, significantly reducing the computational cost and the number of parameters while maintaining the performance of the model.

[0076] In addition, considering that in deep neural networks, the gradient may become very small (vanish) or very large (explode), making training difficult; in this embodiment, each feature processing layer is residually connected, and important features are not lost when information is transferred between layers. The residual connection helps train deeper neural networks by directly adding input information to the output.

[0077] It can be understood that in the above-mentioned Layer 1 and Layer 2 respectively composed of multiple invertedResidual modules, the feature map is transmitted layer by layer, and each layer further extracts spatial features and retains the information between channels.

[0078] After the feature map is processed layer by layer by Layer1 and Layer2, the spatial and channel features are retained, and the feature loss is avoided through residual connection. The initial behavior feature map output by Layer1 and Layer2 is used as the input feature map of the subsequent layers (Layer3, Layer4 and Layer5) to continue feature processing.

[0079] S103, further extracting local features from the initial behavior feature map through the 3DCNN network, and obtaining global features based on the initial behavior feature map through the Transformer combined with the attention mechanism, and fusing the local features with the global features to obtain a behavior feature vector;

[0080] Further, the preliminary feature map obtained in step S102 is used as input, and Layer3, Layer4 and Layer5 continue to perform feature processing, wherein these feature processing layers are composed of InvertedResidual modules and FusionBlock modules, and InvertedResidual modules and FusionBlock modules exist alternately;

[0081] Specifically, Figure 3 is a flow chart of a FusionBlock module according to an embodiment of the present application, such as Figure 3 As shown, the initial feature map is further extracted with global features and local features, and the local features and global features are combined to obtain a behavior feature vector, including the following steps:

[0082] S1, extract local spatial features from the initial behavior feature map through the 3DCNN network to obtain local features;

[0083] In this embodiment, in the last three layers, the features output by the invertedResidual module are further input to the FusionBlock module, which first extracts local spatial features from the initial behavior feature map of the 3DCNN network to obtain local features;

[0084] Among them, Figure 3 As shown in the figure, in the first path, 3D convolution layer (CONV3D(input, input)), kernel_size=3: the size of the convolution kernel is 3x3x3; stride=1: the stride is 1, that is, the convolution kernel moves one unit each time; padding=1: padding is 1 to ensure that the output size is the same as the input. Output: local feature map after processing by the convolution layer.

[0085] It should be noted that the 3D convolutional neural network (3D CNN) is a deep learning model that extends the traditional 2D convolutional neural network (2DCNN) and is used to process data with time and space dimensions. Unlike 2D CNN, which performs convolution operations in two-dimensional space (height and width), 3D CNN performs convolution in three-dimensional space (height, width, and time / depth). 3D CNN can capture the spatiotemporal features in video data and extract detailed information from each local area.

[0086] Furthermore, after 3D CNN, the extracted local features are serialized and input into the Transformer network. The Transformer Block captures the long-range dependencies and contextual information in the input data, namely the global features, and obtains the dependencies and long-distance interaction information between each position in the feature map through the attention mechanism (Self-Attention).

[0087] S2, serialize the local behavior features, and extract global features from the serialized local behavior features through Transformer Block to obtain global features;

[0088] Among them, in the FusionBlock module, local features are transformed into sequence features that can be recognized by TransformerBlock through serialization;

[0089] Specifically, the feature map extracted from 3D CNN is usually in the shape of (D, H, W, C), where D is the time dimension, H is the height, W is the width, and C is the number of channels; Patch partitioning divides the input feature map into multiple patches, each of which has the dimensions (patch_t, patch_h, patch_w), which represent the dimensions in time, spatial height, and spatial width, respectively; each patch is flattened into a vector, and all patches are arranged in order to form a long sequence. The purpose of this is to convert the 3D feature map into a 1D sequence, which is convenient for inputting the Transformer for global feature extraction.

[0090] Figure 4 is a schematic diagram of serializing local features according to the present application, such as Figure 4 As shown in the figure, each feature is divided into multiple batches by patch, and different features will constitute the length of the token. Specifically, the calculation formula is as follows:

[0091]

[0092] Among them, patch_w, patch_h, patch_t represent the dimensions of the patch in time and space, tokens is the number of tokens, tokens length is the length of each token, and features number is the number of features of 3DCNN.

[0093] Furthermore, the transformer extracts global features from the sequence and outputs a new global feature sequence that retains the global context information. The output of the transformer is re-expanded into a feature map, and through the concat operation, a 1×1×1 convolution is used to fuse the local and global features to obtain a fused feature.

[0094] It should be noted that, in this embodiment, the transformer applies the attention mechanism to the process of global feature extraction of the sequence, and dynamically adjusts the weights of various features, so that in the process of global feature extraction, it can dynamically focus on the behavioral features of relatively more important parts, while ignoring less relevant information, thereby improving the effect and efficiency of the model;

[0095] In this embodiment, in behavior recognition, the video data contains time series information, and the attention mechanism can dynamically adjust the weights of features in the time dimension to capture key moments and actions. Specifically: the attention mechanism can dynamically adjust the feature weights of each time point according to the contextual information in the video, so as to better capture the key actions and moments in the video.

[0096] In addition, through the attention mechanism, the model can capture dependencies over long time spans, such as identifying the association between the start and end parts of an action in a long video.

[0097] In one embodiment, the calculation formula of attention is as follows:

[0098]

[0099] Where Q, K, and V represent query, key, and value, and d represents the dimension.

[0100] It should be noted that the complexity of the traditional attention mechanism is O(n 2 ), in this embodiment, the Transformer block can be optimized by Linformer to improve efficiency, and the computational complexity can be reduced from O(n 2 ) is reduced to O(n).

[0101] Specifically, the estimation of the low-rank matrix is ​​performed by using singular value decomposition (SVD), and the matrix is ​​low-rank approximated using singular value decomposition (SVD), so that the attention matrix involved in behavioral feature extraction is represented as a smaller matrix product, thereby reducing the amount of calculation.

[0102] In an exemplary embodiment, the shape of the matrix after decomposition changes from the original nxn to nxk, where k<< n, which significantly reduces the computational complexity; in addition, the Linformer method allows different layers to share low-rank matrices, thereby further reducing the number of model parameters. This can reduce memory usage and computational requirements while maintaining performance.

[0103] The following is the detailed model structure after optimization with Linformer:

[0104] 1. Input data:

[0105] The input data is passed through an embedding layer or linear transformation to obtain the query Q, key K, and value V.

[0106] 2.Linformer Attention Mechanism:

[0107] Use low-rank matrices to perform low-rank decomposition on Q, K, and V.

[0108] After calculating the low-rank approximation of the attention matrix, the complexity is reduced to O(n).

[0109] Apply the attention matrix to the value vector V to get the output after the attention mechanism.

[0110] Transformer output:

[0111] The output processed by the attention mechanism is linearly transformed to obtain global features.

[0112] S3, local features and global features are fused through a 1×1×1 convolution kernel to obtain fused behavior features;

[0113] Finally, after the Transformer Block combines the self-attention mechanism to obtain the serialized behavioral features, it reconstructs the feature map and expands the feature sequence output by the Transformer back into a feature map;

[0114] Furthermore, 1×1×1 convolution is used to fuse the global features of Transformer and the local features of 3DCNN. The role of 1×1×1 convolution is to fuse features from different sources based on linear transformation while reducing the amount of calculation; it should be noted that each network in this module also adds residual connections to ensure that the initial information is not lost during the feature fusion process.

[0115] Through the above step S103, spatial features are extracted through the 3DCNN network, and then global features are further extracted through the Transformer Block combined with the attention mechanism. Finally, the global features and local features are fused to obtain the final features used for comparison, so that the model can effectively capture the complex behavior information in the video and achieve more efficient behavior recognition.

[0116] S104, through the classification head, respectively obtain the Softmax value of the behavior feature vector, and compare the Softmax value with the label value to obtain the behavior classification result.

[0117] It should be noted that the output of step S103 is a feature vector. Further, through the classifier, the Softmax function is applied to convert this vector into a probability distribution relative to each label, and the Softmax value is compared with the label value to obtain the classification result.

[0118] Through the above steps S101 to S103, compared with the related art through the ViT-like deep behavior recognition model, in this embodiment, 3DCNN and Transformer Block combined with the attention mechanism are used for feature extraction, which can achieve more accurate behavior recognition under the premise of low computational complexity and low computing power consumption.

[0119] In addition, during the model training process, the Adam optimizer and OneCycle scheduler are used to train the behavior recognition model, with a learning rate of 3e-4, and a cross entropy loss function is used to calculate the loss:

[0120]

[0121] Among them, yi is the true label value, i is the sample, and pi is the probability distribution of the sample.

[0122] It has been verified by those skilled in the art that the behavior recognition module trained by the method provided in this embodiment has a model parameter amount of 3.17M, a model calculation complexity of 5.95GFLOPS, and an accuracy rate of 73% on the Kinetics400 data set. Compared with models of the same level, the accuracy rate is at least 1%, and compared with models with similar accuracy rates, the parameter amount and calculation complexity are reduced by at least 15%.

[0123] In the second aspect, the embodiment of the present application also provides a behavior recognition model training system that integrates 3DCNN and attention mechanism. Figure 5 is a structural block diagram of a behavior recognition model training system integrating 3DCNN and attention mechanism according to an embodiment of the present application, such as Figure 5 As shown, the system includes: a receiving module 50 and a training module 51, wherein:

[0124] The receiving module 50 is used to receive a training set, wherein the training set is video data containing human behavior labels;

[0125] The training module 51 is used to perform separate spatial extraction on each image frame in the training set to obtain an initial behavior feature map, and to further extract local features from the initial features through a 3DCNN network, and to obtain global features based on the initial behavior feature map through a Transformer Block combined with an attention mechanism, and to fuse the local features with the global features to obtain a behavior feature vector, and to obtain the Softmax value of the behavior feature vector through a classification head, and to compare the Softmax value with the label value to obtain the behavior classification result corresponding to each image frame.

[0126] Through the above system, 3DCNN and Transformer Block combined with attention mechanism are used for feature extraction, which can achieve more accurate behavior recognition with less computational complexity and less computing power consumption.

[0127] In one embodiment, Figure 6 is a schematic diagram of the internal structure of an electronic device according to an embodiment of the present application, such as Figure 6 As shown, an electronic device is provided, which may be a server, and its internal structure diagram may be as shown in Figure 6 As shown. The electronic device includes a processor, a network interface, an internal memory and a non-volatile memory connected through an internal bus, wherein the non-volatile memory stores an operating system, a computer program and a database. The processor is used to provide computing and control capabilities, the network interface is used to communicate with an external terminal through a network connection, the internal memory is used to provide an environment for the operation of the operating system, the computer program is executed by the processor to implement a behavior recognition model training method that integrates 3DCNN and attention mechanism, and the database is used to store data.

[0128] Those skilled in the art will understand that Figure 6 The structure shown in the figure is merely a block diagram of a partial structure related to the scheme of the present application, and does not constitute a limitation on the electronic device to which the scheme of the present application is applied. The specific electronic device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.

[0129] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0130] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.

Claims

1. A behavior recognition model training method integrating 3DCNN and attention mechanism, characterized in that: The method comprises: Receiving a training set, wherein the training set is video data containing human behavior labels; Separately extracting spatial features from each image frame in the training set to obtain an initial behavior feature map; Extracting local features from the initial behavior feature graph through a 3DCNN network, obtaining global features based on the serialized local features through a Transformer network combined with an attention mechanism, and fusing the local features with the global features to obtain a behavior feature vector. Specifically, the method includes: fusing the local features with the global features through a 1×1×1 convolution kernel to obtain the behavior feature vector; Through the classification head, the Softmax value of the behavior feature vector is obtained respectively, and the Softmax value is compared with the label value to obtain the behavior classification result corresponding to each image frame; The model includes a plurality of feature processing layers, wherein each feature processing layer in the first interval includes a plurality of invertedResidual modules, and each feature processing layer in the second interval includes a plurality of invertedResidual modules and a FusionBlock module; The residual connection between different feature processing layers is used to maintain information transmission between different feature layers. After the image frames in the training set are subjected to feature extraction by each feature processing layer in the first interval, the initial behavior feature map is output. After the initial behavior feature map is subjected to feature extraction and fusion by each feature processing layer in multiple second intervals, the feature vector is output. Separate spatial extraction is performed on each image frame in the training set to obtain an initial behavior feature map including: Through multiple invertedResidual modules, using deep convolution, spatial features are extracted from each video frame of the training set to obtain spatial features. And perform point-by-point convolution on each video frame of the training set, linearly combine the spatial features obtained from different channels, and obtain an initial behavior feature map.

2. The method according to claim 1, characterized in that Extracting local features from the initial behavior feature map through a 3DCNN network, and obtaining global features based on the initial behavior feature map through a Transformer network combined with an attention mechanism, including: Extracting local spatial features from the initial behavior feature map through a 3DCNN network to obtain local features; And, the local features are serialized, and global features are extracted from the serialized local features through a Transformer network to obtain global features.

3. The method according to claim 2, characterized in that In the process of obtaining the global features based on the initial behavior feature graph by using a Transformer network combined with an attention mechanism, the method further includes: Through the attention mechanism, the weights of various features are dynamically adjusted in the time dimension. Among them, through low-rank decomposition, the computational complexity of the attention mechanism is reduced from O(n 2 ) is reduced to O(n), where the attention calculation formula is as follows: Where Q, K, and V represent query, key, and value, and d represents the dimension.

4. The method according to claim 1, characterized in that: Before extracting separate spatial features from each image frame in the training set, the method further includes: Acquire source data, and perform data cleaning on the source data; Dividing the source data after data cleaning into training data, verification data and test data; According to a preset time interval and a preset number of frames, the image frames of the training data are extracted respectively, and according to a preset size, random spatial sampling is performed on each of the extracted video frames, and data enhancement and regularization are performed to obtain the training set.

5. The method according to claim 4, characterized in that The behavior recognition model is trained using the Adam optimizer and the OneCycle scheduler, with a learning rate of 3e-4 and a cross entropy loss function to calculate the loss: Among them, yi is the true label value, i is the sample, and pi is the probability distribution of the sample.

6. A behavior recognition model training system integrating 3DCNN and attention mechanism, characterized in that: The system comprises: a receiving module and a training module, wherein; The receiving module is used to receive a training set, wherein the training set is video data containing human behavior labels; The training module is used to extract separate spatial features from each image frame in the training set to obtain an initial behavior feature map. And, extracting local features from the initial behavior feature graph through a 3DCNN network, and obtaining global features based on the serialized local features through a Transformer network combined with an attention mechanism, and fusing the local features with the global features to obtain a behavior feature vector, specifically including: fusing the local features with the global features through a 1×1×1 convolution kernel to obtain the behavior feature vector; Through the classification head, the Softmax value of the behavior feature vector is obtained respectively, and the Softmax value is compared with the label value to obtain the behavior classification result corresponding to each image frame; The model includes a plurality of feature processing layers, wherein each feature processing layer in the first interval includes a plurality of invertedResidual modules, and each feature processing layer in the second interval includes a plurality of invertedResidual modules and a FusionBlock module; The residual connection between different feature processing layers is used to maintain information transmission between different feature layers. After the image frames in the training set are subjected to feature extraction by each feature processing layer in the first interval, the initial behavior feature map is output. After the initial behavior feature map is subjected to feature extraction and fusion by each feature processing layer in multiple second intervals, the feature vector is output. Separate spatial extraction is performed on each image frame in the training set to obtain an initial behavior feature map including: Through multiple invertedResidual modules, using deep convolution, spatial features are extracted from each video frame of the training set to obtain spatial features. And perform point-by-point convolution on each video frame of the training set, linearly combine the spatial features obtained from different channels, and obtain an initial behavior feature map.

7. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 5 is implemented.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • Face recognition method, face recognition device, computer equipment and storage medium

    CN114519877A

  • Chest X-ray image recognition method and device, computer equipment and storage medium

    CN115249228A