Character action detection method and device and computer readable medium
By generating and fusing video feature matrices, frame feature matrices, and person mask feature matrices, combined with action category features, the problem of insufficient accuracy in video person action detection in the existing technology is solved, and more accurate action recognition is achieved.
Patent Information
- Application Number
- CN202410673784.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-28
- Publication Date
- 2024-08-27
AI Technical Summary
Since existing video human action detection solutions only use image information in video frames, the accuracy of the detection results is insufficient, making it difficult to accurately understand the human actions in the video.
By generating a video feature matrix, a frame feature matrix and a person mask feature matrix, the weighted video feature matrix is calculated, and feature fusion is performed with the action category feature matrix, and input into the action recognition model to obtain the person visual feature matrix, and then determine the person in the video action.
It improves the accuracy of human action detection and more accurately understands human actions in videos by fusing video, image and text semantic features.
Smart Images

Figure CN118553013A
Abstract
Description
Technical Field
[0001] The present application relates to the field of information technology, and in particular to a method and device for detecting human motion, and a computer-readable medium. Background Art
[0002] Video character action understanding refers to analyzing the content of a video and detecting and judging the actions of the characters in the video. This technology is very important in the field of video analysis. With the rapid development of video data acquisition technology, how to accurately understand the actions of people in the video has become an important issue in video processing technology. Current character action detection schemes generally use the image information contained in each video frame in the video to analyze the image information contained in the video, and use the relevant feature information in the image to detect the character actions contained in the image, thereby realizing the understanding of the character actions. However, since this scheme only uses the image information in each video frame and the input features are relatively single, the accuracy of the detection result is insufficient, and it is difficult to accurately understand the character actions in the video. Summary of the invention
[0003] One purpose of the present application is to provide a method, device and computer-readable medium for detecting human motion, so as to solve the problem of insufficient accuracy in existing solutions.
[0004] To achieve the above object, the present application provides a method for detecting human motion, the method comprising:
[0005] Generate a corresponding video feature matrix according to the input video, wherein the shape of the video feature matrix is (K, X), K is positively correlated with the number of frames and resolution of the input video, and X is the embedding dimension of the feature;
[0006] Performing frame decomposition processing on the input video to obtain multiple video frames, and generating corresponding frame feature matrices according to the multiple video frames, wherein the shape of the frame feature matrix is (M, X), where M is the number of video frames obtained by the frame decomposition processing;
[0007] Performing character segmentation processing on each video frame to obtain a character segmentation mask map corresponding to the video frame, and generating a corresponding character mask feature matrix according to the character segmentation mask map, wherein the shape of the character mask feature matrix is (N, X), where N is the number of video frames containing character images in the M video frames obtained by the frame splitting processing;
[0008] Generate a corresponding action category feature matrix according to the action text set to be detected, wherein the shape of the action category feature matrix is (Q, X), where Q is the number of categories of character actions contained in the action text set;
[0009] According to the video feature matrix, the frame feature matrix and the character mask feature matrix, a weight matrix about the video features is calculated, and the shape of the weight matrix is (K, N);
[0010] A weighted video feature matrix is calculated based on the weight matrix and the video feature matrix, wherein the shape of the weighted video feature matrix is (N, X);
[0011] Performing feature fusion on the weighted video feature matrix and the action category feature matrix to obtain a weighted action category feature matrix, wherein the shape of the weighted action category feature matrix is (Q, X);
[0012] After splicing the weighted video feature matrix and the weighted action category feature matrix, the matrix is input into the action recognition model to obtain a character visual feature matrix, wherein the character visual feature matrix has a shape of (N, X);
[0013] A character action matrix is calculated based on the character visual feature matrix and the weighted action category feature matrix, wherein the shape of the character action matrix is (N, Q), and the element (n, q) in the character action matrix represents the probability that the nth video frame contains the qth character action;
[0014] According to the character action matrix, character actions in the input video are determined.
[0015] Furthermore, a corresponding video feature matrix is generated according to the input video, including:
[0016] The input video is input to the conv3d model, and the corresponding video feature matrix is extracted using the conv3d model.
[0017] Further, generating a corresponding frame feature matrix according to the multiple video frames includes:
[0018] The multiple video frames are input into an image encoder of a CLIP model, and the image encoder of the CLIP model is used to extract a corresponding frame feature matrix.
[0019] Furthermore, generating a corresponding character mask feature matrix according to the character segmentation mask image includes:
[0020] The character segmentation mask image is input into the image encoder of the CLIP model, and the image encoder of the CLIP model is used to extract the corresponding character mask feature matrix.
[0021] Furthermore, a corresponding action category feature matrix is generated according to the action text set to be detected, including:
[0022] The action text set to be detected is input into the text encoder of the CLIP model, and the text encoder of the CLIP model is used to extract the corresponding action category feature matrix.
[0023] Furthermore, according to the video feature matrix, the frame feature matrix and the character mask feature matrix, a weight matrix about the video feature is calculated, including:
[0024] Performing a matrix multiplication operation on the video feature matrix and the transposed frame feature matrix to obtain a first intermediate result matrix with a shape of (K, M), and calculating each element in the first intermediate result matrix using a preset activation function to obtain a first correlation matrix with a shape of (K, M);
[0025] Performing a matrix multiplication operation on the frame feature matrix and the transposed character mask feature matrix to obtain a second intermediate result matrix with a shape of (M, N), and calculating each element in the second intermediate result matrix using a preset activation function to obtain a second correlation matrix with a shape of (M, N);
[0026] A matrix multiplication operation is performed on the first correlation matrix and the second correlation matrix to obtain a weight matrix with a shape of (K, N).
[0027] Further, according to the weight matrix and the video feature matrix, a weighted video feature matrix is calculated, including:
[0028] The transposed weight matrix is subjected to matrix multiplication operation with the video feature matrix to obtain a weighted video feature matrix.
[0029] Furthermore, the weighted video feature matrix and the action category feature matrix are subjected to feature fusion to obtain a weighted action category feature matrix, including:
[0030] The action category feature matrix is used as the Q vector feature of the cross-attention mechanism model, and the weighted video feature matrix is used as the K vector feature and V vector feature of the cross-attention mechanism model, which are input into the cross-attention mechanism model to obtain the weighted action category feature matrix.
[0031] Furthermore, the weighted video feature matrix and the weighted action category feature matrix are concatenated and input into the action recognition model to obtain a character visual feature matrix, including:
[0032] The weighted video feature matrix and the weighted action category feature matrix are concatenated to obtain a feature concatenation matrix of shape (N+Q, X);
[0033] Input the feature concatenation matrix into the Swin Transformer model to obtain an output feature matrix with a shape of (N+Q, X);
[0034] Take the first N rows of feature vectors in the output feature matrix to obtain a character visual feature matrix with a shape of (N, X).
[0035] Furthermore, according to the character visual feature matrix and the weighted action category feature matrix, a character action matrix is calculated, including:
[0036] A matrix multiplication operation is performed on the character visual feature matrix and the transposed weighted action category feature matrix to obtain a character action matrix.
[0037] Some embodiments of the present application also provide a character motion detection device, wherein the device includes a memory for storing computer program instructions and a processor for executing computer program instructions, wherein when the computer program instructions are executed by the processor, the device is triggered to execute the aforementioned character motion detection method.
[0038] Other embodiments of the present application further provide a computer-readable medium having computer program instructions stored thereon, wherein the computer program instructions can be executed by a processor to implement the human motion detection method.
[0039] Compared with the prior art, in a human action detection scheme provided in an embodiment of the present application, the input video can be used to extract a video feature matrix, a frame feature matrix and a human mask feature matrix in different ways, and a weighted video feature matrix that integrates the above-mentioned video, image and mask related features can be calculated based on the above-mentioned feature matrix. At the same time, after generating a corresponding action category feature matrix according to the action text set to be detected, the action category feature matrix and the weighted video feature matrix are further integrated with the feature information to obtain a weighted action category feature matrix; the weighted video feature matrix and the weighted action category feature matrix are then spliced together and input into the action recognition model, and the human visual feature matrix is obtained and calculated together with the weighted action category feature matrix to obtain a human action matrix representing the probability of containing a specific human action in each video frame, which is used to determine the human action in the input video. Since the entire detection process not only utilizes the image information contained in each video frame, but also effectively integrates it with other modal information such as video features, character mask features, and text semantic features of actions, the feature information used for feature judgment can better express the intrinsic information corresponding to the character action, thereby improving the accuracy of the detection results, so that this scheme can more accurately understand the character actions in the video. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Other features, objects and advantages of the present application will become more apparent by reading the detailed description of non-limiting embodiments made with reference to the following drawings:
[0041] Figure 1 A processing flow chart of a method for detecting human motion provided in an embodiment of the present application;
[0042] Figure 2 This is a flow chart for performing human action recognition on an input video using the solution in an embodiment of the present application;
[0043] The same or similar reference numerals in the drawings represent the same or similar components. DETAILED DESCRIPTION
[0044] The present application is described in further detail below in conjunction with the accompanying drawings.
[0045] In a typical configuration of the present application, the terminal and the equipment of the service network each include one or more processors (CPU), input / output interface, network interface and memory.
[0046] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0047] Computer readable media include permanent and non-permanent, removable and non-removable media, and can be implemented by any method or technology to store information. Information can be computer program instructions, data structures, program devices or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, read-only compact disk (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission medium that can be used to store information that can be accessed by a computing device.
[0048] The embodiment of the present application provides a method for detecting human action, which can use the input video to extract the video feature matrix, frame feature matrix and human mask feature matrix respectively in different ways, and calculate the weighted video feature matrix that integrates the above-mentioned video, image and mask related features based on the above feature matrix, and can generate the corresponding action category feature matrix according to the action text set to be detected, and then further fuse the feature information of the action category feature matrix and the weighted video feature matrix to obtain a weighted action category feature matrix; and then splice the weighted video feature matrix with the weighted action category feature matrix, input it into the action recognition model, obtain the human visual feature matrix, and calculate it together with the weighted action category feature matrix, so as to obtain the human action matrix that represents the probability of containing a specific human action in each video frame, which is used to determine the human action in the input video. Since in the whole detection process, not only the image information contained in each video frame is used, but also the information of other modalities such as video features, human mask features and text semantic features of the action is effectively integrated, so that the feature information used for feature judgment can better express the intrinsic information corresponding to the human action, thereby improving the accuracy of the detection result, so that the present scheme can more accurately understand the human action in the video.
[0049] In actual scenarios, the execution subject of the method can be a user device, a network device, or a device formed by integrating a user device and a network device through a network, or it can also be an application running on the above device. The user device includes but is not limited to various terminal devices such as computers, mobile phones, and tablet computers; the network device includes but is not limited to network hosts, single network servers, multiple network server sets, or cloud computing-based computer sets. Here, the cloud is composed of a large number of hosts or network servers based on cloud computing (Cloud Computing), where cloud computing is a type of distributed computing, a virtual computer composed of a group of loosely coupled computer sets.
[0050] Figure 1 A method for detecting human motion provided by an embodiment of the present application is shown, and the method at least includes the following processing steps:
[0051] Step S101, generating a corresponding video feature matrix according to an input video.
[0052] The input video is the video to be detected in this solution. In actual scenarios, the conv3d (three-dimensional convolution) model can be used to generate a video feature matrix corresponding to the input video. When the conv3d model is used to process video data, it can extract features from the dimensions of space and time, thereby capturing motion information in multiple continuous video frames for subsequent character action detection.
[0053] In the scheme of the embodiment of the present application, when generating the corresponding video feature matrix according to the input video, the input video can be input into the conv3d model, and the corresponding video feature matrix can be extracted using the conv3d model. Wherein, the shape of the video feature matrix can be set to (K, X), K is positively correlated with the number of frames and resolution of the input video, that is, the higher the resolution of the video and the more frames, the larger the corresponding K value; conversely, the lower the resolution of the video and the fewer frames, the smaller the corresponding K value. For example, in this embodiment, the value of K can be determined by downsampling according to the resolution and number of frames of the video. Assuming that the length of the input video is 10 seconds, the frame rate is 60 frames / second, and the resolution of each frame is 1280×720 pixels, then K=10×60×1280×720 / 32768=16875. X is the embedding dimension of the feature, which can be set according to the needs of the actual scene. For example, in this embodiment, it can be set to 1024, and the shape of the video feature matrix is (16875, 1024).
[0054] Step S102, performing frame decomposition processing on the input video to obtain multiple video frames, and generating corresponding frame feature matrices according to the multiple video frames.
[0055] When performing the frame splitting process, a suitable sampling rate can be set as needed. For example, in this embodiment, it can be set to 32 frames per second, so that M video frames can be obtained based on the input video. For example, when the input video is 10 seconds, M=32×10=320. In the scheme of the embodiment of the present application, when generating the corresponding frame feature matrix according to the multiple video frames, the image encoder of the CLIP (Contrastive Language-Image Pre-training) model can be used, that is, the multiple video frames are input to the image encoder of the CLIP model, and the corresponding frame feature matrix is extracted using the image encoder of the CLIP model. The shape of the frame feature matrix is (M, X), where M is the number of video frames obtained by the frame splitting process, and X is the embedding dimension of the feature, which is the same as the embedding dimension set in the aforementioned video feature matrix. In this embodiment, 1024 is taken as an example, and the shape of the frame feature matrix can be (320, 1024).
[0056] Step 103, performing character segmentation processing on each video frame, obtaining a character segmentation mask image corresponding to the video frame, and generating a corresponding character mask feature matrix according to the character segmentation mask image.
[0057] For the M video frames obtained by the previous frame splitting process, each of the video frames can be subjected to character segmentation processing to obtain a corresponding character segmentation mask map to determine the spatial information about the character image contained therein. In the character segmentation mask map, the pixels where the character is located are set to 1, and the pixels of the remaining parts are set to 0, thereby ensuring the saliency of the character foreground image. In this embodiment, in order to obtain a more accurate character segmentation mask map, the deeplab V3 model can be used. The deeplab V3 model is a model for image semantic segmentation tasks, which can identify and segment the character image in each video frame, accurately determine the area where the character image is located in each video frame, and thus obtain the corresponding character segmentation mask map.
[0058] In actual scenes, since some video frames may not contain characters, these video frames do not contain character images and the corresponding character segmentation mask maps cannot be obtained. Therefore, the number of character segmentation mask maps obtained in this step is generally less than or equal to the number of video frames. For example, in this embodiment, N is set to be the number of video frames containing character images in the M video frames obtained by the frame splitting process, then the number of character segmentation mask maps = N, and N≤M.
[0059] When generating the corresponding character mask feature matrix according to the character segmentation mask map, the image encoder of the CLIP model can also be used. Specifically, the character segmentation mask map can be input into the image encoder of the CLIP model, and the corresponding character mask feature matrix can be extracted using the image encoder of the CLIP model. The shape of the character mask feature matrix is (N, X), where N is the number of video frames containing character images in the M video frames obtained by the frame stripping process, which is less than or equal to M, and X is the embedding dimension of the feature, which is the same as the embedding dimension of other features in this scheme. For example, if characters appear in 200 of the 320 video frames obtained by the frame stripping process, then N=200, the embedding dimension is 1024, and the shape of the character mask feature matrix obtained at this time can be (200, 1024).
[0060] Step S104, generating a corresponding action category feature matrix according to the action text set to be detected.
[0061] The action text set refers to a set of character actions that the user wants to detect, for example, it may include striking, climbing, jumping, etc. The specific action categories included in the action text set may be customized by the user, thereby achieving more flexible character action detection.
[0062] In the scheme of the embodiment of the present application, when generating the corresponding action category feature matrix according to the action text set to be detected, the text encoder of the CLIP model can be used, that is, the action text set to be detected is input into the text encoder of the CLIP model, and the text encoder of the CLIP model is used to extract the corresponding action category feature matrix. Thus, an action category feature matrix with a shape of (Q, X) can be obtained, wherein Q is the number of categories of the character actions contained in the action text set. For example, the action text set includes three kinds of character actions, namely, striking, climbing and jumping, then Q=3, X is the embedding dimension of the feature, which is the same as the embedding dimension of other features in this scheme, and taking X=1024 as an example, the shape of the action category feature matrix obtained in this step can be (3, 1024).
[0063] This solution uses the same CLIP model when generating each feature matrix using the CLIP model. Since the CLIP model learns to encode images and texts into a unified feature vector through contrastive learning during the training process, this enables the CLIP model to understand the correspondence between images and texts in natural language and image vision. Therefore, the feature information obtained by the image encoder and text encoder of the same CLIP model can represent the association between text and images corresponding to the same action, and accurately achieve similarity matching between text semantic features and image features.
[0064] Step S105, based on the video feature matrix, the frame feature matrix and the character mask feature matrix, a weight matrix about the video features is calculated. The weight matrix combines the effective information in the entire input video, a single video frame and the character images in each video frame, and can be used to enhance the representation of the feature information about the video, increase the proportion of important information in the video feature matrix, so that the proportion of important information can be more significantly greater than that of non-important information, thereby further improving the accuracy of subsequent processing.
[0065] In some embodiments of the present application, when calculating the weight matrix about the video features based on the video feature matrix, the frame feature matrix and the character mask feature matrix, the video feature matrix can be first subjected to matrix multiplication operation with the transposed frame feature matrix to obtain a first intermediate result matrix with a shape of (K, M), and each element in the first intermediate result matrix is calculated using a preset activation function to obtain a first correlation matrix with a shape of (K, M).
[0066] At the same time, the frame feature matrix and the transposed character mask feature matrix can be subjected to matrix multiplication to obtain a second intermediate result matrix of shape (M, N), and each element in the second intermediate result matrix is calculated using a preset activation function to obtain a second correlation matrix of shape (M, N). The activation function can use a sigmoid function, thereby mapping the first intermediate result matrix and each element in the first intermediate result matrix to the interval (0, 1), thereby obtaining a first correlation matrix and a second correlation matrix in which the value range of each element is between (0, 1).
[0067] After the first correlation matrix and the second correlation matrix are obtained, a matrix multiplication operation may be performed on the first correlation matrix and the second correlation matrix to obtain a weight matrix with a shape of (K, N).
[0068] Step S106, according to the weight matrix and the video feature matrix, a weighted video feature matrix is calculated, whereby the weight matrix can be used to enhance the feature information in the video feature matrix to obtain a weighted video feature matrix. Wherein, since the shape of the weight matrix is (K, N) and the shape of the video feature matrix is (K, X), when calculating based on the two, the weight matrix can be transposed to obtain a matrix with a shape of (N, K), and then the transposed weight matrix and the video feature matrix are subjected to matrix multiplication to obtain a weighted video feature matrix with a shape of (N, X).
[0069] Step S107: performing feature fusion on the weighted video feature matrix and the action category feature matrix to obtain a weighted action category feature matrix.
[0070] In the embodiment of the present application, a cross-attention mechanism can be used to implement feature fusion. Specifically, the action category feature matrix can be used as the Q vector feature of the cross-attention mechanism model, and the weighted video feature matrix can be used as the K vector feature and V vector feature of the cross-attention mechanism model, and input into the cross-attention mechanism model to obtain the weighted action category feature matrix. Thus, the feature information in the weighted action category feature matrix can learn the correlation between the video and the action category, and realize the effective fusion between the text feature and the video image feature. Among them, the shape of the weighted action category feature matrix in the present embodiment can be set to (Q, X), and each row element in the matrix represents the weighted feature information of each character action.
[0071] Step S108, concatenating the weighted video feature matrix and the weighted action category feature matrix, and inputting the concatenated matrix into an action recognition model to obtain a character visual feature matrix.
[0072] Wherein, the action recognition model adopted in the present embodiment can be a Swin Transformer (Shifted windows Transformer, shift window transformer) model. The Swin Transformer model is an improved model based on the Transformer framework, which significantly improves the computational efficiency while maintaining the model performance by introducing the prior knowledge of hierarchy and locality. When the Swin Transformer model is used to obtain the visual feature matrix of the characters, the weighted video feature matrix and the weighted action category feature matrix can be spliced first. Since the shape of the weighted video feature matrix is (N, X), the shape of the weighted action category feature matrix is (Q, X), after splicing the two, a feature splicing matrix with a shape of (N+Q, X) can be obtained.
[0073] The feature concatenation matrix can then be input into the trained Swin Transformer model, which can output an output feature matrix of the same shape (N+Q, X) after calculation. The first N rows of feature vectors in the output feature matrix are taken to obtain a character visual feature matrix of the shape (N, X) as feature information for subsequent detection processing.
[0074] Step S109, calculating and obtaining a character action matrix according to the character visual feature matrix and the weighted action category feature matrix.
[0075] In actual scenarios, the shape of the character visual feature matrix is (N, X), and the shape of the weighted action category feature matrix is (Q, X). When calculating the character action matrix based on the two, the weighted action category feature matrix can be transposed first to obtain a matrix with a shape of (X, Q), and then the character visual feature matrix and the transposed weighted action category feature matrix can be subjected to matrix multiplication to obtain a character action matrix with a shape of (N, Q).
[0076] Step S110, determining the character action in the input video according to the character action matrix.
[0077] Since the character action matrix represents the probability distribution of Q character actions in N video frames, the element (n, q) in the character action matrix represents the probability that the nth video frame contains the qth character action. For example, the element act(1, 2) in the first row and second column of the character action matrix represents the probability that the character action in the first video frame contains the second action (such as climbing action), and the element act(5, 1) in the fifth row and first column represents the probability that the character action in the fifth video frame contains the first action (such as striking action). Therefore, through the above-mentioned character action matrix, the one with the largest probability among the Q character actions can be selected for each frame as the character action of the video frame. In actual scenes, the argmax function can be used to determine the position index corresponding to the maximum probability in each row of the character action matrix, so as to determine the character action of each video frame.
[0078] In addition to determining the character action in each frame, the actions in the entire input video can be counted to determine the distribution of different character actions in the entire input video, etc. Thus, a more complete and comprehensive character action detection result can be obtained.
[0079] The solution of the embodiment of the present application not only utilizes the image information contained in each video frame during the entire detection process, but also effectively integrates it with other modal information such as video features, character mask features, and text semantic features of actions, so that the feature information used for feature judgment can better express the intrinsic information corresponding to the character action, thereby improving the accuracy of the detection results, so that the solution can more accurately understand the character actions in the video. Furthermore, since the action text set to be detected can be customized by the user, the user can set the detection target more flexibly and conveniently, and the application scenarios of this solution are more flexible and extensive.
[0080] Figure 2 The following is a process flow of using the solution provided in the embodiment of the present application to perform character action recognition on an input video, including the following processing steps:
[0081] Step S201, obtaining a video feature matrix.
[0082] For an input video, the conv3d model is used to extract the video feature matrix, which has a shape of (K, 1024).
[0083] Step S202, obtaining a frame feature matrix.
[0084] The aforementioned input video is subjected to frame decomposition processing, and M video frames can be obtained at 32 frames per second. Then, the image encoder of the CLIP model is used to extract the frame feature matrix of the M video frames, and the shape is (M, 1024).
[0085] Step S203, obtaining a character mask feature matrix.
[0086] Each video frame obtained in the previous step is processed using the deeplab V3 model to obtain a character segmentation mask corresponding to each video frame. The pixels corresponding to the character image part in the character segmentation mask are set to 1, and the pixels of the remaining parts are set to 0 to ensure the saliency of the character image part. Since some of the M video frames may not have characters, the number of character segmentation mask maps obtained will be less than M, which is set to N in this step. The image encoder of the CLIP model is used to extract the character mask feature matrix for these N character segmentation mask maps, with a shape of (N, 1024).
[0087] Step S204, obtaining an action category feature matrix.
[0088] Set a set of action texts to be detected, such as [strike, climb, jump...], which contains Q categories of character actions. Use the text encoder of the CLIP model to extract the action category feature matrix corresponding to the action text set, with a shape of (Q, 1024).
[0089] Step S205, obtaining a weighted video feature matrix.
[0090] After performing matrix multiplication operation on the video feature matrix and the transposed frame feature matrix, a sigmoid function is used to perform mapping calculation to obtain a first correlation matrix with a shape of (K, M). At the same time, after performing matrix multiplication operation on the frame feature matrix and the transposed character mask feature matrix, a sigmoid function is used to perform mapping calculation to obtain a second correlation matrix with a shape of (M, N). After performing matrix multiplication operation on the two correlation matrices, a weight matrix with a shape of (K, N) can be obtained. Then, a matrix multiplication operation is performed on the transposed weight matrix and the video feature matrix to obtain a weighted video feature matrix with a shape of (N, 1024).
[0091] Step S206, obtaining a weighted action category feature matrix.
[0092] The action category feature matrix is used as the Q vector feature of the cross-attention mechanism model, and the weighted video feature matrix is used as the K vector feature and V vector feature of the cross-attention mechanism model, and is input into the cross-attention mechanism model to obtain the weighted action category feature matrix, which has a shape of (Q, 1024).
[0093] Step S207, obtaining a person visual feature matrix.
[0094] The weighted video feature matrix and the weighted action category feature matrix are concatenated to obtain a new matrix with a shape of (N+Q, 1024), named A. Then the Swin Transformer model is used to process and fuse the information between the vectors in A to obtain an output feature matrix with the same shape as A. The first N feature vectors in the output feature matrix are taken to obtain a character visual feature matrix with a shape of (N, 1024).
[0095] Step S208, obtaining the character action matrix.
[0096] Perform matrix multiplication on the character visual feature matrix and the transposed weighted action category feature matrix to obtain a character action matrix with a shape of (N, Q). The character action matrix can represent the probability distribution of Q character actions in N video frames, where the value of the element (n, q) represents the probability of the qth character action being included in the nth video frame, and the higher the value, the higher the possibility of the existence of this character action in the frame.
[0097] Step S209, determining the character action matrix.
[0098] For each video frame, the argmax function can be used to determine the index value corresponding to the character action with the highest probability among the Q actions, and then determine the detection result of the character action in each video frame. On this basis, the distribution of character actions in the entire input video can also be counted.
[0099] Based on another aspect of the present application, an embodiment of the present application also provides a character motion detection device, which includes a memory for storing computer program instructions and a processor for executing computer program instructions, wherein when the computer program instructions are executed by the processor, the device is triggered to execute the aforementioned character motion detection method.
[0100] In particular, the methods and / or embodiments in the embodiments of the present application may be implemented as computer software programs. For example, the embodiments of the present disclosure include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes program code for executing the method shown in the flowchart. When the computer program is executed by the processing unit, the above functions defined in the method of the present application are executed.
[0101] It should be noted that the computer-readable medium described in the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device.
[0102] In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, device, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0103] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0104] The flow chart or block diagram in the accompanying drawings shows the possible architecture, function and operation of the equipment, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated system for hardware that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0105] As another aspect, the present application further provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device. The above computer-readable medium carries one or more computer program instructions, which may be executed by a processor to implement the methods and / or technical solutions of the above multiple embodiments of the present application.
[0106] It should be noted that the present application can be implemented in software and / or a combination of software and hardware, for example, can be implemented using an application specific integrated circuit (ASIC), a general purpose computer or any other similar hardware device. In certain embodiments, the software program of the present application can be executed by a processor to implement the above steps or functions. Similarly, the software program of the present application (including related data structures) can be stored in a computer-readable recording medium, for example, a RAM memory, a magnetic or optical drive or a floppy disk and similar devices. In addition, some steps or functions of the present application can be implemented using hardware, for example, as a circuit that cooperates with a processor to perform each step or function.
[0107] It is obvious to those skilled in the art that the present application is not limited to the details of the above exemplary embodiments, and that the present application can be implemented in other specific forms without departing from the spirit or basic features of the present application. Therefore, from any point of view, the embodiments should be regarded as exemplary and non-restrictive, and the scope of the present application is limited by the attached claims rather than the above description, so it is intended to include all changes that fall within the meaning and scope of the equivalent elements of the claims in the present application. Any figure mark in the claims should not be regarded as limiting the claims involved. In addition, it is obvious that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in the device claim can also be implemented by one unit or device through software or hardware. The words first, second, etc. are used to represent names, and do not represent any specific order. The numbers corresponding to the steps are used to mark and distinguish different steps, and the size of the numbers does not limit any specific execution order.
Claims
1. A method for detecting human action, It is characterized in that The method comprises: Generate a corresponding video feature matrix according to the input video, wherein the shape of the video feature matrix is (K, X), K is positively correlated with the number of frames and resolution of the input video, and X is the embedding dimension of the feature; Performing frame decomposition processing on the input video to obtain multiple video frames, and generating corresponding frame feature matrices according to the multiple video frames, wherein the shape of the frame feature matrix is (M, X), where M is the number of video frames obtained by the frame decomposition processing; Performing character segmentation processing on each video frame to obtain a character segmentation mask map corresponding to the video frame, and generating a corresponding character mask feature matrix according to the character segmentation mask map, wherein the shape of the character mask feature matrix is (N, X), where N is the number of video frames containing character images in the M video frames obtained by the frame splitting processing; Generate a corresponding action category feature matrix according to the action text set to be detected, wherein the shape of the action category feature matrix is (Q, X), where Q is the number of categories of character actions contained in the action text set; According to the video feature matrix, the frame feature matrix and the character mask feature matrix, a weight matrix about the video features is calculated, and the shape of the weight matrix is (K, N); A weighted video feature matrix is calculated based on the weight matrix and the video feature matrix, wherein the shape of the weighted video feature matrix is (N, X); Performing feature fusion on the weighted video feature matrix and the action category feature matrix to obtain a weighted action category feature matrix, wherein the shape of the weighted action category feature matrix is (Q, X); After splicing the weighted video feature matrix and the weighted action category feature matrix, the matrix is input into the action recognition model to obtain a character visual feature matrix, wherein the character visual feature matrix has a shape of (N, X); A character action matrix is calculated based on the character visual feature matrix and the weighted action category feature matrix, wherein the shape of the character action matrix is (N, Q), and the element (n, q) in the character action matrix represents the probability that the nth video frame contains the qth character action; According to the character action matrix, character actions in the input video are determined.
2. The method according to claim 1, It is characterized in that Generate the corresponding video feature matrix according to the input video, including: The input video is input to the conv3d model, and the corresponding video feature matrix is extracted using the conv3d model.
3. The method according to claim 1, It is characterized in that Generating a corresponding frame feature matrix according to the multiple video frames includes: The multiple video frames are input into an image encoder of a CLIP model, and the image encoder of the CLIP model is used to extract a corresponding frame feature matrix.
4. The method according to claim 1, It is characterized in that Generating a corresponding character mask feature matrix according to the character segmentation mask image includes: The character segmentation mask image is input into the image encoder of the CLIP model, and the image encoder of the CLIP model is used to extract the corresponding character mask feature matrix.
5. The method according to claim 1, It is characterized in that Generate the corresponding action category feature matrix according to the action text set to be detected, including: The action text set to be detected is input into the text encoder of the CLIP model, and the text encoder of the CLIP model is used to extract the corresponding action category feature matrix.
6. The method according to claim 1, It is characterized in that According to the video feature matrix, the frame feature matrix and the character mask feature matrix, a weight matrix about the video features is calculated, including: Performing a matrix multiplication operation on the video feature matrix and the transposed frame feature matrix to obtain a first intermediate result matrix with a shape of (K, M), and calculating each element in the first intermediate result matrix using a preset activation function to obtain a first correlation matrix with a shape of (K, M); Performing a matrix multiplication operation on the frame feature matrix and the transposed character mask feature matrix to obtain a second intermediate result matrix with a shape of (M, N), and calculating each element in the second intermediate result matrix using a preset activation function to obtain a second correlation matrix with a shape of (M, N); A matrix multiplication operation is performed on the first correlation matrix and the second correlation matrix to obtain a weight matrix with a shape of (K, N).
7. The method according to claim 6, It is characterized in that The weighted video feature matrix is calculated based on the weight matrix and the video feature matrix, including: The transposed weight matrix is subjected to matrix multiplication operation with the video feature matrix to obtain a weighted video feature matrix.
8. The method according to claim 1, It is characterized in that The weighted video feature matrix is subjected to feature fusion with the action category feature matrix to obtain a weighted action category feature matrix, including: The action category feature matrix is used as the Q vector feature of the cross-attention mechanism model, and the weighted video feature matrix is used as the K vector feature and V vector feature of the cross-attention mechanism model, which are input into the cross-attention mechanism model to obtain the weighted action category feature matrix.
9. The method according to claim 1, It is characterized in that After the weighted video feature matrix and the weighted action category feature matrix are spliced, they are input into the action recognition model to obtain the character visual feature matrix, including: The weighted video feature matrix and the weighted action category feature matrix are concatenated to obtain a feature concatenation matrix of shape (N+Q, X); Input the feature concatenation matrix into the Swin Transformer model to obtain an output feature matrix with a shape of (N+Q, X); Take the first N rows of feature vectors in the output feature matrix to obtain a character visual feature matrix with a shape of (N, X).
10. The method according to claim 1, It is characterized in that According to the character visual feature matrix and the weighted action category feature matrix, a character action matrix is calculated, including: A matrix multiplication operation is performed on the character visual feature matrix and the transposed weighted action category feature matrix to obtain a character action matrix.
11. A person action detection device, in, The device comprises a memory for storing computer program instructions and a processor for executing the computer program instructions, wherein when the computer program instructions are executed by the processor, the device is triggered to execute the method according to any one of claims 1 to 10.
12. A computer readable medium having computer program instructions stored thereon, wherein the computer program instructions can be executed by a processor to implement the method according to any one of claims 1 to 10.
