Abnormal behavior incremental detection method and system based on gan synthesis and contrast learning
By using a GAN-based synthesis and contrastive learning approach, image frames are reconstructed and the reconstructed residual field is calculated to generate a contrastive weight map. Combined with gravity direction and conformal probability calibration, the problem of insufficient robustness and real-time performance in traditional methods is solved, and high-precision abnormal behavior detection is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-29
- Publication Date
- 2026-04-07
AI Technical Summary
Traditional abnormal behavior identification methods struggle to guarantee robustness and real-time performance in complex scenarios, exhibiting high false alarm or false negative rates, failing to adapt to environmental changes, and struggling to identify rare abnormal behaviors.
A method based on GAN synthesis and contrastive learning is adopted. Image frames are reconstructed by generating adversarial networks, the reconstructed residual field is calculated, and a contrastive learning encoder is used to generate a contrastive weight map. Combined with gravity direction and conformal probability calibration, a weighted structure tensor is constructed to calculate the degree of anomaly.
It improves the accuracy and robustness of abnormal behavior detection, reduces false alarm and false negative rates, and achieves real-time detection with low latency and high reliability, adapting to complex environmental changes.
Smart Images

Figure CN121214347B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of abnormal behavior detection technology, and more specifically, to an incremental detection method and system for abnormal behavior based on GAN synthesis and contrastive learning. Background Technology
[0002] With the advancement of smart community construction, the level of security management and services in public places has become a critical area that urgently needs improvement. Traditional methods relying on manual patrols or fixed cameras suffer from blind spots, slow response times, and high labor costs, making it difficult to meet increasingly complex security and service demands. Real-time sensing and rapid response are particularly important in incidents such as elderly falls, missing children, and sudden gatherings. Therefore, researching intelligent technologies capable of autonomously monitoring and identifying abnormal behavior has become a core development direction for smart communities and urban management.
[0003] Current methods for identifying abnormal behavior largely rely on supervised learning or rule-setting approaches. The main challenges are twofold: firstly, public spaces exhibit complex behavioral patterns and numerous rare or even unseen abnormal scenarios, leading to insufficient model recognition capabilities under long-tailed distributions; secondly, environmental changes (such as lighting, occlusion, and variations in crowd density) significantly interfere with recognition results, making it difficult for traditional models to guarantee robustness. Furthermore, fixed threshold methods often fail when faced with continuously changing scenarios, resulting in persistently high false positive or false negative rates.
[0004] Because public place surveillance tasks require long-term operation and real-time performance, detection methods need to perform high-precision calculations with limited hardware resources. However, traditional algorithms struggle to guarantee low-latency processing in complex scenarios and cannot adapt to environmental changes. This contradiction directly leads to performance degradation of the system over long-term operation, and even the inability to accurately identify abnormal behavior at critical moments. Summary of the Invention
[0005] This invention provides an incremental detection method and system for abnormal behavior based on GAN synthesis and contrastive learning, which solves the technical problems mentioned in the background art.
[0006] The first aspect is an incremental detection method for abnormal behavior based on GAN synthesis and contrastive learning, including:
[0007] Obtain the gravity direction vector and the corresponding orthogonal direction vector in the detection scene;
[0008] A generative adversarial network trained on normal behavior samples is used to reconstruct the image frame to be detected. The pixel difference between the image frame to be detected and the reconstructed image is calculated to obtain the reconstructed residual field.
[0009] A contrastive learning encoder trained using normal behavior samples encodes image patches of the image frame to be detected to obtain feature embeddings, and a contrastive weight map is generated based on the similarity between the feature embeddings and the normal behavior feature prototypes.
[0010] Within the human torso region, a weighted structure tensor is constructed by weighting and accumulating the spatial gradient of the reconstructed residual field in conjunction with the contrast weight map. The ratio of the energy projection values of the weighted structure tensor onto the gravity direction vector and the orthogonal direction vector is calculated as the gravity anisotropy index.
[0011] The baseline mean tensor is determined based on the weighted structure tensor of historical normal frames. A calibration set is constructed for the gravity anisotropy index after whitening, and then mapped to conformal probability values through statistical comparison.
[0012] The conformal probability value is used to update the weights, followed by the baseline mean tensor and the normal behavior feature prototype, to output the degree of abnormality of the image frame to be detected.
[0013] Secondly, the incremental detection system for abnormal behavior based on GAN synthesis and contrastive learning, applied to any of the aforementioned incremental detection methods for abnormal behavior based on GAN synthesis and contrastive learning, includes:
[0014] The data acquisition module obtains the gravity direction vector and the corresponding orthogonal direction vector in the detection scene;
[0015] The reconstruction residual module uses a generative adversarial network trained on normal behavior samples to reconstruct the image frame to be detected, calculates the pixel difference between the image frame to be detected and the reconstructed image, and obtains the reconstruction residual field.
[0016] The contrast weight module uses a contrastive learning encoder trained on normal behavior samples to encode image patches of the image frame to be detected to obtain feature embeddings, and generates a contrast weight map based on the similarity between the feature embeddings and the normal behavior feature prototypes.
[0017] In the anisotropic module, within the human torso region, a weighted structure tensor is constructed by weighting and accumulating the spatial gradient of the reconstructed residual field in conjunction with the contrast weight map. The ratio of the energy projection values of the weighted structure tensor in the gravity direction vector and the orthogonal direction vector is calculated as the gravity anisotropy index.
[0018] The conformal probability module determines the baseline mean tensor based on the weighted structure tensor of historical normal frames, constructs a calibration set for the gravity anisotropy index after whitening, and maps it to conformal probability values through statistical comparison.
[0019] The anomaly detection module updates the weights with conformal probability values, and sequentially uses the baseline mean tensor and normal behavior feature prototypes to output the degree of anomaly of the image frame to be detected.
[0020] The beneficial effects of this invention are as follows: by combining the reconstruction capabilities of generative adversarial networks with the feature discrimination capabilities of contrastive learning, the accuracy and robustness of abnormal behavior detection are effectively improved. This invention can not only accurately identify rare or unseen abnormal behaviors in complex and ever-changing public scenarios, but also adaptively update normal behavior features, thereby significantly reducing false positive and false negative rates. Simultaneously, by utilizing gravity direction constraints and conformal probability calibration mechanisms, this invention achieves low-latency and high-reliability real-time detection, meeting the needs of smart communities and urban security management for long-term stable operation and rapid response. Attached Figure Description
[0021] Figure 1 This is a flowchart of the abnormal behavior incremental detection method based on GAN synthesis and contrastive learning of the present invention;
[0022] Figure 2 This is a block diagram of the incremental detection system for abnormal behavior based on GAN synthesis and contrastive learning of the present invention. Detailed Implementation
[0023] The subject matter described herein will now be discussed with reference to exemplary embodiments. It should be understood that these embodiments are discussed only to enable those skilled in the art to better understand and implement the subject matter described herein, and changes may be made to the function and arrangement of the elements discussed without departing from the scope of this specification. Various processes or components may be omitted, substituted, or added as needed in the examples. Furthermore, features described in some examples may be combined in other examples.
[0024] Example 1
[0025] like Figures 1-2 As shown, the incremental detection method for abnormal behavior based on GAN synthesis and contrastive learning includes:
[0026] Obtain the gravity direction vector and the corresponding orthogonal direction vector in the detection scene;
[0027] A generative adversarial network trained on normal behavior samples is used to reconstruct the image frame to be detected. The pixel difference between the image frame to be detected and the reconstructed image is calculated to obtain the reconstructed residual field.
[0028] A contrastive learning encoder trained using normal behavior samples encodes image patches of the image frame to be detected to obtain feature embeddings, and a contrastive weight map is generated based on the similarity between the feature embeddings and the normal behavior feature prototypes.
[0029] Within the human torso region, a weighted structure tensor is constructed by weighting and accumulating the spatial gradient of the reconstructed residual field in conjunction with the contrast weight map. The ratio of the energy projection values of the weighted structure tensor onto the gravity direction vector and the orthogonal direction vector is calculated as the gravity anisotropy index.
[0030] The baseline mean tensor is determined based on the weighted structure tensor of historical normal frames. A calibration set is constructed for the gravity anisotropy index after whitening, and then mapped to conformal probability values through statistical comparison.
[0031] The conformal probability value is used to update the weights, followed by the baseline mean tensor and the normal behavior feature prototype, to output the degree of abnormality of the image frame to be detected.
[0032] In detail, the detection scenario refers to intelligent monitoring scenarios in the fields of smart communities and public safety, used to identify abnormal behaviors such as falls among the elderly. The detection scenario relies on equipment equipped with inertial measurement units and visual odometry to acquire prior information such as the direction of gravity in the scene, providing an environmental benchmark for abnormal behavior detection. Simultaneously, it must address real-world interference such as changes in lighting, occlusion, and low resolution to ensure the detection method operates effectively in complex daily environments.
[0033] In one embodiment of the present invention, obtaining the gravity direction vector and the corresponding orthogonal direction vector in the detection scene includes:
[0034] Acquire the angular velocity and acceleration output by the inertial measurement unit at each moment, as well as the pose output by the visual odometry.
[0035] The extended Kalman filter algorithm is used to fuse angular velocity, acceleration, and pose to obtain the fused attitude quaternion. ;
[0036] attitude quaternions Convert to a 3D rotation matrix The conversion formula is as follows:
[0037] ;
[0038] The standard gravity vector in the world coordinate system The 3D direction vector is obtained by transforming to the camera coordinate system using a 3D rotation matrix. ;
[0039] The camera intrinsic parameter matrix is determined as follows: ;in, and For pixel focal length, and Principal point coordinates;
[0040] Normalize and project the three-dimensional direction vectors to obtain the two-dimensional vectors of the image plane. ;
[0041] Normalize the two-dimensional vectors in the image plane to obtain the gravity direction vector. ;in, Indicates the modulus length;
[0042] The gravity direction vector is rotated by a counterclockwise 90-degree rotation operator to obtain an orthogonal direction vector. ; where the rotation operator is .
[0043] In detail, the angular velocity output by the inertial measurement unit is a physical quantity that describes the speed and direction of the detection device's rotation, and can reflect the device's rotational state around the xyz axes in three-dimensional space; the acceleration is a physical quantity that describes the rate of change of the device's linear motion velocity, including the device's own motion acceleration and gravitational acceleration components.
[0044] In detail, visual odometry calculates and outputs the pose of the detection device by continuously analyzing changes in feature points in an image sequence. The pose consists of two parts: position and orientation. Position refers to the coordinate information of the device in three-dimensional space, which describes the spatial location of the device; orientation refers to the orientation information of the device in three-dimensional space, which describes the placement angle of the device.
[0045] In detail, the Extended Kalman Filter (EKF) algorithm is a state estimation algorithm suitable for nonlinear systems, capable of handling noise and errors in sensor data. The EKF algorithm first predicts the device attitude based on the angular velocity and acceleration output from the inertial measurement unit (IMU) and the system motion model. Then, it introduces the pose output from the visual odometry (VAI) as an observation value, comparing and correcting it with the predicted value. Through an iterative prediction and update process, it suppresses noise interference from various sensor data, ultimately outputting more accurate fused attitude information.
[0046] In detail, a pose quaternion is a mathematical tool used to represent rotations in three-dimensional space, consisting of a real part... and three imaginary parts Composition. Compared to traditional Euler angles, attitude quaternions avoid gimbal lock problems and offer higher efficiency and accuracy in rotation calculations. Attitude quaternions are generated by fusing angular velocity, acceleration, and pose data using an extended Kalman filter algorithm, and serve as a representation of the attitude state of the detection device.
[0047] In detail, a 3D rotation matrix is a 3×3 orthogonal matrix used to describe the rotational transformation of an object in 3D space from one coordinate system to another. The 3D rotation matrix is obtained through attitude quaternion transformation, and the transformation formula strictly follows the mathematical correspondence between quaternions and rotation matrices. The matrix elements are composed of the squares and cross products of the quaternion components. The function of the 3D rotation matrix is to transform the standard gravity vector in the world coordinate system to the camera coordinate system, establishing a mapping relationship between the gravity directions of different coordinate systems.
[0048] In detail, the standard gravity vector is a vector representing the direction and magnitude of the Earth's gravitational field in the world coordinate system. Its direction is perpendicular to the Earth's surface and points towards the Earth's center, and its magnitude is the standard gravitational acceleration g, approximately 9.8 meters per second squared. Its expression in the world coordinate system is: The standard gravity vector is the original reference for calculating the direction of gravity.
[0049] In detail, the three-dimensional direction vector is the vector obtained in the camera coordinate system after the standard gravity vector has undergone a three-dimensional rotation matrix transformation. Its expression is: The three-dimensional direction vector retains the direction of the standard gravity vector, but the coordinate representation is based on the camera coordinate system, which can reflect the three-dimensional spatial orientation of gravity from the camera's perspective.
[0050] In detail, the intrinsic parameter matrix is a 3×3 matrix describing the relationship between the camera's optical characteristics and imaging geometry, in the form of: Here, fx and fy are the pixel focal lengths of the camera along the x and y axes, respectively, determining the scaling ratio of the camera image; cx and cy are the pixel coordinates of the principal point of the camera's imaging plane along the x and y axes, respectively, corresponding to the center position of the image plane. The intrinsic parameter matrix projects the three-dimensional direction vectors in the camera coordinate system onto the two-dimensional image plane, establishing a mapping relationship between the three-dimensional space and the image pixel coordinates.
[0051] In detail, the two-dimensional vector in the image plane is obtained by normalizing and projecting the three-dimensional direction vector in the camera coordinate system through an intrinsic parameter matrix, and its form is as follows: During projection, the xy and z components of the three-dimensional direction vector are normalized and calculated using the parameters fx, fy, cx, and cy of the intrinsic parameter matrix, ultimately yielding a two-dimensional vector represented by pixel coordinates. This two-dimensional vector in the image plane reflects the initial orientation of gravity on the image plane.
[0052] In detail, the gravity direction vector is a vector obtained by normalizing a two-dimensional vector in the image plane. Normalization makes the magnitude of the gravity direction vector 1, retaining only the direction of gravity in the image plane and removing the influence of the vector magnitude.
[0053] In detail, the rotation matrix is a 2×2 matrix, in the form of... A rotation matrix is used to rotate a vector on the image plane 90 degrees counterclockwise. The rotation matrix acts on the gravity direction vector and generates an orthogonal direction vector through matrix multiplication.
[0054] In one embodiment of the present invention, a generative adversarial network trained on normal behavior samples is used to reconstruct the image frame to be detected, and the pixel difference between the image frame to be detected and the reconstructed image is calculated to obtain the reconstructed residual field, including:
[0055] Construct a sample set of normal behaviors The normal behavior sample set includes a preset number of feature behavior sample images of equal format and size, and the feature behaviors include at least: walking, standing, sitting and squatting.
[0056] For each pixel in each feature behavior sample image, the pixel value is normalized to form a training image set. ;
[0057] Generative adversarial networks (GANs) consist of a generator G and a discriminator D, where:
[0058] The generator G contains 5 deconvolutional layers. The first layer takes a 128-dimensional random noise and image feature concatenation vector as input. The deconvolution kernel sizes are 4×4, 4×4, 4×4, 4×4, and 3×3, with a stride of 2. Each hidden layer is followed by a batch normalization layer and a ReLU activation function. The output layer uses the Tanh activation function and outputs a reconstructed image of size P×Q.
[0059] The discriminator D contains 5 convolutional layers with kernel sizes of 3×3, 4×4, 4×4, 4×4, and 4×4, and a stride of 2. The first hidden layer is followed by a LeakyReLU activation function, and the hidden layers of the remaining layers are connected to a batch normalization layer and a LeakyReLU activation function. The output layer is a 1-dimensional discrimination result.
[0060] The training loss function is ,in:
[0061] The least-squares adversarial loss is calculated using the following formula:
[0062] ;in, This indicates a sample averaging operation. Represents training images, This represents the discriminator's one-dimensional discrimination result on the training image;
[0063] The L1 reconstruction loss is calculated as follows:
[0064] ;in, This represents the set of pixel coordinates constructed from all pixel coordinates in the training image. This represents the reconstructed image output by the generator. Indicating characteristic behavior sample images in Pixel value at that location, Indicates the reconstructed image in Pixel value at;
[0065] Preset reconstruction loss weights;
[0066] Acquire the image frame to be detected The size of the image frame to be detected is equal to that of the training image;
[0067] The image frame to be detected is normalized by pixel values and then input into generator G to obtain the reconstructed image. ;
[0068] The pixel-by-pixel difference operation is performed on the image frame to be detected after pixel value normalization and the reconstructed image to obtain the reconstructed residual field.
[0069] In detail, the feature behavior sample images are the basic image data that constitute the normal behavior sample set. They have the characteristics of a predetermined number and completely consistent format and size. The feature behaviors they contain at least cover common normal behaviors of the elderly in community scenarios such as walking, standing, sitting, and squatting, and do not contain any abnormal behavior images. Thus, the generative adversarial network and contrastive learning encoder provide the raw data of normal behaviors, ensuring that the model can learn the image feature distribution of normal behaviors.
[0070] In detail, training images are image data formed by normalizing the pixel values of feature behavior sample images, thus constituting the training image set. Pixel value normalization is performed to eliminate the interference of pixel value scale differences between different images on model training, ensuring that the image pixel values are within a uniform numerical range. Training images directly serve as training input data for generative adversarial networks and contrastive learning encoders, providing standardized data for the model to learn the image features and semantic representations of normal behavior.
[0071] In detail, a Generative Adversarial Network (GNN) consists of two sub-networks: a generator (G) and a discriminator (D). Its core function is to learn the image distribution of normal behavior, which is then used to reconstruct the image frame to be detected. The generator G contains five deconvolutional layers. The first layer takes a concatenated vector of 128-dimensional random noise and image features as input. The deconvolutional kernel sizes are 4×4, 4×4, 4×4, 4×4, and 3×3, with a stride of 2 for each layer. Each hidden layer is followed by a batch normalization layer and a ReLU activation function. The output layer uses the Tanh activation function, resulting in a reconstructed image of size P×Q. The discriminator D contains five convolutional layers with kernel sizes of 3×3, 4×4, 4×4, 4×4, and 4×4, each with a stride of 2. The first hidden layer is followed by a LeakyReLU activation function. The remaining hidden layers are connected to a batch normalization layer and a LeakyReLU activation function. The output layer is a 1-dimensional discrimination result, used to distinguish whether the input image is a real training image or a reconstructed image output by the generator.
[0072] In detail, the least squares adversarial loss is the core adversarial loss function in the training of generative adversarial networks. The least squares adversarial loss is used to drive the discriminator to improve its ability to distinguish between real training images and generator-reconstructed images, while driving the generator to optimize its own parameters so that the generated reconstructed images are closer to the real training images, thereby allowing the generator to better learn the image distribution of normal behavior.
[0073] In detail, L1 reconstruction loss is a loss function used in generative adversarial network training to measure the pixel-level difference between real training images and generator-reconstructed images. L1 reconstruction loss quantifies the pixel-level deviation between the reconstructed image and the real image by calculating the mean of the absolute differences of all pixels between the two images, driving the generator to optimize and reduce this deviation, thus improving the accuracy of the reconstructed image.
[0074] In detail, the preset reconstruction loss weight is a manually set hyperparameter used to adjust the contribution of L1 reconstruction loss to the total training loss of the generative adversarial network. A larger preset reconstruction loss weight means that the model training process focuses more on reducing L1 reconstruction loss, i.e., more attention is paid to the pixel-level fit between the reconstructed image and the real image. A smaller λ value, on the other hand, focuses more on optimizing the least-squares adversarial loss, i.e., more attention is paid to the adversarial game effect between the generator and the discriminator. The setting of the preset reconstruction loss weight affects the learning focus of the generative adversarial network, ensuring that the model can balance adversarial capability and reconstruction accuracy.
[0075] In detail, the reconstructed image is the image output by the trained generator G after the pixel values of the image frame to be detected have been normalized. Its size is exactly the same as the training image. Based on the learned distribution of normal behavior images, the generator G reconstructs the input image frame to be detected in a behavior-oriented manner, giving the reconstructed image the image features of normal behavior. The core function of the reconstructed image is to serve as a reference benchmark for normal behavior, comparing it with the image frame to be detected to uncover deviation information.
[0076] In detail, the reconstructed residual field is a pixel-level deviation matrix obtained by performing pixel-by-pixel difference calculations between the detected image frame (after pixel value normalization) and the reconstructed image. In normal behavior scenarios, the deviation in the reconstructed residual field is mostly due to random noise (such as minor fluctuations in lighting and texture); in abnormal behavior scenarios, the deviation exhibits structured characteristics (such as significant pixel changes in the torso region during a fall). The reconstructed residual field reflects the degree of deviation between the detected image frame and the distribution of the normal behavior image.
[0077] In one embodiment of the present invention, a contrastive learning encoder trained using normal behavior samples encodes image patches of the image frame to be detected to obtain feature embeddings, and a contrastive weight map is generated based on the similarity between the feature embeddings and normal behavior feature prototypes, including:
[0078] The training image is segmented according to fixed row and column intervals to obtain U image blocks;
[0079] Based on all image patches, a normal image patch set is formed. ;in, In the training image set, the first... The training image of the first... Line 1 Image blocks in a column;
[0080] The contrastive learning encoder has a 4-layer convolutional neural network structure, with the following parameters for each layer:
[0081] The first layer of the convolutional neural network takes a 16×16×3 pixel image block as input, has a 3×3 kernel size, 64 kernels, a stride of 1, uses SAME padding, and has ReLU activation function.
[0082] The second convolutional neural network takes the output of the first layer as input, has a kernel size of 3×3, a number of 128 kernels, a stride of 1, uses SAME padding, and employs ReLU activation function.
[0083] The input to the third convolutional neural network is the output of the second layer. The kernel size is 3×3, the number of kernels is 256, the stride is 1, the padding method is SAME, and the activation function is ReLU.
[0084] The fourth layer of the convolutional neural network takes the output of the third layer as input, has a kernel size of 3×3, a number of kernels of 512, a stride of 1, uses SAME padding, and employs ReLU activation.
[0085] Output layer: Global average pooling is performed on the output of the fourth convolutional neural network to obtain a 512-dimensional feature vector, which is used as the feature embedding of the image patch;
[0086] The contrastive learning encoder training process uses the SimCLR contrastive loss function.
[0087] Calculate the prototype of normal behavioral characteristics: The normal behavior feature prototype is obtained by inputting all image patches into the contrastive learning encoder and obtaining feature embeddings, which are then normalized by L2 and the mean value is taken. ;in, , This represents the feature embedding of the k-th image patch;
[0088] The image frame to be detected after pixel value normalization is segmented according to fixed row and column intervals to obtain a set of image blocks to be detected;
[0089] Each image patch in the set of image patches to be detected is input into the contrastive learning encoder to obtain the corresponding feature embedding detection result. The feature embedding detection result of each image patch to be detected is then normalized to obtain the corresponding normalized feature embedding.
[0090] Calculate the vector dot product of each unitized feature embedding and the normal behavior feature prototype to obtain the similarity of the corresponding image patch to be detected. ;
[0091] The similarity of each image patch to be detected is mapped as follows:
[0092] ;
[0093] in, This represents the mapping weight of the image patch to be detected. express function, Indicates the scaling factor. Indicates the offset coefficient;
[0094] A mapping matrix is formed based on the mapping weights of each image patch to be detected. The mapping matrix is then aligned with the image to be detected to obtain a contrast weight map. ;in, This represents the bilinear interpolation kernel function. , , , , and These represent the number of rows and columns of the mapping matrix, respectively.
[0095] In detail, the contrastive learning encoder is a four-layer convolutional neural network used to extract semantic features from image patches. Its core function is to convert image patches into semantically discriminative feature embeddings, providing a foundation for subsequent similarity calculations. Its network structure parameters are strictly fixed: the first layer takes a 16×16×3 pixel image patch as input, using 64 3×3 convolutional kernels with a stride of 1, SAME padding, and ReLU activation; the second layer takes the output of the first layer as input, using 128 3×3 convolutional kernels with a stride of 1, SAME padding, and ReLU activation; the third layer takes the output of the second layer as input, using 256 3×3 convolutional kernels with a stride of 1, SAME padding, and ReLU activation; the fourth layer takes the output of the third layer as input, using 512 3×3 convolutional kernels with a stride of 1, SAME padding, and ReLU activation; the output layer performs global average pooling on the output of the fourth layer, ultimately obtaining a 512-dimensional feature vector as the feature embedding for the image patch. The training process uses the SimCLR contrastive loss function, which enables the encoder to learn the semantic feature distribution of normal behavior by comparing the feature embeddings of normal behavior image patches.
[0096] In detail, normalized feature embedding is the feature vector obtained by L2 normalizing the feature embedding output by the contrastive learning encoder. Normalized feature embedding is used to eliminate scale differences between different feature embeddings, making the modulus of the feature embedding uniform to 1, retaining only the orientation information of the features, and ensuring that the normalized feature embedding result can accurately reflect the semantic fit between the detected image patch and the normal behavior feature prototype, avoiding similarity calculation deviations caused by different feature embedding scales.
[0097] In detail, the similarity of the image patch to be detected is a quantitative indicator that measures the degree of semantic fit between the image patch to be detected and the prototype of normal behavior features. The result of the vector dot product reflects the similarity between the two: the larger the dot product value, the closer the semantic features of the image patch to the prototype of normal behavior features, and the higher the probability that the image patch belongs to normal behavior; the smaller the dot product value, the greater the semantic feature deviation, and the possible existence of anomalies.
[0098] In detail, the mapping weight converts the similarity of the image patches to be detected into a numerical value between 0 and 1 that can be used for weighted calculation. The calculation uses the sigmoid function, which keeps the mapping weight within the range of 0 to 1: when the similarity of the image patch to be detected is high, the mapping weight approaches 1, indicating that the image patch closely matches normal behavior; when the similarity is low, the mapping weight approaches 0, indicating that the image patch deviates significantly from normal behavior.
[0099] In detail, the contrast weight map is a weight matrix obtained by aligning the mapped weights with the image to be detected at the pixel level. The contrast weight map is used to highlight areas in the image to be detected that should be normal (weights approaching 1), amplify the residual deviation in these areas, and weaken the interference from non-critical areas such as the background (weights approaching 0).
[0100] In detail, the SimCLR contrastive loss function is the training loss function for the contrastive learning encoder. It is used to drive the encoder to learn discriminative semantic features of normal behavior by comparing the similarity of the feature embeddings of sample images. Its training logic is as follows: For each image patch in the set of normal behavior image patches, multiple data augmented views (such as random cropping or flipping) are generated. Different augmented views of the same image patch are regarded as positive sample pairs, and augmented views of different image patches are regarded as negative sample pairs. The cosine similarity between the feature embeddings of positive sample pairs and negative sample pairs is calculated. The difference between the similarity of positive sample pairs and negative sample pairs is minimized by the loss function, so that the feature embeddings output by the encoder satisfy the property that the embeddings of different views of the same image patch are similar, and the embeddings of different image patches are distant. Finally, the encoder can capture the semantic feature distribution of normal behavior.
[0101] In one embodiment of the present invention, within the human torso region, a weighted structure tensor is constructed by weighting and accumulating the spatial gradient of the reconstructed residual field using a contrast weighting map. The ratio of the energy projection values of the weighted structure tensor onto the gravity direction vector and the orthogonal direction vector is calculated as the gravity anisotropy index, including:
[0102] Human pose key points are obtained by identifying the image frames to be detected using a human pose estimation model, including: the center point of the upper edge of the pelvis and the center point of the lower edge of the thoracic spine; a rectangular region with the center points of the upper edge of the pelvis and the center points of the lower edge of the thoracic spine as diagonal vertices is taken as the human torso region. ;
[0103] Calculate the first-order discrete gradients of the human torso region in the horizontal and vertical directions within the reconstructed residual field; where the first-order discrete gradient in the horizontal direction is: The first-order discrete gradient in the vertical direction is: ;
[0104] The pixel-level two-dimensional gradient vector is defined as: ;
[0105] Within the human torso region, the gradient outer product is weighted and accumulated pixel-by-pixel to form a weighted structure tensor; where the gradient outer product is... The weighted structure tensor is ;
[0106] Calculate the energy projection value in the direction of gravity: ;
[0107] Calculate the energy projection values in orthogonal directions: ;
[0108] Calculate the anisotropy index of gravity: .
[0109] In detail, the pre-training of the human pose estimation model includes three core aspects. First, the pre-training dataset: This requires a public or custom dataset containing annotations of human key points. The dataset should include images of elderly people's daily behaviors (such as walking, standing, and sitting) that match the detection scenario, ensuring the model can adapt to the body shape and behavioral characteristics of the elderly. Second, the pre-training task: The task objective is human key point detection, focusing on training the model to identify key points related to trunk positioning, such as the center point of the upper pelvis and the center point of the lower thoracic spine. The model learns the mapping relationship between image pixel features and human key point coordinates through the labeled data. Third, training optimization: Using a key point localization loss function (such as mean squared error loss), the model parameters are optimized to reduce the deviation between the predicted coordinates and the actual labeled coordinates of key points, ensuring the model can accurately output the coordinates of the center points of the upper pelvis and the lower thoracic spine in the image frame to be detected.
[0110] In detail, the center point of the lower edge of the thoracic vertebrae is one of the key points output by the human pose estimation model, corresponding to the center point of the lowest thoracic vertebral column in human anatomy. In the image, this point is usually located in the lower middle part of the back, and its specific coordinates are determined by the pose estimation model by analyzing the back contour, torso texture, and relative positional relationship with other key points (such as the shoulders and waist) in the image.
[0111] In detail, the center point of the upper edge of the pelvis is one of the key points output by the human pose estimation model, corresponding to the center point of the upper edge of the pelvic bone in human anatomy. The center point of the upper edge of the pelvis is usually located in the middle area below the waist and above the buttocks. Its coordinates are determined by the pose estimation model by analyzing the waist contour, buttock texture and relative positional relationship with lower limb key points (such as the hip joint) in the image.
[0112] In detail, the human torso region is a specific area defined within the image frame to be detected, used for subsequent calculations of residual gradients and weighted structure tensors. It is defined as follows: using the center points of the upper edge of the pelvis and the lower edge of the thoracic vertebrae, output by the human pose estimation model, as the two diagonal vertebrae of a rectangle, a rectangular region covering the human torso (including the chest, abdomen, and waist) is constructed. The human torso region is used to focus on the key locations where fall behavior occurs. During a fall, the human torso first exhibits rapid flexion and descent dynamics; performing calculations only within this region eliminates interference from non-critical areas such as the background and limbs, improving the accuracy of abnormal feature extraction.
[0113] In detail, a pixel-level two-dimensional gradient vector is a vector that describes the direction and intensity of the spatial variation of the reconstructed residual field at a single pixel. The magnitude of the pixel-level two-dimensional gradient vector reflects the intensity of the residual variation at that pixel, and the direction reflects the dominant direction of the residual variation.
[0114] In detail, the gradient outer product is the product of the pixel-level two-dimensional gradient vector and its own transpose.
[0115] In detail, the weighted structure tensor is a 2×2 symmetric positive definite matrix obtained by weighting and accumulating the gradient outer product pixel by pixel within the human torso region. The weighted structure tensor integrates the spatial distribution characteristics of the residual gradient within the torso region with the semantic prior of the contrast weights, which can highlight the residual changes in the torso region that should be normal.
[0116] In detail, the gravity-direction energy projection value is a quantitative indicator that measures the degree of concentration of the residual gradient energy, as represented by the weighted structure tensor, in the gravity direction. It projects the gradient energy described by the tensor onto the gravity direction; a larger value indicates a more concentrated residual gradient energy in the gravity direction. During a fall, rapid trunk flexion and descent significantly enhance the residual gradient in the gravity direction, thus causing a systematic increase in this value.
[0117] In detail, the orthogonal direction energy projection value is a quantitative indicator that measures the degree of concentration of the residual gradient energy represented by the weighted structure tensor in the orthogonal direction of gravity (horizontal direction). Thus, the tensor gradient energy is projected onto the horizontal direction. Under normal behavior, this value is similar to the energy projection value in the gravity direction; however, during a fall, trunk deformation mainly occurs along the gravity direction, and the increase in gradient energy in the horizontal direction is limited. Therefore, the increase in this value is much smaller than that of the energy projection value in the gravity direction.
[0118] In detail, the gravitational anisotropy index is a single scalar that quantifies the difference in the distribution of residual gradient energy in the gravitational and horizontal directions by using the ratio of the energy projection value in the gravitational direction to the energy projection value in the orthogonal direction. Under normal behavior, the residual gradient energy is relatively evenly distributed in both directions, and the index is approximately 1. When falling, the energy projection value in the gravitational direction increases significantly while the increase in the horizontal direction is limited, and the index will be much greater than 1. Therefore, this index can directly characterize abnormal deformation in the gravitational direction.
[0119] It's important to note that the gravity-direction energy projection value reflects the degree to which the reconstructed residual gradient energy within the torso region is concentrated in the gravity direction (i.e., the vertical direction). The reconstructed residual gradient energy originates from the pixel differences between the image frame to be detected and the reconstructed image of normal behavior output by the generative adversarial network (GAN). The GAN is trained using normal behavioral samples such as standing and walking slowly, learning only the image features of normal behavior. When an elderly person falls, the torso exhibits a rapid bending and downward-falling motion. This motion causes drastic changes in the vertical pixels of the torso region in the real image, resulting in a significant deviation from the normal vertical features learned by the GAN. This leads to a substantial increase in the vertical gradient change in the reconstructed residual field. Simultaneously, the contrast weight map highlights the residual in the torso, a crucial region that should remain normal, causing the vertical residual gradient energy to concentrate more in the gravity direction, ultimately resulting in a significant increase in the gravity-direction energy projection value.
[0120] The horizontal energy projection value reflects the degree of concentration of residual gradient energy in the horizontal direction (perpendicular to the direction of gravity). When an elderly person falls, the core movement is a downward bending of the torso and a complete descent, with minimal horizontal movement. For example, there is no significant left-right translation or lateral swaying. Therefore, the horizontal pixel changes in the torso region of the real image are very similar to those of normal behavior (such as slight horizontal swaying during standing or slow walking). The enhancement of the horizontal gradient change in the reconstructed residual field is very limited, and the corresponding horizontal energy projection value naturally increases only slightly.
[0121] The gravitational anisotropy index is obtained by dividing the energy projection value in the gravitational direction by the energy projection value in the horizontal direction. Its purpose is to quantify the difference in the distribution of residual gradient energy in the two directions. Under normal circumstances, the residual gradient energy in the torso region is relatively evenly distributed in both the gravitational and horizontal directions. For example, when standing, the pixel changes in both the vertical and horizontal directions are very gradual, and the two energy projection values are similar, so the index is close to 1. However, when falling, the energy projection value in the gravitational direction increases significantly, while the energy projection value in the horizontal direction increases only slightly. The numerator (energy projection value in the gravitational direction) becomes larger, while the denominator (energy projection value in the horizontal direction) changes little, resulting in an index much greater than 1. This clearly reflects the abnormal deformation in the gravitational direction, thus distinguishing a fall from normal behavior.
[0122] In one embodiment of the present invention, a baseline mean tensor is determined based on the weighted structure tensor of historical normal frames, and a calibration set is constructed for the gravity anisotropy index after whitening. This set is then mapped to conformal probability values through statistical comparison, including:
[0123] The weighted structure tensor of each historical normal frame is determined, and the average of the weighted structure tensors of all historical normal frames is calculated to obtain the baseline mean tensor; wherein the weighted structure tensor is constructed as a 2×2 symmetric positive definite matrix;
[0124] Eigenvalue decomposition of the baseline mean tensor yields... ;in, Represents an orthogonal matrix. Represents a diagonal matrix. , and These are the eigenvalues of the baseline mean tensor;
[0125] Calculate the inverse square root matrix of the baseline mean tensor ;in, ;
[0126] Calculate the normalized tensor of the image frame to be detected ;
[0127] Calculate the energy projection values of the normalized tensor in the gravitational direction and the orthogonal direction respectively, and use the ratio of the energy projection values of the normalized tensor in the gravitational direction and the orthogonal direction as the normalized gravitational anisotropy index of the image frame to be detected. ;
[0128] Collect the normalized gravity anisotropy index for each historical normal frame and construct a calibration set;
[0129] Using the rank statistics method, the normalized gravity anisotropy index of the image frame to be detected is compared with the calibration set to obtain the conformal probability value, including:
[0130] The number N of elements in the statistical calibration set that are greater than or equal to the normalized gravity anisotropy index of the image frame to be detected;
[0131] Calculate the conformal probability value: ;in, This represents the calibration set.
[0132] In detail, the baseline mean tensor is a 2×2 symmetric positive definite matrix describing the spatial distribution of residual gradient energy in the torso region under historical normal behavior. It is constructed by collecting weighted structure tensors from all historical normal frames (each normal frame corresponds to one weighted structure tensor reflecting the residual gradient energy distribution of normal behavior in that frame), calculating the average of these weighted structure tensors, and finally obtaining the baseline mean tensor. The baseline mean tensor serves as the benchmark for gradient energy distribution under normal behavior, eliminating the influence of global interference factors in the scene (such as changes in illumination and camera gain fluctuations causing overall gradient energy scaling), ensuring the comparability of gradient energy distributions at different times and under different environments.
[0133] In detail, eigenvalue decomposition is a matrix decomposition operation performed on the baseline mean tensor. Its purpose is to decompose the gradient energy scale information contained within the baseline mean tensor. The decomposition process is as follows: the baseline mean tensor is decomposed into the product of three matrices, namely, the baseline mean tensor is equal to the product of the orthogonal matrix U, the diagonal matrix Λ, and the transpose of the orthogonal matrix U. Here, the column vectors of the orthogonal matrix U represent the principal directions of the gradient energy distribution (related to the direction of gravity and the horizontal direction), and the diagonal elements of the diagonal matrix Λ are the eigenvalues, corresponding to the gradient energy scale magnitudes in each principal direction of the orthogonal matrix U. The core purpose of this operation is to provide the basis for calculating the inverse square root matrix of the baseline mean tensor. Using the orthogonal matrix U and the diagonal matrix Λ obtained through decomposition, the inverse square root matrix can be further derived and used for the whitening and normalization of the weighted structure tensor of the current frame.
[0134] In detail, the normalized gravity anisotropy index is a single scalar that quantifies the difference in the distribution of residual gradient energy in the torso region of the current frame in the gravity direction and the horizontal direction after eliminating global gradient energy scale interference. Its calculation steps are as follows: First, using the inverse square root matrix of the baseline mean tensor, the weighted structure tensor of the current frame is whitened to obtain a normalized tensor (eliminating the influence of the global energy scale represented by the baseline mean tensor); then, the energy projection values of the normalized tensor in the gravity direction and the orthogonal direction are calculated respectively; finally, the ratio of the energy projection values in the two directions is taken to obtain the normalized gravity anisotropy index. The normalized gravity anisotropy index avoids the interference of synchronous rise and fall of gradient energy in all directions caused by global factors such as illumination and texture intensity, retaining only the energy difference in the gravity direction and the horizontal direction. Under normal behavior, this index is approximately 1, but when falling, it is much greater than 1 due to the significant increase in energy in the gravity direction.
[0135] In detail, the conformal probability value is an index quantifying the probability that the current frame belongs to normal behavior, obtained through rank statistics based on a historical normal frame calibration set. The conformal probability value ranges from 0 to 1. The closer the value is to 1, the higher the overlap between the current frame index and the historical normal frame index, and the greater the probability of normal behavior; the closer the value is to 0, the greater the probability that the current frame index deviates significantly from the normal distribution, and the greater the probability of abnormal behavior. The uses of the conformal probability value include: first, as a weight for the baseline mean tensor and incremental updates of normal behavior feature prototypes (frames with higher probability values contribute more to the update, avoiding pollution of the model by abnormal frames); second, providing a probabilistic basis for anomaly detection, replacing fixed thresholds, and improving the robustness of detection in complex scenarios.
[0136] In one embodiment of the present invention, the conformal probability value is used to update the weights and update the normal behavior feature prototype; when the abnormal stop determination is triggered, the degree of abnormality of the image frame to be detected is output, including:
[0137] The formula for updating the prototype of normal behavioral characteristics is: ;
[0138] The degree of abnormality of the image frame to be detected is calculated based on the updated normal behavior feature prototype: ;
[0139] If the degree of abnormality of the image frame to be detected is greater than or equal to the preset abnormality threshold, an abnormal behavior alarm will be output.
[0140] In detail, updating the normal behavior feature prototype refers to the process of iteratively optimizing the original normal behavior feature prototype using conformal probability values as weights. This allows the prototype to dynamically adapt to minor changes in normal behavior within the scene, preventing prototype failure due to scene drift. The update logic is as follows: the new normal behavior feature prototype equals (1 minus the conformal probability value) multiplied by the original prototype, plus the conformal probability value multiplied by the normalized gravity anisotropy index of the current frame. The conformal probability value reflects the probability that the current frame belongs to normal behavior. The closer the value is to 1, the more consistent the current frame is with normal behavior characteristics, and the higher its contribution weight to the new prototype, integrating the new normal behavior characteristics into the prototype. Conversely, the closer the value is to 0, the more likely the current frame is abnormal, contributing very little weight to the prototype, avoiding contamination of the prototype by abnormal features. Through this incremental update method, the prototype always maintains an accurate representation of normal behavior in the current scene.
[0141] In detail, the degree of anomaly in the image frame to be detected is an indicator that quantifies the extent to which the current frame deviates from the normal behavioral feature prototype, thus providing a quantifiable basis for anomaly judgment. If the current frame conforms to normal behavior, the normalization index is close to the prototype, the relative deviation value is close to 0, and the degree of anomaly is 0; if the current frame is an abnormal behavior such as falling, the normalization index is much greater than the prototype, the relative deviation value is significantly positive, and the degree of anomaly increases accordingly. The larger the value, the more serious the deviation from normal behavior, which can intuitively reflect the severity of the anomaly.
[0142] In detail, the preset anomaly threshold is a pre-set threshold value for anomaly judgment, manually determined based on the needs of the detection scenario and the distribution of normal behavioral characteristics. The setting of the preset anomaly threshold must be combined with the specific application scenario. For example, in a community elderly fall detection scenario, it is necessary to refer to the anomaly severity values of a large number of historical fall samples, the distribution range of anomaly severity of normal behavior samples, and the tolerance requirements for false alarm rate and false negative rate. If it is necessary to reduce the false negative rate, the threshold can be appropriately lowered; if it is necessary to reduce the false alarm rate, the threshold can be appropriately raised. The core function of this threshold is to serve as the trigger standard for abnormal behavior alarms. When the anomaly severity of the image frame to be detected is greater than or equal to the preset anomaly threshold, the system determines that there is abnormal behavior in the current frame; otherwise, it is determined to be normal behavior.
[0143] In detail, an abnormal behavior alarm is a warning response output by the system when it determines that an image frame under inspection contains an anomaly. Its core purpose is to promptly notify relevant personnel to handle the abnormal event. When the degree of anomaly in the image frame under inspection is greater than or equal to a preset anomaly threshold, the system automatically triggers the alarm mechanism. The alarm output typically includes a timestamp of the time the anomaly occurred, the numerical value of the anomaly degree of the current frame, and in some scenarios, it may also simultaneously output an image of the abnormal frame or an annotation of the abnormal region (such as the torso region) to help staff quickly locate the anomaly and understand its severity. In target scenarios such as smart communities, alarm signals can be transmitted in real time to the monitoring center terminal or relevant personnel's mobile devices, ensuring that emergency anomalies such as falls by the elderly can be detected promptly and rescue measures can be taken, realizing the practical application value of the detection method.
[0144] Example 2
[0145] An incremental detection system for abnormal behavior based on GAN synthesis and contrastive learning, applied to any of the described incremental detection methods for abnormal behavior based on GAN synthesis and contrastive learning, includes:
[0146] The data acquisition module obtains the gravity direction vector and the corresponding orthogonal direction vector in the detection scene;
[0147] The reconstruction residual module uses a generative adversarial network trained on normal behavior samples to reconstruct the image frame to be detected, calculates the pixel difference between the image frame to be detected and the reconstructed image, and obtains the reconstruction residual field.
[0148] The contrast weight module uses a contrastive learning encoder trained on normal behavior samples to encode image patches of the image frame to be detected to obtain feature embeddings, and generates a contrast weight map based on the similarity between the feature embeddings and the normal behavior feature prototypes.
[0149] In the anisotropic module, within the human torso region, a weighted structure tensor is constructed by weighting and accumulating the spatial gradient of the reconstructed residual field in conjunction with the contrast weight map. The ratio of the energy projection values of the weighted structure tensor in the gravity direction vector and the orthogonal direction vector is calculated as the gravity anisotropy index.
[0150] The conformal probability module determines the baseline mean tensor based on the weighted structure tensor of historical normal frames, constructs a calibration set for the gravity anisotropy index after whitening, and maps it to conformal probability values through statistical comparison.
[0151] The anomaly detection module updates the weights with conformal probability values, and sequentially uses the baseline mean tensor and normal behavior feature prototypes to output the degree of anomaly of the image frame to be detected.
[0152] The embodiments of this example have been described above. However, this example is not limited to the specific implementation methods described above. The specific implementation methods described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms based on the guidance of this example, and all of them are within the protection scope of this example.
Claims
1. An incremental detection method for abnormal behavior based on GAN synthesis and contrastive learning, characterized in that, include: Obtain the gravity direction vector in the detection scene and the corresponding orthogonal direction vector ; A generative adversarial network trained on normal behavior samples is used to reconstruct the image frame to be detected. The pixel difference between the image frame to be detected and the reconstructed image is calculated to obtain the reconstructed residual field. A contrastive learning encoder trained using normal behavior samples encodes image patches in the image frame to be detected to obtain feature embeddings. A contrastive weight map is then generated based on the similarity between the feature embeddings and the normal behavior feature prototypes. ; Within the human torso region, a weighted structure tensor is constructed by weighting and accumulating the spatial gradient of the reconstructed residual field using a contrast weighting map. The ratio of the energy projection values of the weighted structure tensor onto the gravity direction vector and the orthogonal direction vector is calculated as the gravity anisotropy index, including: Human pose key points are obtained by identifying the image frames to be detected using a human pose estimation model, including: the center point of the upper edge of the pelvis and the center point of the lower edge of the thoracic spine; a rectangular region with the center points of the upper edge of the pelvis and the center points of the lower edge of the thoracic spine as diagonal vertices is taken as the human torso region. ; Calculate the first-order discrete gradients of the human torso region in the horizontal and vertical directions within the reconstructed residual field; where the first-order discrete gradient in the horizontal direction is: The first-order discrete gradient in the vertical direction is: ; The pixel-level two-dimensional gradient vector is defined as: ; Within the human torso region, the gradient outer product is weighted and accumulated pixel-by-pixel to form a weighted structure tensor; where the gradient outer product is... The weighted structure tensor is ; Calculate the energy projection value in the direction of gravity: ; Calculate the energy projection values in orthogonal directions: ; Calculate the anisotropy index of gravity: ; The baseline mean tensor is determined based on the weighted structure tensor of historical normal frames. A calibration set is constructed for the gravity anisotropy index after whitening, and then mapped to conformal probability values through statistical comparison. The conformal probability value is used to update the weights, followed by the baseline mean tensor and the normal behavior feature prototype, to output the degree of abnormality of the image frame to be detected.
2. The method for incremental detection of abnormal behavior based on GAN synthesis and contrastive learning according to claim 1, characterized in that, Obtain the gravity direction vector and its corresponding orthogonal direction vector in the detection scene, including: Acquire the angular velocity and acceleration output by the inertial measurement unit at each moment, as well as the pose output by the visual odometry. The extended Kalman filter algorithm is used to fuse angular velocity, acceleration, and pose to obtain the fused attitude quaternion. ; attitude quaternions Convert to a 3D rotation matrix The conversion formula is as follows: ; The standard gravity vector in the world coordinate system The 3D direction vector is obtained by transforming to the camera coordinate system using a 3D rotation matrix. ; The camera intrinsic parameter matrix is determined as follows: ;in, and For pixel focal length, and Principal point coordinates; Normalize and project the three-dimensional direction vectors to obtain the two-dimensional vectors of the image plane. ; Normalize the two-dimensional vectors in the image plane to obtain the gravity direction vector. ;in, Indicates the modulus length; The gravity direction vector is rotated by a counterclockwise 90-degree rotation operator to obtain an orthogonal direction vector. ; where the rotation operator is .
3. The method for incremental detection of abnormal behavior based on GAN synthesis and contrastive learning according to claim 2, characterized in that, A generative adversarial network trained on normal behavior samples is used to reconstruct the image frame to be detected. The pixel difference between the image frame to be detected and the reconstructed image is calculated to obtain the reconstructed residual field, including: Construct a sample set of normal behaviors The normal behavior sample set includes a preset number of feature behavior sample images of equal format and size, and the feature behaviors include at least: walking, standing, sitting and squatting. For each pixel in each feature behavior sample image, the pixel value is normalized to form a training image set. ; Generative adversarial networks (GANs) consist of a generator G and a discriminator D, where: The generator G contains 5 deconvolutional layers. The first layer takes a 128-dimensional random noise and image feature concatenation vector as input. The deconvolution kernel sizes are 4×4, 4×4, 4×4, 4×4, and 3×3, with a stride of 2. Each hidden layer is followed by a batch normalization layer and a ReLU activation function. The output layer uses the Tanh activation function and outputs a reconstructed image of size P×Q. The discriminator D contains 5 convolutional layers with kernel sizes of 3×3, 4×4, 4×4, 4×4, and 4×4, and a stride of 2. The first hidden layer is followed by a LeakyReLU activation function, and the hidden layers of the remaining layers are connected to a batch normalization layer and a LeakyReLU activation function. The output layer is a 1-dimensional discrimination result. The training loss function is ,in: The least-squares adversarial loss is calculated using the following formula: ;in, This indicates a sample averaging operation. Represents training images, This represents the discriminator's one-dimensional discrimination result on the training image; The L1 reconstruction loss is calculated as follows: ;in, This represents the set of pixel coordinates constructed from all pixel coordinates in the training image. This represents the reconstructed image output by the generator. Indicating characteristic behavior sample images in Pixel value at that location, Indicates the reconstructed image in Pixel value at; Preset reconstruction loss weights; Acquire the image frame to be detected The size of the image frame to be detected is equal to that of the training image; The image frame to be detected is normalized by pixel values and then input into generator G to obtain the reconstructed image. ; The pixel-by-pixel difference operation is performed on the image frame to be detected after pixel value normalization and the reconstructed image to obtain the reconstructed residual field.
4. The method for incremental detection of abnormal behavior based on GAN synthesis and contrastive learning according to claim 3, characterized in that, A contrastive learning encoder trained using normal behavior samples encodes image patches of the image frame to be detected to obtain feature embeddings. A contrastive weight map is generated based on the similarity between the feature embeddings and normal behavior feature prototypes, including: The training image is segmented according to fixed row and column intervals to obtain U image blocks; Based on all image patches, a normal image patch set is formed. ;in, In the training image set, the first... The training image of the first... Line number Image blocks in a column; The contrastive learning encoder has a 4-layer convolutional neural network structure, with the following parameters for each layer: The first layer of the convolutional neural network takes a 16×16×3 pixel image block as input, has a 3×3 kernel size, 64 kernels, a stride of 1, uses SAME padding, and has ReLU activation function. The second convolutional neural network takes the output of the first layer as input, has a kernel size of 3×3, a number of 128 kernels, a stride of 1, uses SAME padding, and employs ReLU activation function. The input to the third convolutional neural network is the output of the second layer. The kernel size is 3×3, the number of kernels is 256, the stride is 1, the padding method is SAME, and the activation function is ReLU. The fourth layer of the convolutional neural network takes the output of the third layer as input, has a kernel size of 3×3, a number of kernels of 512, a stride of 1, uses SAME padding, and employs ReLU activation. Output layer: Global average pooling is performed on the output of the fourth convolutional neural network to obtain a 512-dimensional feature vector, which is used as the feature embedding of the image patch; The contrastive learning encoder training process uses the SimCLR contrastive loss function. Calculate the prototype of normal behavioral characteristics: The normal behavior feature prototype is obtained by inputting all image patches into the contrastive learning encoder and obtaining feature embeddings, which are then normalized by L2 and the mean value is taken. ;in, , This represents the feature embedding of the k-th image patch; The image frame to be detected after pixel value normalization is segmented according to fixed row and column intervals to obtain a set of image blocks to be detected; Each image patch in the set of image patches to be detected is input into the contrastive learning encoder to obtain the corresponding feature embedding detection result. The feature embedding detection result of each image patch to be detected is then normalized to obtain the corresponding normalized feature embedding. Calculate the vector dot product of each unitized feature embedding and the normal behavior feature prototype to obtain the similarity of the corresponding image patch to be detected. ; The similarity of each image patch to be detected is mapped as follows: ; in, This represents the mapping weight of the image patch to be detected. express function, Indicates the scaling factor. Indicates the offset coefficient; A mapping matrix is formed based on the mapping weights of each image patch to be detected. The mapping matrix is then aligned with the image to be detected to obtain a contrast weight map. ;in, This represents the bilinear interpolation kernel function. , , , , and These represent the number of rows and columns of the mapping matrix, respectively.
5. The method for incremental detection of abnormal behavior based on GAN synthesis and contrastive learning according to claim 4, characterized in that, The baseline mean tensor is determined based on the weighted structure tensor of historical normal frames. A calibration set is constructed for the gravity anisotropy index after whitening, and mapped to conformal probability values through statistical comparison, including: The weighted structure tensor of each historical normal frame is determined, and the average of the weighted structure tensors of all historical normal frames is calculated to obtain the baseline mean tensor; wherein the weighted structure tensor is constructed as a 2×2 symmetric positive definite matrix; Eigenvalue decomposition of the baseline mean tensor yields... ;in, Represents an orthogonal matrix. Represents a diagonal matrix. , and These are the eigenvalues of the baseline mean tensor; Calculate the inverse square root matrix of the baseline mean tensor ;in, ; Calculate the normalized tensor of the image frame to be detected ; Calculate the energy projection values of the normalized tensor in the gravitational direction and the orthogonal direction respectively, and use the ratio of the energy projection values of the normalized tensor in the gravitational direction and the orthogonal direction as the normalized gravitational anisotropy index of the image frame to be detected. ; Collect the normalized gravity anisotropy index for each historical normal frame and construct a calibration set; Using the rank statistics method, the normalized gravity anisotropy index of the image frame to be detected is compared with the calibration set to obtain the conformal probability value, including: The number N of elements in the statistical calibration set that are greater than or equal to the normalized gravity anisotropy index of the image frame to be detected; Calculate the conformal probability value: ;in, This represents the calibration set.
6. The method for incremental detection of abnormal behavior based on GAN synthesis and contrastive learning according to claim 5, characterized in that, The conformal probability value is used to update the weights, and the normal behavior feature prototype is updated to output the degree of abnormality of the image frame to be detected, including: The formula for updating the prototype of normal behavioral characteristics is: ; The degree of abnormality of the image frame to be detected is calculated based on the updated normal behavior feature prototype: ; If the degree of abnormality of the image frame to be detected is greater than or equal to the preset abnormality threshold, an abnormal behavior alarm will be output.
7. An incremental detection system for abnormal behavior based on GAN synthesis and contrastive learning, applied in the incremental detection method for abnormal behavior based on GAN synthesis and contrastive learning as described in any one of claims 1-6, characterized in that, include: The data acquisition module obtains the gravity direction vector in the detection scene. and the corresponding orthogonal direction vector ; The reconstruction residual module uses a generative adversarial network trained on normal behavior samples to reconstruct the image frame to be detected, calculates the pixel difference between the image frame to be detected and the reconstructed image, and obtains the reconstruction residual field. The contrast weighting module uses a contrastive learning encoder trained on normal behavior samples to encode image patches in the image frame to be detected, obtaining feature embeddings. Based on the similarity between these feature embeddings and the normal behavior feature prototypes, a contrast weighting map is generated. ; The anisotropic module, within the human torso region, constructs a weighted structure tensor by weighting and accumulating the spatial gradient of the reconstructed residual field using a contrast weight map. The ratio of the energy projections of the weighted structure tensor onto the gravity direction vector and orthogonal direction vectors is calculated as the gravity anisotropy index, including: Human pose key points are obtained by identifying the image frames to be detected using a human pose estimation model, including: the center point of the upper edge of the pelvis and the center point of the lower edge of the thoracic spine; a rectangular region with the center points of the upper edge of the pelvis and the center points of the lower edge of the thoracic spine as diagonal vertices is taken as the human torso region. ; Calculate the first-order discrete gradients of the human torso region in the horizontal and vertical directions within the reconstructed residual field; where the first-order discrete gradient in the horizontal direction is: The first-order discrete gradient in the vertical direction is: ; The pixel-level two-dimensional gradient vector is defined as: ; Within the human torso region, the gradient outer product is weighted and accumulated pixel-by-pixel to form a weighted structure tensor; where the gradient outer product is... The weighted structure tensor is ; Calculate the energy projection value in the direction of gravity: ; Calculate the energy projection values in orthogonal directions: ; Calculate the anisotropy index of gravity: ; The conformal probability module determines the baseline mean tensor based on the weighted structure tensor of historical normal frames, constructs a calibration set for the gravity anisotropy index after whitening, and maps it to the conformal probability value through statistical comparison; the anomaly detection module updates the weights with the conformal probability value, and sequentially uses the baseline mean tensor and normal behavior feature prototype to output the degree of anomaly of the image frame to be detected.
Citation Information
Patent Citations
MEMS inertia measuring unit and mounting error calibration method
CN101059384A
A video abnormal behavior detection method based on action prediction
CN109919032A