A method for monitoring the posture of a person getting out of bed at night

By introducing a lightweight self-attention LSA module, the self-attention mechanism is simplified and the Softmax layer is removed, and a lightweight human body attitude detection model is built at night, which solves the problem of high computing costs on small edge devices and achieves high efficiency and low cost Test of human body's posture at night.

CN118430183BActive Publication Date: 2024-11-08THE FIRST MEDICAL CENT CHINESE PLA GENERAL HOSPITAL
View PDF 0 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

The existing nighttime human body attitude alarm monitoring technology has high computing cost on small edge devices, and the existence of a Softmax layer causes low computing efficiency, making it difficult to effectively deploy on low-cost devices.

Method used

The lightweight self-attention LSA (LSA) module is proposed. By simplifying the self-attention mechanism, it realizes simple multiplication of query, key and value matrix, and dynamically changes the matrix calculation order, removes the Softmax layer, and builds a lightweight human body's exit from bed pose at night. The detection model, including multiple linear layers, front feedback network, converter units and decoders, is suitable for small edge devices.

Benefits of technology

Efficient night-time human body exit posture detection is realized on small edge devices, reducing calculation costs, maintaining the same performance as traditional self-attention, and improving detection efficiency and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118430183B_ABST
    Figure CN118430183B_ABST
Patent Text Reader

Abstract

The present invention proposes a method for monitoring the posture alarm of a person getting out of bed at night, and relates to the technical field of image recognition. The present invention proposes a process for detecting the posture of a person getting out of bed at night, including obtaining a data set of a person getting out of bed at night, constructing a lightweight self-attention LSA, constructing a forward feedback network FFN, constructing a first-order transformer unit OTU, constructing a second-order transformer unit TTU, constructing a lightweight decoder LD, constructing a posture detection model for a person getting out of bed at night, and training the posture detection model for a person getting out of bed at night and detecting it in real time; at the same time, a lightweight self-attention LSA is proposed, which can realize simple multiplication of the three matrices of query, key and value, and can dynamically change the order of calculation of the three matrices. The lightweight self-attention LSA is applied to the scene of detecting the posture of a person getting out of bed at night, and can use less edge computing cost while achieving superior performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of image recognition, and in particular relates to an alarm monitoring method for a posture of a human body getting out of bed at night. Background Art

[0002] Nighttime human posture alarm monitoring for getting out of bed is of great significance. At night, people's alertness is reduced, and the elderly or patients may get into accidents when getting out of bed. Nighttime human posture monitoring for getting out of bed can track human posture in real time, especially the movement of getting out of bed. Once an abnormality is detected, an alarm will be triggered immediately, effectively reducing the risk of falling at night and protecting the user's safety. At the same time, this technology also helps caregivers understand the nighttime activities of the cared-for person and provide timely help.

[0003] The use of image recognition technology for nighttime posture alarm monitoring of people getting out of bed has significant effectiveness. This technology captures images through a camera without touching the human body, achieving non-invasive real-time monitoring, which is convenient and does not disturb the user. The visual algorithm can accurately and quickly identify human posture in the real-time video stream. Once an abnormal movement such as getting out of bed at night is detected, the system can immediately trigger an alarm, ensuring the real-time and accuracy of monitoring. In addition, the technology is low-cost, easy to deploy, and can record image data for subsequent analysis. It is also scalable and can be linked with smart home systems to improve the level of intelligence in home security management.

[0004] Recently, visual transformers have become very popular and have shown superior performance in various visual tasks. However, the computational cost of deploying visual transformers in many applications is high, partly due to the presence of Softmax layers in the attention module. If the Softmax layer is properly reconstructed or replaced, the computational cost of visual transformers can be reduced, making visual transformers easy to deploy in many applications. Summary of the invention

[0005] The present invention provides a method for monitoring the posture alarm of a person getting out of bed at night, and aims to propose a lightweight self-attention LSA, which can realize simple multiplication of three matrices: query, key and value, and can dynamically change the calculation order of the three matrices, and realize linear calculation of the number of tokens and the number of channels. At the same time, no Softmax layer is required. Compared with traditional self-attention, lightweight self-attention LSA has a faster calculation speed on small edge devices, and its performance is at the same level as traditional self-attention. Applying lightweight self-attention LSA to the scene of detecting the posture of a person getting out of bed at night can achieve superior performance while using less edge computing cost.

[0006] The present invention aims to improve the traditional self-attention and provide a method for monitoring the posture of a person getting out of bed at night, comprising the following steps:

[0007] S1. Obtain a dataset of postures of people getting out of bed at night. Use a night vision camera to continuously collect video data of the human body at night, obtain images of people getting out of bed by extracting frames from the video, and annotate the images of people getting out of bed with postures of people getting out of bed. After the annotation is completed, obtain a dataset of postures of people getting out of bed at night.

[0008] S2, build lightweight self-attention LSA, including multiple linear layers;

[0009] S3. Build a feedforward network FFN, including 3×3 convolution, Leaky ReLU activation function and deep convolution;

[0010] S4, construct a first-order transformer unit OTU, including a normalization layer, a lightweight self-attention LSA and a feedforward network FFN;

[0011] S5. Construct a second-order transformer unit TTU, including a normalization layer, a lightweight self-attention LSA, and a feedforward network FFN;

[0012] S6. Construct a lightweight decoder LD, including bilinear interpolation, ReLU activation function and 3×3 convolution;

[0013] S7, building a nighttime human getting out of bed posture detection model, including input, image block embedding, multiple first-order transformer units OTU, multiple second-order transformer units TTU, lightweight decoder LD and output;

[0014] S8. Train a model for detecting the posture of a person getting out of bed at night and conduct real-time detection. Use a data set of postures of a person getting out of bed at night to train the model for detecting the posture of a person getting out of bed at night. After the training is completed, use a night vision camera to collect real-time video data of the area where the human body is located in a night scene. Input the single-frame image obtained by extracting frames per second into the model for detecting the posture of a person getting out of bed at night to obtain the posture detection result. If the posture of a person getting out of bed is detected, an alarm message is output.

[0015] Preferably, in step S2, for lightweight self-attention LSA, the input feature F LSAIn , F LSAIn ∈R H×W×C , H, W and C represent the input features F LSAIn The height, width and channel of F LSAIn Transform the dimension so that F LSAIn ∈R N×D , N = H × W, D = C, through the linear layer W Q W K , and W V Generate Q, K and V, Q = W Q F LSAIn , K=W k F LSAIn , V=W VF LSAIn , where W Q ∈R D×D , W K ∈R D×D , W V ∈R D×D , Q∈R N×D , K∈R N×D , V∈R N×D , the output of lightweight self-attention LSA is F LSAOut , F LSAOut ∈R N×D , when N>D, When N <D, pass Transpose the matrix to get, is the normalized matrix of Q, is the normalized matrix of K, obtained by calculating each column of Q Right now Q i is the i-th column of Q, Q i ∈R N×1 , 1≤i≤D,|Q i | 1 It's Q i The L1 norm of is obtained by calculating each column of K Right now K j is the jth column of K, K j ∈R N×1 , 1≤j≤D,|K j | 1 It's K j The L1 norm of F LSAOut Transform the dimension so that F LSAOut ∈R H×W×C .

[0016] Preferably, in step S3, for the feedforward network FFN, the input feature F FFNIn , F FFNIn ∈R H×W×C , H, W and C represent the input features F FFNIn The height, width and channel of the forward feedback network FFN are F FFNOut , F FFNOut ∈R H×W×C , F FFNOut =C2 3×3 (DWConv(LR(C1 3×3 (F FFNIn )))), C1 3×3 is the first 3×3 convolution, LR is the Leaky ReLU activation function, DWConv is the depth convolution, C2 3×3It is the second 3×3 convolution.

[0017] Preferably, in step S4, for the first-order transformer unit OTU, the input feature F OTUIn , F OTUIn ∈R H×W×C , H, W and C represent the input features F OTUIn The height, width and channel of F are first obtained. OTUm1 , F OTUm1 ∈R H×W×C , F OTUm1 =LSA(LN(F OTUIn ))+F OTUIn , LN represents the normalization layer, LSA represents the lightweight self-attention LSA, + ​​represents element-by-element addition, and then the output F of the first-order transformer unit OTU is obtained OTUOut , F OTUOut ∈R H×W×C , F OTUOut =FFN(LN(F OTUm1 ))+F OTUm1 , LN represents the normalization layer, FFN represents the feedforward network FFN, and + represents element-by-element addition.

[0018] Preferably, in step S5, for the second-order transformer unit TTU, the input feature F TTUIn , F TTUIn ∈R H×W×C , H, W and C represent the input features F TTUIn The height, width and channel of F are first obtained. TTUm1 , F TTUm1 ∈R H×W×C , F TTUm1 =LSA(LN(F TTUIn ))+F TTUIn , LN represents the normalization layer, LSA represents the lightweight self-attention LSA, + ​​represents element-by-element addition, and then we get F TTUm2 , F TTUm2 ∈R H×W×C , F TTUm2 =LSA(LN(F TTUm1 ))+F TTUm1 , LN represents the normalization layer, LSA represents the lightweight self-attention LSA, + ​​represents element-by-element addition, and finally the output F of the second-order transformer unit TTU is obtained TTUOut , F TTUOut ∈R H×W×C , F TTUOut =FFN(LN(F TTUm2 ))+F TTUm2 , LN represents the normalization layer, FFN represents the feedforward network FFN, and + represents element-by-element addition.

[0019] Preferably, in step S6, for the lightweight decoder LD, the input feature F LDIn , F LDIn ∈R H×W×C , H, W and C represent the input features F LDIn The height, width and channels of the lightweight decoder LD are F LDOut , H 1 , W 1 and C 1 Yes F LDOut The height, width and channels of , Bilinear represents bilinear interpolation, F LDIn Upsampling is performed through Bilinear, ReLU represents the ReLU activation function, C 3×3 Represents a 3×3 convolution.

[0020] Preferably, in step S7, for the nighttime human getting out of bed posture detection model, the image block embedding is implemented by traditional PatchEmbed, and a single frame image I is input, I∈R H×W×3 , H, W and 3 represent the height, width and channel of I. I is embedded in the image block to obtain the feature F. H 1 , W 1 and C are the height, width and channel of F. F is passed through multiple first-order transformer units OTU connected in series to obtain the characteristic F 1 , That is F 1 Consistent with the dimension of F, 1 After multiple second-order transformer units TTU are connected in series, the characteristic F is obtained. 2 , That is F 2 and F 1 The dimensions are consistent, and F 2 After the lightweight decoder LD, the output F of the nighttime human getting out of bed posture detection model is obtained 3 , That is F 3 The height and width of F are consistent with those of I. 3 The number of channels is C 1 .

[0021] Compared with the prior art, the present invention has the following technical effects:

[0022] The technical solution provided by the present invention proposes a lightweight self-attention LSA, which can realize simple multiplication of the three matrices of query, key and value, and can dynamically change the calculation order of the three matrices, and realize linear calculation of the number of tokens and the number of channels. At the same time, no Softmax layer is required. Compared with traditional self-attention, lightweight self-attention LSA is calculated faster on small edge devices, and its performance is maintained at the same level as traditional self-attention. Applying lightweight self-attention LSA in the scene of human getting out of bed posture detection at night can achieve superior performance while using less edge computing cost. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] Figure 1 The present invention provides a flow chart for detecting the posture of a person getting out of bed at night.

[0024] Figure 2 This is a structural diagram of the lightweight self-attention LSA provided by the present invention.

[0025] Figure 3 It is a structural diagram of the forward feedback network FFN provided by the present invention.

[0026] Figure 4 It is a structural diagram of the first-order converter unit OTU provided by the present invention.

[0027] Figure 5 It is a structural diagram of the second-order converter unit TTU provided by the present invention.

[0028] Figure 6 This is a structural diagram of the lightweight decoder LD provided by the present invention.

[0029] Figure 7 It is a structural diagram of a model for detecting the posture of a human body getting out of bed at night provided by the present invention. DETAILED DESCRIPTION

[0030] The present invention aims to propose an alarm monitoring method for the posture of a person getting out of bed at night, and proposes a lightweight self-attention LSA, which can realize simple multiplication of the three matrices of query, key and value, and can dynamically change the calculation order of the three matrices, and realize linear calculation of the number of tokens and the number of channels. At the same time, no Softmax layer is required. Compared with traditional self-attention, lightweight self-attention LSA has a faster calculation speed on small edge devices, and its performance is at the same level as traditional self-attention. Applying lightweight self-attention LSA in the scene of human getting out of bed posture detection at night can achieve superior performance while using less edge computing cost.

[0031] See also Figure 1 As shown, a method for monitoring the posture of a person getting out of bed at night in an embodiment of the present application is as follows:

[0032] S1. Obtain a dataset of postures of people getting out of bed at night. Use a night vision camera to continuously collect video data of the human body at night. Obtain 200 images of people getting out of bed by extracting frames from the video. Annotate the images of people getting out of bed with postures of people getting out of bed. After the annotation is completed, obtain a dataset of postures of people getting out of bed at night.

[0033] S2, build lightweight self-attention LSA, which includes 3 linear layers;

[0034] S3. Build a feedforward network FFN, which includes 2 3×3 convolutions, 1 Leaky ReLU activation function and 1 depth convolution;

[0035] S4, construct a first-order transformer unit OTU, including 2 normalization layers, 1 lightweight self-attention LSA and 1 feedforward network FFN;

[0036] S5. Construct a second-order transformer unit TTU, which includes 3 normalization layers, 2 lightweight self-attention LSAs, and 1 feedforward network FFN.

[0037] S6. Build a lightweight decoder LD, including 1 bilinear interpolation, 1 ReLU activation function and 1 3×3 convolution;

[0038] S7. Build a nighttime human getting out of bed posture detection model, including input, 1 image block embedding, 2 first-order transformer units OTU, 2 second-order transformer units TTU, 1 lightweight decoder LD and output;

[0039] S8. Train a model for detecting the posture of a person getting out of bed at night and conduct real-time detection. Use a data set of postures of a person getting out of bed at night to train the model for detecting the posture of a person getting out of bed at night. After the training is completed, use a night vision camera to collect real-time video data of the area where the human body is located in a night scene. Input the single-frame image obtained by extracting frames per second into the model for detecting the posture of a person getting out of bed at night to obtain the posture detection result. If the posture of a person getting out of bed is detected, an alarm message is output.

[0040] Furthermore, in step S2, for lightweight self-attention LSA, its structure is as follows Figure 2 As shown, input feature F LSAIn , F LSAIn ∈R H×W×C , H, W and C represent the input features F LSAIn The height, width and channel of F LSAIn Transform the dimension so that F LSAIn ∈R N×D , N = H × W, D = C, through the linear layer W Q W K , and W V Generate Q, K and V, Q = W Q FLSAIn , K=W K F LSAIn , V=W V F LSAIn , where W Q ∈R D×D , W K ∈R D×D , W V ∈R D×D , Q∈R N×D , K∈R N×D , V∈R N×D , the output of lightweight self-attention LSA is F LSAOut , F LSAOut ∈R N×D , when N>D, When N <D, pass Transpose the matrix to get, is the normalized matrix of Q, is the normalized matrix of K, obtained by calculating each column of Q Right now Q i is the i-th column of Q, Q i ∈R N×1 , 1≤i≤D,|Q i | 1 It's Q i The L1 norm of is obtained by calculating each column of K Right now K j is the jth column of K, K j ∈R N ×1 , 1≤j≤D,|K j | 1 It's K j The L1 norm of F LSAOut Transform the dimension so that F LSAOut ∈R H×W×C .

[0041] Further, in step S3, for the forward feedback network FFN, its structure is as follows Figure 3 As shown, input feature F FFNIn , F FFNIn ∈R H×W×C , H, W and C represent the input features F FFNIn The height, width and channel of the forward feedback network FFN are F FFNOut , F FFNOut ∈R H×W×C , F FFNOut =C2 3×3 (DWConv(LR(C1 3×3 (FFFNIn )))), C1 3×3 is the first 3×3 convolution, LR is the Leaky ReLU activation function, DWConv is the depth convolution, C2 3×3 It is the second 3×3 convolution.

[0042] Further, in step S4, for the first-order converter unit OTU, its structure is as follows: Figure 4 As shown, input feature F OTUIn , F OTUIn ∈R H×W×C , H, W and C represent the input features F OTUIn The height, width and channel of F are first obtained. OTUm1 , F OTUm1 ∈R H×W×C , F OTUm1 =LSA(LN(F OTUIn ))+F OTUIn , LN represents the normalization layer, LSA represents the lightweight self-attention LSA, + ​​represents element-by-element addition, and then the output F of the first-order transformer unit OTU is obtained OTUOut , F OTUOut ∈R H×W×C , F OTUOut =FFN(LN(F OTUm1 ))+F OTUm1 , LN represents the normalization layer, FFN represents the feedforward network FFN, and + represents element-by-element addition.

[0043] Further, in step S5, for the second-order transformer unit TTU, its structure is as follows Figure 5 As shown, input feature F TTUIn , F TTUIn ∈R H×W×C , H, W and C represent the input features F TTUIn The height, width and channel of F are first obtained. TTUm1 , F TTUm1 ∈R H×W×C , F TTUm1 =LSA(LN(F TTUIn ))+F TTUIn , LN represents the normalization layer, LSA represents the lightweight self-attention LSA, + ​​represents element-by-element addition, and then we get F TTUm2 , F TTUm2 ∈R H×W×C , F TTUm2 =LSA(LN(F TTUm1 ))+F TTUm1 , LN represents the normalization layer, LSA represents the lightweight self-attention LSA, + ​​represents element-by-element addition, and finally the output F of the second-order transformer unit TTU is obtained TTUOut , F TTUOut∈R H×W×C , F TTUOut =FFN(LN(F TTUm2 ))+F TTUm2 , LN represents the normalization layer, FFN represents the feedforward network FFN, and + represents element-by-element addition.

[0044] Further, in step S6, for the lightweight decoder LD, its structure is as follows Figure 6 As shown, input feature F LDIn , F LDIn ∈R H×W×C , H, W and C represent the input features F LDIn The height, width and channels of the lightweight decoder LD are F LDOut , H 1 , W 1 and C 1 Yes F LDOut The height, width and channels of , Bilinear represents bilinear interpolation, F LDIn Upsampling is performed through Bilinear, ReLU represents the ReLU activation function, C 3×3 Represents a 3×3 convolution.

[0045] Further, in step S7, for the nighttime human body getting out of bed posture detection model, its structure is as follows: Figure 7 As shown, image block embedding is implemented by traditional PatchEmbed, inputting a single frame image I, I∈R 640×640×3 , 640, 640 and 3 represent the height, width and channel of I. I is embedded in the image block to obtain the feature F, F∈R 32×32×128 , 32, 32 and 128 are the height, width and channel of F. F is passed through two first-order transformer units OTU connected in series to obtain the characteristic F 1 , F 1 ∈R 32×32×128 , that is, F 1 Consistent with the dimension of F, 1 After two second-order transformer units TTU are connected in series, the characteristic F is obtained. 2 , F 2 ∈R 32×32×128 , that is, F 2 and F 1 The dimensions are consistent, and F 2 After the lightweight decoder LD, the output F of the nighttime human getting out of bed posture detection model is obtained 3 , F 3 ∈R 640×640×32 , that is, F 3 The height and width of F are consistent with those of I. 3 The number of channels is 32.

[0046] The above are only preferred embodiments of the present invention. It should be pointed out that a person skilled in the art can make several modifications and improvements without departing from the inventive concept of the present invention, and these all fall within the protection scope of the present invention.

Claims

1. A method for monitoring the posture of a person getting out of bed at night, characterized in that: The following steps are involved: S1. Obtain a dataset of postures of people getting out of bed at night. Use a night vision camera to continuously collect video data of the human body at night, obtain images of people getting out of bed by extracting frames from the video, and annotate the images of people getting out of bed with postures of people getting out of bed. After the annotation is completed, obtain a dataset of postures of people getting out of bed at night. S2, construct a lightweight self-attention LSA, including multiple linear layers; the lightweight self-attention LSA, input feature F LSAIn , F LSAIn ∈R H×W×C , H, W and C represent the input features F LSAIn The height, width and channel of F LSAIn Transform the dimension so that F LSAIn ∈R N×D , N = H × W, D = C, through the linear layer W Q W K , and W V Generate Q, K and V, Q = W Q F LSAIn , K=W K F LSAIn , V=W V F LSAIn , where W Q ∈R D×D , W K ∈R D×D , W V ∈R D×D , Q∈R N×D , K∈R N×D , V∈R N×D , the output of lightweight self-attention LSA is F LSAOut , F LSAOut ∈R N×D , when N>D, When N <D, pass Transpose the matrix to get, is the normalized matrix of Q, is the normalized matrix of K, obtained by calculating each column of Q Right now Q i is the i-th column of Q, Q i ∈R N×1 , 1≤i≤D,|Q i |1 is Q i The L1 norm of is obtained by calculating each column of K Right now K j is the jth column of K, K j ∈R N×1 , 1≤j≤D,|K j |1 is K j The L1 norm of F LSAOut Transform the dimension so that F LSAOut ∈R H×W×C ; S3, construct a feedforward network FFN, including 3×3 convolution, Leaky ReLU activation function and deep convolution; the feedforward network FFN, input feature F FFNIn , F FFNIn ∈R H×W×C , H, W and C represent the input features F FFNIn The height, width and channel of the forward feedback network FFN are F FFNO ut,F FFNOut ∈R H×W×C , F FFNOut =C2 3×3 (DWConv(LR(C1 3×3 (F FFNIn )))), C1 3×3 is the first 3×3 convolution, LR is the Leaky ReLU activation function, DWConv is the depth convolution, C2 3×3 It is the second 3×3 convolution; S4, construct a first-order transformer unit OTU, including a normalization layer, a lightweight self-attention LSA and a forward feedback network FFN; the first-order transformer unit OTU, input feature F OTUIn , F OTUIn ∈R H×W×C , H, W and C represent the input features F OTUIn The height, width and channel of F are first obtained. OTU m1,F OTUm1 ∈R H ×W× C , F OTUm1 =LSA(LN(F OTUIn ))+F OTUIn , LN represents the normalization layer, LSA represents the lightweight self-attention LSA, + ​​represents element-by-element addition, and then the output F of the first-order transformer unit OTU is obtained OTUOut , F OTUOut ∈R H×W×C , F OTUOut =FFN(LN(F OTUm1 ))+F OTUm1 , LN represents the normalization layer, FFN represents the feedforward network FFN, and + represents element-by-element addition; S5, construct a second-order transformer unit TTU, including a normalization layer, a lightweight self-attention LSA and a feedforward network FFN; the second-order transformer unit TTU, input feature F TTUI n,F TTUIn ∈R H×W×C , H, W and C represent the input features F TTUIn The height, width and channel of F are first obtained. TTU m1,F TTUm1 ∈R H×W×C , F TTUm1 =LSA(LN(F TTUIn ))+F TTUIn , LN represents the normalization layer, LSA represents the lightweight self-attention LSA, + ​​represents element-by-element addition, and then we get F TTUm2 , F TTUm2 ∈R H × W×C , F TTUm2 =LSA(LN(F TTUm1 ))+F TTUm1 , LN represents the normalization layer, LSA represents the lightweight self-attention LSA, + ​​represents element-by-element addition, and finally the output F of the second-order transformer unit TTU is obtained TTUOut , F TTUOut ∈R H× W ×C , F TTUOut =FFN(LN(F TTUm2 ))+F TTUm2 , LN represents the normalization layer, FFN represents the feedforward network FFN, and + represents element-by-element addition; S6. Construct a lightweight decoder LD, including bilinear interpolation, ReLU activation function and 3×3 convolution; the lightweight decoder LD, input feature F LDIn , F LDIn ∈R H× W ×C , H, W and C represent the input features F LDIn The height, width and channels of the lightweight decoder LD are H1, W1 and C1 are F LDOut The height, width and channels of F, Bilinear represents bilinear interpolation, LDIn Upsampling is performed through Bilinear, ReLU represents the ReLU activation function, C 3×3 Represents 3×3 convolution; S7, construct a nighttime human getting out of bed posture detection model, including input, image block embedding, multiple first-order transformer units OTU, multiple second-order transformer units TTU, lightweight decoder LD and output; the nighttime human getting out of bed posture detection model, image block embedding is implemented by traditional PatchEmbed, input single frame image I, I∈R H×W×3 , H, W and 3 represent the height, width and channel of I, and I is embedded in the image block to obtain the feature H1, W1 and C are the height, width and channel of F. F is passed through multiple first-order transformer units OTU connected in series to obtain the characteristic That is, F1 and , have the same dimensions. F1 is passed through multiple second-order transformer units TTU connected in series to obtain the characteristic That is, the dimensions of F2 and F1 are consistent. F2 is passed through the lightweight decoder LD to obtain the output of the nighttime human getting out of bed posture detection model. That is, the height and width of F3 are consistent with those of I, and the number of channels of F3 is C1; S8. Train a model for detecting the posture of a person getting out of bed at night and conduct real-time detection. Use a data set of postures of a person getting out of bed at night to train the model for detecting the posture of a person getting out of bed at night. After the training is completed, use a night vision camera to collect real-time video data of the area where the human body is located in a night scene. Input the single-frame image obtained by extracting frames per second into the model for detecting the posture of a person getting out of bed at night to obtain the posture detection result. If the posture of a person getting out of bed is detected, an alarm message is output.