A method and device for detecting periodic signals based on periodic sparse attention
By introducing periodic sparse attention mechanism, hierarchical time period transformer and fine attention module in periodic signal detection, the computational complexity problem of Transformer in periodic signal detection is solved, and the detection accuracy and robustness are significantly improved.
Patent Information
- Application Number
- CN202410170587.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-02-06
- Publication Date
- 2024-10-08
- Estimated Expiration
- 2044-02-06
AI Technical Summary
Existing Transformers have secondary computational complexity problems in periodic signal detection, resulting in low accuracy in complex environments and difficulty in effectively extracting features of non-contact physiological signals and repetitive actions.
A periodic signal detection method based on periodic sparse attention is designed. Through the hierarchical time period converter module and fine attention mechanism, multi-scale periodic features are extracted, and high-correlation areas with similar phases in time and rich signals in space are aggregated. ,features are extracted from these regions at fine granularity.
It effectively alleviates the secondary computational complexity problem of Transformer and improves the accuracy and robustness of periodic signal detection. In particular, the performance of physiological signal and repeated action detection in complex environments is significantly improved.
Smart Images

Figure CN118097498B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of periodic signal detection, and in particular to a periodic signal detection method and device based on periodic sparse attention. Background Art
[0002] From human physiology to environmental evolution, important processes in nature often show meaningful and strong periodic or quasi-periodic changes. Repetitive actions or signals are widely present in human daily life and activities, such as regular human movements and postures, physiological signals such as electrocardiogram and electroencephalogram, changes in natural environment such as seasons and weather, industrial production, traffic flow, planetary motion, music beats, etc. The detection of repetitive / periodic motion has important application value. In machine learning, learning or recovering periodic signals from high-dimensional data is common in practical applications. Examples of periodic learning include recovering and amplifying physiological signals (e.g., heart rate or breathing), predicting weather and environmental changes (e.g., nowcasting of precipitation or surface temperature), counting repetitive movements (e.g., exercise or treatment), and analyzing human behavior (e.g., gait).
[0003] In computer vision, video-based physiological signal recovery and repeated action detection are hot topics. The following are two types of existing technologies similar to the present invention:
[0004] 1. Non-contact physiological signal detection
[0005] BVP (Blood Volumn Pulse) is an important physiological information, which can be used to obtain key vital signs such as heart rate and heart rate variability. The principle of BVP extraction based on PPG (Photo Plethysmo Graphy) is based on the changes in blood content in blood vessels under the skin caused by heart contraction and relaxation, which causes changes in light absorption and scattering. It is reflected on the imaging sensor as a subtle periodic color signal change that is invisible to the human eye. Traditionally, BVP needs to be obtained through contact sensors, and the contact characteristics can lead to many inconveniences and limitations. In recent years, the rPPG (Remote Photo Plethysmo Graphy) method, which can extract BVP information non-contactly, has received increasing attention. It is not only expected to convert ubiquitous cameras into sensors for health monitoring, but also has broad application prospects and research value in many fields such as emotional computing, liveness detection, and generated video detection, especially in the context of the widespread dissemination of self-media videos and generated videos.
[0006] Most of the early research on rPPG was based on traditional signal processing methods to analyze skin (usually facial) videos to extract its periodic signals, but the rPPG amplitude is too weak, and the noise caused by ambient light, movement, etc. is strong. It is difficult to obtain good accuracy in a complex environment using only signal processing methods. With the development of machine learning, more and more data-driven methods have emerged, and the frameworks used by these methods show a trend from two-dimensional convolutional neural networks to three-dimensional convolutional neural networks and then to Transformers.
[0007] PhysFormer (Physiological Signal Detection Transformer) is the most representative non-contact physiological signal detection method in the past two years. As a fully end-to-end method, it takes face video as input and pulse wave signal as output. It first introduces video Transformer into rPPG task, aiming to use Transformer to capture the long-range spatiotemporal relationship of quasi-periodic rPPG signal, and on this basis, uses TDC (Temporal Difference Convolution) module to project query (Q) and key (K) in the attention mechanism to refine the time difference information and better extract rPPG signal.
[0008] However, this method, like other current Transformer-based rPPG methods, is a coarse-grained global attention method. Due to artifacts and head movement, coarse-grained patches will inevitably contain both rPPG information-rich areas and a large amount of noise areas. The noise introduced by this coarse-grained extraction combined with the weak essential characteristics of rPPG results in an extremely low signal-to-noise ratio, making it difficult for the rPPG features to be noticed by the network. This also results in the fact that the effect of this method in complex environments has no obvious performance advantage over traditional convolutional methods.
[0009] 2. Repeat action counting
[0010] Repetitive motions are widely present in human activities, such as physical exercise. Counting some physical exercise movements can help people perform physical fitness detection and planning. Although people can use some sensors on the human body (e.g., gravity sensors), vision-based methods can be non-invasive, making third-view based video analysis possible and promising.
[0011] TransRAC (Transformers for Repetitive Action Counting) is the most representative repetitive action counting method in the field in the past two years. It is a Transformer-based multi-scale temporal correlation coding network. It consists of three stages. First, the video sequence V is sent to the encoder, and the multi-scale temporal correlation is encoded using Video SwinTransformer (Video Shift Window Transformer). Then the output X is used to calculate the correlation matrix C, and finally C is sent to the period predictor to predict the final output density map. This network can handle not only high-frequency and low-frequency actions, but also long and short videos. This method allows the model to automatically select its adaptive scale to calculate the correlation matrix for final count prediction. It uses Video Swin Transformer to extract periodic features in the encoding stage. It is a man-made static sparse attention mechanism. Although the secondary computational complexity of Transformer is alleviated to a certain extent through the local sparse attention mechanism, it is suboptimal for dynamic periodic signal extraction tasks.
[0012] Transformer uses attention as an alternative to convolution to achieve global context modeling. Compared with convolutional neural networks, it can capture long-range spatiotemporal relationships, which is very beneficial for periodic signals. However, since the traditional attention mechanism calculates the correlation of pairwise features at all spatial positions, it will bring a high computational burden and heavy memory usage, especially for high-resolution and high-dimensional inputs. Therefore, seeking more effective attention mechanisms is an important research direction. To address this problem, some works have introduced different artificially designed sparse patterns, such as dilated windows or cross windows. There are also some works that try to adapt sparse patterns to data, such as DAT (Deformable Attention Transformer), TCFormer (Token Clustering Transformer), and DPT (Dense Prediction Transformer). BiFormer (Dual-Layer Routing Transformer) explores a dynamic sparse attention mechanism and proposes new possibilities for sparse attention. In the past, most of the work related to periodic signal extraction did not introduce sparse attention mechanisms, but rather coarse-grained attention. Some introduced artificially designed static sparse attention mechanisms, such as local sparse attention based on Video Swin Transformer, but this is suboptimal for dynamic periodic signal extraction tasks. There are two main difficulties in designing a sparse attention mechanism suitable for periodic tasks: first, since periodic tasks require global attention at all times, and the position and frequency of the attention point are uncertain, it is difficult to achieve sparse attention through artificially designed static attention; second, the sparse attention mechanisms in past work were mostly discussed on two-dimensional images, and how to apply them to three-dimensional videos is a challenge. Summary of the invention
[0013] In order to solve the technical problem of the Transformer quadratic computational complexity in periodic tasks in the prior art, an embodiment of the present invention provides a periodic signal detection method and device based on periodic sparse attention. The technical solution is as follows:
[0014] On the one hand, a periodic signal detection method based on periodic sparse attention is provided, the method is implemented by a periodic signal detection device, and the method includes:
[0015] S1. Obtain video data to be detected, perform data preprocessing, and obtain preprocessed video data.
[0016] S2. Input the preprocessed video data into a periodic signal detection model based on periodic sparse attention to obtain a model output; wherein the periodic signal detection model includes: a convolution module, a block coding module, a hierarchical time period transformer module and a signal prediction head module.
[0017] S3. Perform data post-processing on the model output to obtain periodic signal detection results.
[0018] Optionally, in S2, the preprocessed video data is input into a periodic signal detection model based on periodic sparse attention to obtain a model output, including:
[0019] S21, input the preprocessed video data into the convolution module for primary feature extraction to obtain the convolution module output.
[0020] S22. Input the output of the convolution module to the block coding module for division to obtain the output of the block coding module.
[0021] S23, input the output of the block coding module to the hierarchical time period transformer module for periodic feature extraction to obtain the output of the hierarchical time period transformer module.
[0022] S24, inputting the output of the hierarchical time period transformer module into the signal prediction head module for projection to obtain the waveform characteristics of the periodic signal.
[0023] Optionally, the hierarchical time period converter module includes: a first time period converter submodule, a second time period converter submodule and a third time period converter submodule.
[0024] In S23, the output of the block coding module is input into the hierarchical time period transformer module for periodic feature extraction to obtain the output of the hierarchical time period transformer module, including:
[0025] S231. Input the block coding module output to the first time period converter submodule to obtain the first time period converter submodule output.
[0026] S232: Input the output of the first time period converter submodule to the second time period converter submodule to obtain the output of the second time period converter submodule.
[0027] S233 , input the output of the second time period converter submodule into the third time period converter submodule to obtain a hierarchical time period converter module output.
[0028] Optionally, the first time period transformer submodule includes: a down-sampling module, a pre-attention module, a fine-attention module, a spatiotemporal feedforward module and an up-sampling module.
[0029] Inputting the block coding module output to the first time period converter submodule in S231 to obtain the first time period converter submodule output includes:
[0030] S2311. Input the block encoding module output to the downsampling module to obtain the downsampling module output.
[0031] The downsampling module includes n downsampling submodules, where n is a sampling coefficient; each downsampling submodule includes a downsampling batch normalization layer and a downsampling three-dimensional convolution layer.
[0032] S2312. Input the output of the downsampling module to the pre-attention module to obtain the output of the pre-attention module.
[0033] S2313. Input the output of the pre-attention module into the fine attention module to obtain the output of the fine attention module.
[0034] S2314. Input the output of the fine attention module into the spatiotemporal feedforward module to obtain the output of the spatiotemporal feedforward module.
[0035] S2315. Input the output of the spatiotemporal feedforward module to the upsampling module to obtain the output of the first time period converter submodule.
[0036] The upsampling module includes n upsampling submodules, where n is a sampling coefficient; each upsampling submodule includes an upsampling layer, an upsampling convolution layer, an upsampling batch normalization layer, and an exponential linear unit (ELU) activation layer.
[0037] Optionally, the pre-attention module output in S2312 is as shown in the following equations (1) and (2):
[0038] K g =gather(K,topkIndex(Score)) (1)
[0039] V g =gather(V,topkIndex(Score)) (2)
[0040] In the formula, K g represents the aggregated key, gather represents the aggregation function, K represents the key, topkIndex represents the function for obtaining the index of the top k values, Score represents the pre-attention score, V g represents the aggregated value, and V represents the value.
[0041] Optionally, the output of the fine attention module in S2313 is as shown in the following formula (3):
[0042] MHSA=Concat(SA1,SA2,SA i , ..., S.A.h )W (3)
[0043] Among them, MHSA represents the output of the fine attention module, Concat represents the connection function, W represents the weight matrix, and SA i represents the output of the i-th self-attention head, as shown in the following formula (4):
[0044]
[0045] In the formula, SoTxmax represents the activation function, Q represents the query, and K g represents the key after pre-attention aggregation, T represents matrix transpose, D represents the dimension of single-head attention, V g represents the value after pre-attention aggregation, LCE represents the context enhancement module, and V represents the value.
[0046] Optionally, the spatiotemporal feedforward module includes a first fully connected layer, a hidden layer, and a second fully connected layer.
[0047] The hidden layers include a three-dimensional convolutional layer of the spatiotemporal feedforward module, a batch normalization layer of the spatiotemporal feedforward module, and a Gaussian error linear unit GELU activation layer.
[0048] On the other hand, a periodic signal detection device based on periodic sparse attention is provided, and the device is applied to a periodic signal detection method based on periodic sparse attention, and the device comprises:
[0049] The acquisition module is used to acquire the video data to be detected, perform data preprocessing, and obtain the preprocessed video data.
[0050] The input module is used to input the preprocessed video data into a periodic signal detection model based on periodic sparse attention to obtain a model output; wherein the periodic signal detection model includes: a convolution module, a block coding module, a hierarchical time period transformer module and a signal prediction head module.
[0051] The output module performs data post-processing on the model output to obtain the periodic signal detection result.
[0052] Optionally, the input module is further configured to:
[0053] S21, input the preprocessed video data into the convolution module for primary feature extraction to obtain the convolution module output.
[0054] S22. Input the output of the convolution module to the block coding module for division to obtain the output of the block coding module.
[0055] S23, input the output of the block coding module to the hierarchical time period transformer module for periodic feature extraction to obtain the output of the hierarchical time period transformer module.
[0056] S24, inputting the output of the hierarchical time period transformer module into the signal prediction head module for projection to obtain the waveform characteristics of the periodic signal.
[0057] Optionally, the hierarchical time period converter module includes: a first time period converter submodule, a second time period converter submodule and a third time period converter submodule.
[0058] In S23, the output of the block coding module is input into the hierarchical time period transformer module for periodic feature extraction to obtain the output of the hierarchical time period transformer module, including:
[0059] S231. Input the block coding module output to the first time period converter submodule to obtain the first time period converter submodule output.
[0060] S232: Input the output of the first time period converter submodule to the second time period converter submodule to obtain the output of the second time period converter submodule.
[0061] S233 , input the output of the second time period converter submodule into the third time period converter submodule to obtain a hierarchical time period converter module output.
[0062] Optionally, the first time period transformer submodule includes: a down-sampling module, a pre-attention module, a fine-attention module, a spatiotemporal feedforward module and an up-sampling module.
[0063] Inputting the block coding module output to the first time period converter submodule in S231 to obtain the first time period converter submodule output includes:
[0064] S2311, input the block encoding module output to the downsampling module to obtain the downsampling module output;
[0065] The downsampling module includes n downsampling submodules, where n is a sampling coefficient; each downsampling submodule includes a downsampling batch normalization layer and a downsampling three-dimensional convolution layer.
[0066] S2312. Input the output of the downsampling module to the pre-attention module to obtain the output of the pre-attention module.
[0067] S2313. Input the output of the pre-attention module into the fine attention module to obtain the output of the fine attention module.
[0068] S2314. Input the output of the fine attention module into the spatiotemporal feedforward module to obtain the output of the spatiotemporal feedforward module.
[0069] S2315. Input the output of the spatiotemporal feedforward module to the upsampling module to obtain the output of the first time period converter submodule.
[0070] The upsampling module includes n upsampling submodules, where n is a sampling coefficient; each upsampling submodule includes an upsampling layer, an upsampling convolution layer, an upsampling batch normalization layer, and an exponential linear unit (ELU) activation layer.
[0071] Optionally, the output of the pre-attention module in S2312 is as shown in the following equations (1) and (2):
[0072] K g =gather(K,topkIndex(Score)) (1)
[0073] V g =gather(V,topkIndex(Score)) (2)
[0074] In the formula, K g represents the aggregated key, gather represents the aggregation function, K represents the key, topkIndex represents the function for obtaining the index of the top k values, Score represents the pre-attention score, V g represents the aggregated value, and V represents the value.
[0075] Optionally, the output of the fine attention module in S2313 is as shown in the following formula (3):
[0076] MHSA=Concat(SA1,SA2,SA i , ..., S.A. h )W (3)
[0077] Among them, MHSA represents the output of the fine attention module, Concat represents the connection function, W represents the weight matrix, and SA i represents the output of the i-th self-attention head, as shown in the following formula (4):
[0078]
[0079] In the formula, SoTxmax represents the activation function, Q represents the query, and K g represents the key after pre-attention aggregation, T represents matrix transpose, D represents the dimension of single-head attention, V g represents the value after pre-attention aggregation, LCE represents the context enhancement module, and V represents the value.
[0080] Optionally, the spatiotemporal feedforward module includes a first fully connected layer, a hidden layer, and a second fully connected layer.
[0081] The hidden layers include a three-dimensional convolutional layer of the spatiotemporal feedforward module, a batch normalization layer of the spatiotemporal feedforward module, and a Gaussian error linear unit GELU activation layer.
[0082] On the other hand, a periodic signal detection device is provided, which includes: a processor; a memory, wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, any one of the periodic signal detection methods based on periodic sparse attention is implemented.
[0083] On the other hand, a computer-readable storage medium is provided, wherein at least one instruction is stored in the storage medium, and the at least one instruction is loaded and executed by a processor to implement any one of the above-mentioned periodic signal detection methods based on periodic sparse attention.
[0084] The beneficial effects brought about by the technical solution provided by the embodiment of the present invention include at least:
[0085] In the embodiment of the present invention, a periodic sparse attention mechanism is designed based on the periodicity of periodic signals. The problem of the quadratic computational complexity of the Transformer is effectively solved through the pre-attention stage, and the periodic features are modeled in a fine-grained manner.
[0086] Based on the periodic sparse attention mechanism, this paper proposes a periodic signal detection method. The periodic features are hierarchically mined from multiple time scales. The spatiotemporal correlation is calculated in a larger spatiotemporal receptive field, and high-correlation regions with similar phases in time and rich signals in space are aggregated, and features are extracted from the above regions in a fine-grained manner.
[0087] The present invention has fully experimentally verified the proposed periodic signal detection method in the heart rate detection application scenario, proving its excellent performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0088] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0089] Figure 1 It is a flow chart of a periodic signal detection method based on periodic sparse attention provided by an embodiment of the present invention;
[0090] Figure 2 It is a structural diagram of a periodic signal detection model based on periodic sparse attention provided by an embodiment of the present invention;
[0091] Figure 3 is a structural diagram of a time period converter submodule provided by an embodiment of the present invention;
[0092] Figure 4 It is a block diagram of a periodic signal detection device based on periodic sparse attention provided by an embodiment of the present invention;
[0093] Figure 5 It is a structural schematic diagram of a periodic signal detection device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0094] The technical solution of the present invention is described below in conjunction with the accompanying drawings.
[0095] In the embodiments of the present invention, words such as "exemplarily" and "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "example" in the present invention should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of the word "example" is intended to present the concept in a specific way. In addition, in the embodiments of the present invention, the meaning expressed by "and / or" can be both, or it can be either of the two.
[0096] In the embodiments of the present invention, "image" and "picture" can sometimes be used interchangeably. It should be noted that when the difference between them is not emphasized, the meanings they intend to express are the same. "of", "corresponding, relevant" and "corresponding" can sometimes be used interchangeably. It should be noted that when the difference between them is not emphasized, the meanings they intend to express are the same.
[0097] In the embodiments of the present invention, sometimes a subscript such as W1 may be mistakenly written as a non-subscript such as W1. When the difference is not emphasized, the meanings to be expressed are consistent.
[0098] In order to make the technical problems, technical solutions and advantages to be solved by the present invention more clear, a detailed description will be given below with reference to the accompanying drawings and specific embodiments.
[0099] The embodiment of the present invention provides a periodic signal detection method based on periodic sparse attention, which can be implemented by a periodic signal detection device, which can be a terminal or a server. Figure 1 The process flow chart of the periodic signal detection method based on periodic sparse attention shown in FIG. 1 may include the following steps:
[0100] S1. Obtain video data to be detected, perform data preprocessing, and obtain preprocessed video data.
[0101] In a feasible implementation manner, the acquired video data may be a video captured by a camera. The data preprocessing process may include data format conversion, size adjustment, face detection, target recognition, and video segmentation.
[0102] S2. Input the preprocessed video data into a periodic signal detection model based on periodic sparse attention to obtain the model output.
[0103] like Figure 2 As shown, the periodic signal detection model includes: a convolution module, a block coding module, a hierarchical time period transformer module and a signal prediction head module.
[0104] Optionally, the above step S2 may include the following steps S21-S24:
[0105] S21, input the video data into the convolution module for primary feature extraction to obtain the convolution module output.
[0106] For RGB video input The primary features are extracted through the convolution module, and the convolution module outputs Among them, C, T, W, and H represent dimension, time, width, and height respectively.
[0107] Optionally, the convolution module includes a first convolution layer, a second convolution layer, and a third convolution layer.
[0108] Among them, the first convolution layer includes a first three-dimensional convolution layer, a first batch normalization layer, a first rectified linear unit ReLU activation layer and a first three-dimensional maximum pooling layer; the second convolution layer includes a second three-dimensional convolution layer, a second batch normalization layer, a second rectified linear unit ReLU activation layer and a second three-dimensional maximum pooling layer; the third convolution layer includes a third three-dimensional convolution layer, a third batch normalization layer, a third rectified linear unit ReLU activation layer and a third three-dimensional maximum pooling layer.
[0109] S22. Input the output of the convolution module to the block coding module for division to obtain the output of the block coding module.
[0110] In a feasible implementation, the output of the convolutional module will be divided into non-overlapping tokens through block coding, aggregating adjacent semantic information in space and reducing the Transformer computational cost.
[0111] Specifically, given the input Xstem, the output after block encoding is The number of tokens is T×H / 16×W / 16.
[0112] S23, input the output of the block coding module to the hierarchical time period transformer module for periodic feature extraction to obtain the output of the hierarchical time period transformer module.
[0113] In a feasible implementation, the output after block coding will be fed into a hierarchical temporal period transformer, which extracts periodic features from different time scales through periodic sparse attention at a fine-grained level. The hierarchical temporal period transformer module is divided into three stages, and the sampling coefficients of each stage are different. First, the inter-frame features are strengthened at a smaller time scale, and then the periodic features are modeled at a larger time scale, which effectively reduces noise interference. This pyramid-shaped hierarchical multi-scale learning can make the first learned scale provide information for the later learned scale.
[0114] Optionally, the hierarchical time period converter module includes: a first time period converter submodule, a second time period converter submodule and a third time period converter submodule.
[0115] Among them, the sampling coefficient of the first time period converter submodule is 1; the sampling coefficient of the second time period converter submodule is 2; and the sampling coefficient of the third time period converter submodule is 3.
[0116] The above step S23 may include the following steps S231-S233:
[0117] S231. Input the block coding module output to the first time period converter submodule to obtain the first time period converter submodule output.
[0118] like Figure 3 As shown, the first time period transformer submodule includes: a downsampling module, a pre-attention module, a fine attention module, a spatiotemporal feedforward module and an upsampling module.
[0119] The above step S231 may include the following steps S2311-S2315:
[0120] S2311. Input the block encoding module output to the downsampling module to obtain the downsampling module output.
[0121] The downsampling module includes n downsampling submodules, where n is the sampling coefficient. The downsampling submodule includes a downsampling batch normalization layer and a downsampling 3D convolution layer.
[0122] In a feasible implementation, for the input of the time period converter submodule, after passing through the downsampling module, the timing information will be non-overlapping and divided into two n Granular aggregation, downsampling module output
[0123] S2312. Input the output of the downsampling module into the pre-attention module to obtain the output of the pre-attention module.
[0124] After Q, K, and V are projected, the projected Q and K will undergo 3D average pooling to calculate attention in a larger spatiotemporal receptive field and filter out key-value pairs with low relevance. Specifically, for the input The size of the pooling convolution kernel is T′×H′×W′:
[0125]
[0126] Where T s =MAX(2 x , 2 n ), x is the partition coefficient. The number of tokens in the pre-attention phase is T s ×4×4. The score of the pre-attention stage is as shown in the following formula (2):
[0127] Score = Q′(K′) T (2)
[0128] Optionally, the output of the pre-attention module in S2312 is as shown in the following equations (3) and (4):
[0129] K g =gather(K,topkIndex(Score)) (3)
[0130] V g =gather(V,topkIndex(Score)) (4)
[0131] In the formula, K g represents the aggregated key, gather represents the aggregation function, K represents the key, topkIndex represents the function for obtaining the index of the top k values, Score represents the pre-attention score, V g represents the aggregated value, and V represents the value.
[0132] S2313. Input the output of the pre-attention module into the fine attention module to obtain the output of the fine attention module.
[0133] The output SA of the i-th self-attention head i , as shown in the following formula (5):
[0134]
[0135] In the formula, Sofxmax represents the activation function, Q represents the query, and K g represents the key after pre-attention aggregation, T represents transposition, D represents the dimension of single-head attention, V g represents the value after pre-attention aggregation, LCE represents the context enhancement module, which is a three-dimensional convolutional layer with a convolution kernel size of 3×3×3, and V represents the value.
[0136] Optionally, the fine attention module in S2313 outputs MHSA (Multi-head self-attention), as shown in the following formula (6):
[0137] MHSA=Concat(SA1,SA2,SA i , ..., S.A. h )W (6)
[0138] In the formula, Concat represents the connection function and W represents the weight matrix
[0139] S2314. Input the output of the fine attention module into the spatiotemporal feedforward module to obtain the output of the spatiotemporal feedforward module.
[0140] Optionally, the spatiotemporal feedforward module includes a first fully connected layer, a hidden layer, and a second fully connected layer.
[0141] The hidden layers include a 3D convolutional layer of the spatiotemporal feedforward module, a batch normalization layer of the spatiotemporal feedforward module, and a Gaussian error linear unit (GELU) activation layer, which are used to refine local information and enhance relative position clues.
[0142] S2315. Input the output of the spatiotemporal feedforward module to the upsampling module to obtain the output of the first time period converter submodule.
[0143] The upsampling module includes n upsampling submodules, where n is the sampling coefficient. The upsampling submodule includes an upsampling layer, an upsampling convolution layer, an upsampling batch normalization layer, and an exponential linear unit (ELU) activation layer.
[0144] In one feasible implementation, the output X of the upsampling module is out The dimensions will be restored to the same as the time period transformer submodule input Consistent.
[0145] S232: Input the output of the first time period converter submodule to the second time period converter submodule to obtain the output of the second time period converter submodule.
[0146] S233 , input the output of the second time period converter submodule into the third time period converter submodule to obtain a hierarchical time period converter module output.
[0147] Optionally, the spatiotemporal feedforward module includes a first fully connected layer, a hidden layer, and a second fully connected layer;
[0148] The hidden layers include a three-dimensional convolutional layer of the spatiotemporal feedforward module, a batch normalization layer of the spatiotemporal feedforward module, and a Gaussian error linear unit GELU activation layer.
[0149] S24, inputting the output of the hierarchical time period transformer module into the signal prediction head module for projection to obtain the waveform characteristics of the periodic signal.
[0150] In a feasible implementation, the prediction head is a fully connected layer, and the output of the hierarchical time period transformer is projected into a signal waveform or a periodogram through the prediction head.
[0151] S3. Perform data post-processing according to the model output to obtain periodic signal detection results.
[0152] In a feasible implementation manner, a spectrum analysis is performed on the output of the model to obtain its frequency domain characteristics.
[0153] The present invention has fully experimentally verified the proposed periodic signal detection method in the application scenario of non-contact physiological signal detection:
[0154] Experiments in the dataset
[0155] The present invention conducts in-dataset experiments on dataset 1 PURE, dataset 2 UBFC and dataset 3 MMPD to compare the performance of the present method with the previous methods. As shown in Table 1, the compared methods include HR-CNN (heart rate-convolutional neural network), DeepPhys (deep physiological signal detection method), PhysNet (physiological signal detection network), rPPGNet (remote photoplethysmography network), TS-CAN (Temporal Shift Convolutional Attention Networks), PulseGAN (Pulse Generative Adversarial Network), Dual-GAN (Dual Generative Adversarial Network), PhysFormer (physiological signal detection transformer), EfficientPhys (effective physiological signal detection method), LSTC (Long Short-Term Convolutional Network). In PURE, the present method outperforms the previous methods in all indicators; in UBFC, the present method performs comparable to the most advanced methods. This shows that the proposed method can better characterize weak rPPG features. As shown in Table 2, on the more challenging MMPD dataset, the method proposed in the present invention achieved the lowest MAE (Mean Absolute Error) (3.07), RMSE (Root Mean Square Error) (6.81) and the highest Pearson correlation coefficient ρ (0.86), which is much better than previous methods. This shows that the proposed method has better rPPG feature extraction capabilities and strong robustness. From the relatively good performance of other Transformer-based methods in PURE and UBFC and the large performance margin on MMPD, it can be concluded that in more complex environments, coarse-grained extracted rPPG features are extremely susceptible to noise interference and have poor robustness. The present invention uses periodic sparse attention to extract fine-grained rPPG features, and demonstrates its potential for application in complex real-world environments through excellent performance.
[0156] Table 1
[0157]
[0158] Table 2
[0159]
[0160]
[0161] Cross-dataset experiments
[0162] In addition to the evaluation within the dataset, the present invention also performs cross-dataset evaluation, training on dataset 1PURE and dataset 2UBFC, and testing on dataset 1PURE, dataset 2UBFC, and dataset 3MMPD. As shown in Table 3, in all experiments, this method outperforms previous methods in all indicators. The compared methods include 1. GREEN (a method based on green channel analysis), 2. ICA (independent component analysis), 3. CHROM (chrominance), 4. LGI (local group invariance), 5. PBV (blood volume pulse signature), 6. POS (plane-orthogonal-to-skin), 7. DeepPhys (deep physiological signal detection method), 8. PhysNet (physiological signal detection network), 9. TS-CAN (time-shifted convolutional attention network), 10. PhysFormer (physiological signal detection transformer), 11. EfficientPhys (effective physiological signal detection method). The results show that the proposed method can better model domain-invariant rPPG features and has excellent generalization ability.
[0163] Table 3
[0164]
[0165]
[0166] Ablation experiment
[0167] The present invention conducts ablation experiments on the MMPD dataset to evaluate the impact of different modules.
[0168] The effect of pre-attention
[0169] The main function of pre-attention is to reduce computational complexity and memory usage. Without pre-attention, the memory usage of a single batch will exceed the 48GB memory of a single RTX A6000, and only coarse-grained attention can be achieved. As shown in Table 4 below, ablation experiments show that pre-attention for fine-grained rPPG information mining significantly improves modeling capabilities while reducing noise interference.
[0170] Table 4
[0171]
[0172] Multi-scale impact
[0173] The present invention also compares the performance of the model under different fusion strategies and different time scales, as shown in Table 5 below. The results of the first four rows show that compared with a single scale, multi-scale modeling can more effectively capture the periodic characteristics of rPPG; the results of the fifth row show that for the extraction of rPPG information of a single type but with strong periodicity, hierarchical mining features are more effective than merging multi-scale information. The results of the last two rows show that the method of increasing multi-scale time granularity is far superior to the method of decreasing time granularity. Strengthening the inter-frame rPPG features with a smaller time scale and then extracting periodic features with a larger time scale can effectively eliminate interference and improve the network's ability to characterize rPPG signals. It is worth noting that for a single time scale, the granularity of 4 frames is significantly better than other granularities. In particular, when the scale is set to 1 frame, that is, the global focus time series, it will generate a lot of memory and computational costs, but the effect is poor. This shows that aggregated time information can effectively enhance rPPG features and prevent noise interference.
[0174] Table 5
[0175]
[0176] Calculation Amount
[0177] The present invention also reports the parameters and computational complexity of all methods implemented when the video input size is 160×128×128 (time×height×width). As shown in Table 6 below, the method proposed in the present invention achieves more excellent performance with smaller parameters and computational complexity, demonstrating the potential for efficient mobile-level rPPG applications.
[0178] Table 6
[0179] method Parameter quantity (M) Computational Amount(G) Depth Physiological Signal Detection Method 7.504 130.00 Physiological signal detection network 0.70 70.12 Time-Shifted Convolutional Attention Networks 7.504 130.00 Physiological signal detection transducer 7.381 50.607 Effective physiological signal detection method 7.439 60.687 The present invention 3.251 38.494
[0180] In an embodiment of the present invention, a periodic sparse attention mechanism is designed based on the periodicity of periodic signals. The problem of the Transformer's quadratic computational complexity is effectively alleviated through the pre-attention stage, and the periodic features are modeled in a fine-grained manner.
[0181] Based on the periodic sparse attention mechanism, this paper proposes a periodic signal detection method. The periodic features are hierarchically mined from multiple time scales. First, the spatiotemporal correlation is calculated in a larger spatiotemporal receptive field, and high-correlation regions with similar phases in time and rich signals in space are aggregated, and then features are extracted from multiple time scales in the above regions in a fine-grained manner.
[0182] The present invention has fully experimentally verified the proposed periodic signal detection method in a non-contact heart rate detection application scenario, demonstrating its excellent performance.
[0183] Figure 4 1 is a block diagram of a periodic signal detection device based on periodic sparse attention according to an exemplary embodiment, wherein the device is used in a periodic signal detection method based on periodic sparse attention. Figure 4 , the device includes an acquisition module 410, an input module 420 and an output module 430. For ease of description, Figure 4 Only the main components of the periodic signal detection device 400 are shown:
[0184] The acquisition module 410 is used to acquire the video data to be detected, perform data preprocessing, and obtain preprocessed video data.
[0185] The input module 420 is used to input the preprocessed video data into the periodic signal detection model based on periodic sparse attention to obtain the model output; wherein the periodic signal detection model includes: a convolution module, a block coding module, a hierarchical time period transformer module and a signal prediction head module.
[0186] The output module 430 is used to perform data post-processing on the model output to obtain a periodic signal detection result.
[0187] Optionally, the input module 420 is further configured to:
[0188] S21, input the preprocessed video data into the convolution module for primary feature extraction to obtain the convolution module output.
[0189] S22. Input the output of the convolution module into the block coding module for division to obtain the output of the block coding module.
[0190] S23, inputting the output of the block coding module into the hierarchical time period converter module to extract periodic features, and obtaining the output of the hierarchical time period converter module.
[0191] S24, inputting the output of the hierarchical time period transformer module into the signal prediction head module for projection to obtain the waveform characteristics of the periodic signal.
[0192] Optionally, the hierarchical time period converter module includes: a first time period converter submodule, a second time period converter submodule and a third time period converter submodule.
[0193] In S23, the output of the block coding module is input into the hierarchical time period transformer module for periodic feature extraction to obtain the output of the hierarchical time period transformer module, including:
[0194] S231. Input the block coding module output to the first time period converter submodule to obtain the first time period converter submodule output.
[0195] S232: Input the output of the first time period converter submodule to the second time period converter submodule to obtain the output of the second time period converter submodule.
[0196] S233 , input the output of the second time period converter submodule into the third time period converter submodule to obtain a hierarchical time period converter module output.
[0197] Optionally, the first time period transformer submodule includes: a first down-sampling module, a pre-attention module, a fine attention module, a spatiotemporal feedforward module and a first up-sampling module.
[0198] Inputting the block coding module output to the first time period converter submodule in S231 to obtain the first time period converter submodule output includes:
[0199] S2311. Input the block encoding module output to the downsampling module to obtain the downsampling module output.
[0200] The downsampling module includes n downsampling submodules, where n is a sampling coefficient; each downsampling submodule includes a downsampling batch normalization layer and a downsampling three-dimensional convolution layer.
[0201] S2312. Input the output of the downsampling module to the pre-attention module to obtain the output of the pre-attention module.
[0202] S2313. Input the output of the pre-attention module into the fine attention module to obtain the output of the fine attention module.
[0203] S2314. Input the output of the fine attention module into the spatiotemporal feedforward module to obtain the output of the spatiotemporal feedforward module.
[0204] S2315. Input the output of the spatiotemporal feedforward module to the upsampling module to obtain the output of the first time period converter submodule.
[0205] The upsampling module includes n upsampling submodules, where n is a sampling coefficient; each upsampling submodule includes an upsampling layer, an upsampling convolution layer, an upsampling batch normalization layer, and an exponential linear unit (ELU) activation layer.
[0206] Optionally, the output of the pre-attention module in S2312 is as shown in the following equations (1) and (2):
[0207] K g =gather(K,topk / index(Score)) (1)
[0208] V g =gather(V,topkIndex(Score)) (2)
[0209] In the formula, K g represents the aggregated key, gather represents the aggregation function, K represents the key, topkIndex represents the function for obtaining the index of the top k values, Score represents the pre-attention score, V g represents the aggregated value, and V represents the value.
[0210] Optionally, the fine attention module output in S3313 is as shown in the following formula (3):
[0211] MHSA=Concat(SA1,SA2,SA i , ..., S.A. h )W (3)
[0212] Among them, MHSA represents the output of the fine attention module, Concat represents the connection function, W represents the weight matrix, and SA i represents the output of the i-th self-attention head, as shown in the following formula (4):
[0213]
[0214] In the formula, Sofxmax represents the activation function, Q represents the query, and K g represents the key after pre-attention aggregation, T represents matrix transpose, D represents the dimension of single-head attention, V g represents the value after pre-attention aggregation, LCE represents the context enhancement module, which is a three-dimensional convolutional layer with a convolution kernel size of 3×3×3, and V represents the value.
[0215] Optionally, the spatiotemporal feedforward module includes a first fully connected layer, a hidden layer, and a second fully connected layer.
[0216] The hidden layers include a three-dimensional convolutional layer of the spatiotemporal feedforward module, a batch normalization layer of the spatiotemporal feedforward module, and a Gaussian error linear unit GELU activation layer.
[0217] In an embodiment of the present invention, a periodic sparse attention mechanism is designed based on the periodicity of periodic signals. The problem of the Transformer's quadratic computational complexity is effectively alleviated through the pre-attention stage, and the periodic features are modeled in a fine-grained manner.
[0218] Based on the periodic sparse attention mechanism, this paper proposes a periodic signal detection method. The periodic features are hierarchically mined from multiple time scales. First, the spatiotemporal correlation is calculated in a larger spatiotemporal receptive field, and high-correlation regions with similar phases in time and rich signals in space are aggregated, and then features are extracted from multiple time scales in the above regions in a fine-grained manner.
[0219] The present invention has fully experimentally verified the proposed periodic signal detection method in a non-contact heart rate detection application scenario, demonstrating its excellent performance.
[0220] Figure 5 is a schematic diagram of the structure of a periodic signal detection device provided by an embodiment of the present invention, such as Figure 5 As shown, the periodic signal detection device may include the above Figure 4 The periodic signal detection device based on periodic sparse attention is shown. Optionally, the periodic signal detection device 510 may include a first processor 2001.
[0221] Optionally, the periodic signal detection device 510 may further include a memory 2002 and a transceiver 2003 .
[0222] The first processor 2001, the memory 2002 and the transceiver 2003 may be connected via a communication bus.
[0223] Combine the following Figure 5 The components of the periodic signal detection device 510 are specifically introduced as follows:
[0224] The first processor 2001 is the control center of the periodic signal detection device 510, and may be a processor or a general term for multiple processing elements. For example, the first processor 2001 is one or more central processing units (CPUs), or may be application specific integrated circuits (ASICs), or may be configured to implement one or more integrated circuits of the embodiments of the present invention, such as one or more microprocessors (digital signal processors, DSPs), or one or more field programmable gate arrays (FPGAs).
[0225] Optionally, the first processor 2001 may perform various functions of the periodic signal detection device 510 by running or executing a software program stored in the memory 2002 , and calling data stored in the memory 2002 .
[0226] In a specific implementation, as an embodiment, the first processor 2001 may include one or more CPUs, such as Figure 5 CPU0 and CPU1 are shown in FIG.
[0227] In a specific implementation, as an embodiment, the periodic signal detection device 510 may also include multiple processors, such as Figure 5 The first processor 2001 and the second processor 2004 are shown in FIG. Each of these processors can be a single-core processor (single-CPU) or a multi-core processor (multi-CPU). The processor here can refer to one or more devices, circuits, and / or processing cores for processing data (e.g., computer program instructions).
[0228] The memory 2002 is used to store the software program for executing the solution of the present invention, and is controlled to be executed by the first processor 2001. The specific implementation method can refer to the above method embodiment, which will not be repeated here.
[0229] Optionally, the memory 2002 may be a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM) or other types of dynamic storage devices that can store information and instructions, or an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical disc, laser disc, optical disc, digital versatile disc, Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory 2002 may be integrated with the first processor 2001, or may exist independently, and may be accessed through the interface circuit ( Figure 5 (not shown) is coupled to the first processor 2001, which is not specifically limited in this embodiment of the present invention.
[0230] The transceiver 2003 is used to communicate with a network device or a terminal device.
[0231] Optionally, the transceiver 2003 may include a receiver and a transmitter ( Figure 5 The receiver is used to implement a receiving function, and the transmitter is used to implement a sending function.
[0232] Optionally, the transceiver 2003 may be integrated with the first processor 2001, or may exist independently, and may be connected to the first processor 2001 through the interface circuit ( Figure 5 (not shown) is coupled to the first processor 2001, which is not specifically limited in this embodiment of the present invention.
[0233] It should be noted that Figure 5 The structure of the periodic signal detection device 510 shown in the figure does not constitute a limitation on the router, and the actual knowledge structure identification device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0234] In addition, the technical effects of the periodic signal detection device 510 can refer to the technical effects of the periodic signal detection method based on periodic sparse attention described in the above method embodiment, which will not be repeated here.
[0235] It should be understood that the first processor 2001 in the embodiment of the present invention may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0236] It should also be understood that the memory in the embodiments of the present invention may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of random access memory (RAM) are available, such as static RAM (SRAM), dynamic random access memory (DRAM), synchronous DRAM (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link DRAM (SLDRAM), and direct rambus RAM (DR RAM).
[0237] The above embodiments can be implemented in whole or in part by software, hardware (such as circuits), firmware or any other combination. When implemented by software, the above embodiments can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer programs are loaded or executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center by wired (such as infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that contains one or more available media sets. The available medium can be a magnetic medium (for example, a floppy disk, a hard disk, a tape), an optical medium (for example, a DVD), or a semiconductor medium. The semiconductor medium can be a solid-state hard disk.
[0238] It should be understood that the term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. A and B can be singular or plural. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship, but it may also indicate an "and / or" relationship. Please refer to the context for specific understanding.
[0239] In the present invention, "at least one" means one or more, and "more than one" means two or more. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can be represented by: a, b, c, ab, ac, bc, or abc, where a, b, c can be single or multiple.
[0240] It should be understood that in various embodiments of the present invention, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0241] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0242] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described equipment, devices and units can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0243] In the several embodiments provided by the present invention, it should be understood that the disclosed devices, apparatuses and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0244] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0245] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0246] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage media include: various media that can store program codes, such as USB flash drives, mobile hard disks, read-only memories (ROM), random access memories (RAM), magnetic disks or optical disks.
[0247] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A periodic signal detection method based on periodic sparse attention, characterized in that: The method comprises: S1. Obtain the video data to be detected, perform data preprocessing, and obtain the preprocessed video data; S2, inputting the preprocessed video data into a periodic signal detection model based on periodic sparse attention to obtain a model output; wherein the periodic signal detection model includes: a convolution module, a block coding module, a hierarchical time period transformer module and a signal prediction head module; S3, performing data post-processing on the model output to obtain a periodic signal detection result; The step of inputting the preprocessed video data into a periodic signal detection model based on periodic sparse attention to obtain a model output comprises: S21, inputting the preprocessed video data into the convolution module for primary feature extraction to obtain a convolution module output; S22, inputting the output of the convolution module into the block coding module for division to obtain the output of the block coding module; S23, inputting the output of the block coding module into the hierarchical time period converter module for periodic feature extraction to obtain the output of the hierarchical time period converter module; S24, inputting the output of the hierarchical time period transformer module into the signal prediction head module for projection to obtain waveform characteristics of the periodic signal; The hierarchical time period converter module includes: a first time period converter submodule, a second time period converter submodule and a third time period converter submodule; The step of inputting the block coding module output to the hierarchical time period transformer module for periodic feature extraction in S23 to obtain the hierarchical time period transformer module output includes: S231, inputting the block coding module output into the first time period converter submodule to obtain the first time period converter submodule output; S232, inputting the output of the first time period converter submodule into the second time period converter submodule to obtain an output of the second time period converter submodule; S233, inputting the output of the second time period converter submodule into the third time period converter submodule to obtain a hierarchical time period converter module output; The first time period transformer submodule includes: a downsampling module, a pre-attention module, a fine attention module, a spatiotemporal feedforward module and an upsampling module; The step of inputting the block coding module output to the first time period converter submodule in S231 to obtain the first time period converter submodule output includes: S2311, inputting the block encoding module output into the down-sampling module to obtain the down-sampling module output; The downsampling module includes n downsampling submodules, where n is a sampling coefficient; each downsampling submodule includes a downsampling batch normalization layer and a downsampling three-dimensional convolution layer; S2312, inputting the down-sampling module output into the pre-attention module to obtain the pre-attention module output; S2313, inputting the pre-attention module output into the fine attention module to obtain a fine attention module output; S2314, inputting the output of the fine attention module into the spatiotemporal feedforward module to obtain the spatiotemporal feedforward module output; S2315, inputting the output of the spatiotemporal feedforward module into the up-sampling module to obtain the output of the first time period converter submodule; The upsampling module includes n upsampling submodules, where n is a sampling coefficient; each upsampling submodule includes an upsampling layer, an upsampling convolution layer, an upsampling batch normalization layer, and an exponential linear unit (ELU) activation layer; The output of the pre-attention module in S2312 is as shown in the following equations (1) and (2): K g =gather(K,topkIndex(Score)) (1) V g =gather(V,topkIndex(Score)) (2) In the formula, K g represents the aggregated key, gather represents the aggregation function, K represents the key, topkIndex represents the function for obtaining the index of the top k values, Score represents the pre-attention score, V g represents the aggregated value, and V represents the value; The output of the fine attention module in S2313 is shown in the following formula (3): MHSA=Concat(SA1,SA2,SA i ,...,IN n )W (3) Among them, MHSA represents the output of the fine attention module, Concat represents the connection function, W represents the weight matrix, and SA i represents the output of the i-th self-attention head, as shown in the following formula (4): In the formula, Sofxmax represents the activation function, Q represents the query, and K g represents the key after pre-attention aggregation, T represents matrix transpose, D represents the dimension of single-head attention, V g represents the value after pre-attention aggregation, LCE represents the context enhancement module, and V represents the value.
2. The method according to claim 1, characterized in that The spatiotemporal feedforward module includes a first fully connected layer, a hidden layer, and a second fully connected layer; The hidden layer includes a three-dimensional convolution layer of a spatiotemporal feedforward module, a batch normalization layer of the spatiotemporal feedforward module, and a Gaussian error linear unit GELU activation layer.
3. A periodic signal detection device based on periodic sparse attention, the periodic signal detection device based on periodic sparse attention is used to implement the periodic signal detection method based on periodic sparse attention according to any one of claims 1-2, characterized in that: The device comprises: An acquisition module is used to acquire the video data to be detected, perform data preprocessing, and obtain preprocessed video data; An input module, used for inputting the preprocessed video data into a periodic signal detection model based on periodic sparse attention to obtain a model output; wherein the periodic signal detection model comprises: a convolution module, a block coding module, a hierarchical time period transformer module and a signal prediction head module; An output module, used for performing data post-processing on the model output to obtain a periodic signal detection result; The step of inputting the preprocessed video data into a periodic signal detection model based on periodic sparse attention to obtain a model output comprises: S21, inputting the preprocessed video data into the convolution module for primary feature extraction to obtain a convolution module output; S22, inputting the output of the convolution module into the block coding module for division to obtain the output of the block coding module; S23, inputting the output of the block coding module into the hierarchical time period converter module for periodic feature extraction to obtain the output of the hierarchical time period converter module; S24, inputting the output of the hierarchical time period transformer module into the signal prediction head module for projection to obtain waveform characteristics of the periodic signal; The hierarchical time period converter module includes: a first time period converter submodule, a second time period converter submodule and a third time period converter submodule; The step of inputting the block coding module output to the hierarchical time period transformer module for periodic feature extraction in S23 to obtain the hierarchical time period transformer module output includes: S231, inputting the block coding module output into the first time period converter submodule to obtain the first time period converter submodule output; S232, inputting the output of the first time period converter submodule into the second time period converter submodule to obtain an output of the second time period converter submodule; S233, inputting the output of the second time period converter submodule into the third time period converter submodule to obtain a hierarchical time period converter module output; The first time period transformer submodule includes: a downsampling module, a pre-attention module, a fine attention module, a spatiotemporal feedforward module and an upsampling module; The step of inputting the block coding module output to the first time period converter submodule in S231 to obtain the first time period converter submodule output includes: S2311, inputting the block encoding module output into the down-sampling module to obtain the down-sampling module output; The downsampling module includes n downsampling submodules, where n is a sampling coefficient; each downsampling submodule includes a downsampling batch normalization layer and a downsampling three-dimensional convolution layer; S2312, inputting the down-sampling module output into the pre-attention module to obtain the pre-attention module output; S2313, inputting the pre-attention module output into the fine attention module to obtain a fine attention module output; S2314, inputting the output of the fine attention module into the spatiotemporal feedforward module to obtain the spatiotemporal feedforward module output; S2315, inputting the output of the spatiotemporal feedforward module into the up-sampling module to obtain the output of the first time period converter submodule; The upsampling module includes n upsampling submodules, where n is a sampling coefficient; each upsampling submodule includes an upsampling layer, an upsampling convolution layer, an upsampling batch normalization layer, and an exponential linear unit (ELU) activation layer; The output of the pre-attention module in S2312 is as shown in the following equations (1) and (2): K g =gather(K,topkIndex(Score)) (1) V g =gather(V,topkIndex(Score)) (2) In the formula, K g represents the aggregated key, gather represents the aggregation function, K represents the key, topkIndex represents the function for obtaining the index of the top k values, Score represents the pre-attention score, V g represents the aggregated value, and V represents the value; The output of the fine attention module in S2313 is shown in the following formula (3): MHSA=Concat(SA1,SA2,SA i ,...,IN h )W (3) Among them, MHSA represents the output of the fine attention module, Concat represents the connection function, W represents the weight matrix, and SA i represents the output of the i-th self-attention head, as shown in the following formula (4): In the formula, Sofxmax represents the activation function, Q represents the query, and K g represents the key after pre-attention aggregation, T represents matrix transpose, D represents the dimension of single-head attention, V g represents the value after pre-attention aggregation, LCE represents the context enhancement module, and V represents the value.
4. A periodic signal detection device, characterized in that: The periodic signal detection device comprises: processor; A memory having computer-readable instructions stored thereon, wherein when the computer-readable instructions are executed by the processor, the method according to any one of claims 1 to 2 is implemented.
5. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program codes, which can be called by a processor to execute the method according to any one of claims 1 to 2.
