Small sample behavior recognition method of task-specific adaptive image pre-training model

By freezing the parameters of the pre-trained model and introducing adapter parameters for spatio-temporal and task-specific adaptation, the problem of model forgetting and over-fitting in small sample behavior recognition is solved, and the accuracy of task-specific feature extraction is significantly improved, especially in SSv2 data. Excellent performance was achieved on the set.

CN118537644APending Publication Date: 2024-08-23NORTHWESTERN POLYTECHNICAL UNIV

Patent Information

Application Number
CN202410670172.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-28
Publication Date
2024-08-23

AI Technical Summary

Technical Problem

Existing technologies destroy the prior knowledge of pre-trained models in small-sample behavior recognition tasks, leading to catastrophic forgetting and over-fitting of the model, and ignore the importance of task-specific information, failing to fully mine the most discriminating features.

Method used

Freeze the parameters of the original pre-training model, introduce learnable adapter parameters to perform spatiotemporal information modeling and task-specific information modeling in the ViT model, enhance feature extraction through temporal, spatial and task-specific adaptation, and only update the adapter parameters to avoid over-fitting combine.

Benefits of technology

It effectively alleviates the over-fitting problem, enhances the extraction of task-specific key information, and significantly improves the accuracy of small sample behavior recognition. In particular, it achieved 71.3% of 5-way 1-shot and 74.2% on the SSv2 data set. 5-way 5-shot accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118537644A
    Figure CN118537644A
Patent Text Reader

Abstract

The invention discloses a small sample behavior recognition method for a task-specific adaptive image pre-training model, which comprises the following steps of: freezing original parameters of an original pre-training model, additionally adding learnable adapter parameters in each layer of ViT, and finishing spatio-temporal information modeling and task-specific key information modeling by utilizing a frozen multi-head self-attention layer. According to the method, the overfitting problem caused by all traditional fine tuning strategies can be effectively relieved, and specific key information of a task can be enhanced according to a given small sample learning task, so that priori knowledge of a pre-training model is fully utilized, and better small sample behavior recognition is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of pattern recognition technology, and in particular relates to a small sample behavior recognition method for a task-specific adaptive image pre-training model. Background Art

[0002] In recent years, large-scale pre-trained models have demonstrated remarkable generalization capabilities across a variety of downstream computer vision tasks. However, manually collecting and annotating massive amounts of data for each specific downstream task is unrealistic. Consequently, a growing number of researchers are focusing on leveraging the prior knowledge of these large models for specific downstream tasks. In the field of video understanding, combining these with large pre-trained models has significantly improved the performance of action recognition tasks. However, existing work has focused on fine-tuning on well-labeled video datasets, with the categories used during testing and training remaining consistent. In real-world scenarios, most problems arise with small sample sizes: models are only fine-tuned on data from the seen categories, with only a small number of labeled examples for new categories not seen during training. Therefore, leveraging the prior knowledge of pre-trained models for small-sample action recognition tasks is an urgent challenge.

[0003] Mainstream work on few-shot action recognition employs a metric-based meta-learning strategy, calculating the distance between query video features and prototype features of each class to produce a final classification score. Therefore, to better measure the distance between video features, existing work has designed various temporal alignment modules at the feature level. These works consistently use pre-trained image models as feature extractors and then fine-tune the pre-trained models on video datasets. However, this traditional paradigm suffers from two flaws: First, mainstream work employs a full fine-tuning strategy, fine-tuning all parameters of the pre-trained model on seen data, hoping that the model will maintain good generalization performance on unseen test data. However, this classic full fine-tuning strategy can destroy the prior knowledge of the pre-trained model, leading to catastrophic forgetting or even overfitting to seen data. A second flaw is that existing work has overlooked the importance of extracting task-specific information for few-shot action recognition. It is generally accepted that the most discriminative features differ for different target tasks. For example, when distinguishing between "high jump" and "long jump," the performer's trajectory is the most discriminative feature, while when distinguishing between "high jump" and "pole vault," whether the performer is holding a pole is an even more significant feature. Existing technologies only design temporal alignment modules at the feature level, which is insufficient to fully exploit the most discriminative features in a given small-sample learning task. Summary of the Invention

[0004] To overcome the shortcomings of the existing technology, this paper provides a task-specific small-sample behavior recognition method that adapts to a pre-trained image model. This method freezes the original pre-trained model parameters, adds learnable adapter parameters within each ViT layer, and utilizes the frozen multi-head self-attention layer to model both spatiotemporal information and task-specific key information. This method effectively mitigates the overfitting problem caused by traditional full fine-tuning strategies and enhances task-specific key information based on a given small-sample learning task, thereby fully leveraging the pre-trained model's prior knowledge and achieving better small-sample behavior recognition.

[0005] The technical solutions adopted by the present invention to solve the technical problems are as follows:

[0006] Step 1: Randomly sample C categories from the known category dataset;

[0007] Step 2: Randomly extract K+M video samples from each category, and the first K samples constitute the support set The last M samples constitute the query set

[0008] Step 3: Convert all video inputs into word embedding representations required by ViT:

[0009] Step 4: Encode the word embedding of the video through the N-layer ViT block;

[0010] Step 5: Concatenate the word embeddings corresponding to the classification words in each frame feature along the time dimension to obtain the final video feature F S ∈R CK×T×D and F Q ∈R M×T×D ;

[0011] Step 6: Average all support set features of each category to obtain the prototype representation of each category:

[0012]

[0013] in Represents the class prototype of the c-th category;

[0014] Step 7: Calculate the distance between the query feature and the prototype feature of each category:

[0015]

[0016] in represents the probability that the i-th query video belongs to the c-th category,

[0017] Step 8: Calculate the cross-entropy classification loss for each query video, backpropagate the gradient, and update the parameters. Note that only the adapter parameters within each layer of the entire model are learnable, and all parameters of the original pre-trained model are frozen and not updated.

[0018] Step 9: Determine whether the specified number of meta-learning tasks has been reached. If so, end the training; otherwise, jump to step 1 to continue.

[0019] Furthermore, the step 3 is specifically as follows:

[0020] Step 3-1: For each RGB video sample v∈R T×H×W×3 , first divide each frame into N = HW / P 2 image blocks, where P represents the size of each image block; T, H, and W represent the number of frames, the number of vertical pixels in the frame, and the number of horizontal pixels in the frame, respectively;

[0021] Step 3-2: Map each image block to the D-dimensional word embedding space to obtain v p ∈R T×N×D ;

[0022] Step 3-3: Add a learnable classification word at the beginning of the word sequence to get v0∈R T×(N+1)×D ;

[0023] Step 3-4: Add learnable positional encoding:

[0024] z0=v0+E pos

[0025] The position code F pos ∈R (N+1)×D ; z0 represents the features of the input video sample after word segmentation.

[0026] Further, the step 4 is specifically as follows:

[0027] The first NL layers keep the network structure of the original pre-trained model unchanged. Starting from the N-L+1 layer, learnable adapter parameters are introduced. For the l-th layer ViT block, where l∈[N-L+1,N-L+2,…,N], the following steps are included:

[0028] Step 4-1: Video feature z l ∈R T×(N+1)×D Perform timing adaptation:

[0029]

[0030] in represents the features after temporal adaptation in the lth layer ViT, z l-1represents the output of the l-1th layer ViT; MSA(·) represents the multi-head self-attention layer with frozen parameters in the original pre-trained model, which is applied to the time dimension T; LN(·) represents layer normalization, and Adapter(·) represents the additional learnable adapter layer, which contains two fully connected layers and an intermediate layer activation function;

[0031] Step 4-2: Video features Perform spatial adaptation:

[0032]

[0033] in represents the features after spatial adaptation in the l-th layer ViT, and the frozen multi-head self-attention layer MSA(·) is applied to the spatial dimension (N+1);

[0034] Step 4-3: Video features Performing task-specific adaptations:

[0035]

[0036] in represents the features in the lth layer ViT after task-specific adaptation, and the frozen multi-head self-attention layer MSA(·) is applied to different video dimensions;

[0037] Step 4-4: Video features Perform joint adaptation:

[0038]

[0039] where z l Represents the output of the lth layer ViT. The multi-layer perceptron MLP(·) also uses the parameters frozen in the original pre-training model.

[0040] The beneficial effects of the present invention are as follows:

[0041] (1) This paper designs a new task-specific adaptation method for small-sample behavior recognition tasks, which effectively alleviates the problems of catastrophic forgetting and overfitting of pre-trained models caused by traditional full fine-tuning methods.

[0042] (2) This invention proposes for the first time task-specific adaptation in the feature extraction process, which significantly enhances the most discriminative features in a given small-sample learning task.

[0043] (3) The present invention has achieved the current best results on four international public datasets: HMDB51, Kinetics, UCF101 and SSv2. In particular, on the most challenging SSv2 dataset, its 5-way 1-shot accuracy and 5-way 5-shot accuracy reached 71.3% and 74.2% respectively. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] Figure 1 Schematic diagram of the adapter structure.

[0045] Figure 2 Schematic diagram of the small sample behavior recognition method of the present invention that specifically adapts the image pre-training model to the task.

[0046] Figure 3 This is an experimental effect diagram of the present invention. DETAILED DESCRIPTION

[0047] The present invention will be further described below with reference to the accompanying drawings and examples.

[0048] like Figure 2 As shown, the present invention provides a small sample behavior recognition method based on a task-specific adaptive image pre-training model, and the specific steps are as follows.

[0049] 1. Training Phase

[0050] During the training phase of the small-shot action recognition task, C-way K-shot small-shot learning tasks are continuously randomly sampled from the visible category data. For a given C-way K-shot small-shot learning task, there are C categories, with K samples per category forming the support set. A total of M videos from these C categories serve as the query set. For each sampled small-shot learning task, the model needs to generate classification scores for all query videos based on the support set samples, with the average classification loss of all query samples serving as the optimization objective. The training phase can be formulated as follows:

[0051] Step 1: Randomly sample C categories from the known category dataset;

[0052] Step 2: Randomly extract K+M video samples from each category, and the first K samples constitute the support set The last M samples constitute the query set

[0053] Step 3: Convert all video inputs into word embedding representations required by ViT;

[0054] Step 3-1: For each RGB video sample v∈RT ×H×W×3 , first divide each frame into N = HW / P 2image blocks, where P represents the size of each image block;

[0055] Step 3-2: Map each image block to the D-dimensional word embedding space to obtain v p ∈R T×N×D ;

[0056] Step 3-3: Add a learnable classification word at the beginning of the word sequence to get v0∈R T×(N+1)×D ;

[0057] Step 3-4: Add learnable positional encoding:

[0058] z0=v0+E pos

[0059] Among them E pos ∈R (N+1)×D ;

[0060] Step 4: Encode the word embedding of the video through the N-layer ViT block;

[0061] The first NL layers keep the network structure of the original pre-trained model unchanged, and starting from the N-L+1 layer, learnable adapter parameters are introduced. For the l-th layer ViT block, where l∈[N-L+1,N-L+2,…,N], the following steps are included:

[0062] Step 4-1: For each video feature z l ∈R T×(N+1)×D Perform timing adaptation:

[0063]

[0064] in represents the features after temporal adaptation in the lth layer ViT, z l-1 Represents the output of the l-1th layer ViT. MSA(·) represents the multi-head self-attention layer with frozen parameters in the original pre-trained model, which is applied to the time dimension T. LN(·) represents layer normalization, and Adapter(·) represents the additional learnable adapter layer, which consists of two fully connected layers and an intermediate layer activation function. The specific structure is shown in Figure 1 ;

[0065] Step 4-2: For each video feature Perform spatial adaptation:

[0066]

[0067] in represents the features after spatial adaptation in the l-th layer ViT, and the frozen multi-head self-attention layer MSA(·) is applied to the spatial dimension (N+1);

[0068] Step 4-3: For each video feature Performing task-specific adaptations:

[0069]

[0070] in represents the features in the lth layer ViT after task-specific adaptation. The frozen multi-head self-attention layer MSA(·) is applied to the dimensions of different videos (between C×K support set videos and M query videos) to fully explore and enhance the most discriminative features between different videos in a given few-shot learning task.

[0071] Step 4-4: For each video feature Perform joint adaptation:

[0072]

[0073] where z l Represents the output of the lth layer ViT. The multi-layer perceptron MLP(·) also uses the parameters frozen in the original pre-training model.

[0074] Step 5: Concatenate the word embeddings corresponding to the classification words in each frame feature along the time dimension to obtain the final video feature F S ∈R CK×T×D and F Q ∈R M×T×D ;

[0075] Step 6: Average all support set features of each category to obtain the prototype representation of each category:

[0076]

[0077] in Represents the class prototype of the c-th category;

[0078] Step 7: Calculate the distance between the query feature and the prototype feature of each category:

[0079]

[0080] in represents the probability that the i-th query video belongs to the c-th category,

[0081] Step 8: Calculate the cross-entropy classification loss for each query video, backpropagate the gradient, and update the parameters. Note that only the adapter parameters within each layer of the entire model are learnable, and all parameters of the original pre-trained model are frozen and not updated.

[0082] Step 9: Determine whether the specified number of meta-learning tasks has been reached. If so, end the training; otherwise, jump to step 1 to continue.

[0083] 2. Testing phase;

[0084] For the C-way K-shot meta-learning test task sampled from unseen category data, freeze the entire model including the adapter parameters and use it as the feature extractor for the unseen category. Use steps 3 to 7 above to complete the action recognition task for the unseen category query video.

[0085] like Figure 3 As shown in the figure, the present invention has achieved the best or second best performance on the benchmark tests of multiple public datasets. In particular, for the most challenging SSv2 dataset, the present invention surpasses the best existing algorithm by 5.7% on the 5-way 5-shot method, demonstrating the effectiveness of the present invention for task-specific feature extraction.

Claims

1. A task-specific adaptation of the image pre-trained model to a small sample size action recognition method, It is characterized in that The steps include: Step 1: Randomly sample C categories from a known category dataset; Step 2: Randomly select K+M video samples from each category, and the first K samples constitute the support set The last M samples constitute the query set Step 3: Convert all video inputs into word embedding representations required by ViT: Step 4: Encode the word embedding of the video through the N-layer ViT block; Step 5: Concatenate the word embeddings corresponding to the classification words in each frame feature along the time dimension to obtain the final video feature F S ∈R CK×T×D and F Q ∈R M×T×D ; Step 6: Average all support set features of each category to obtain the prototype representation of each category: in Represents the class prototype of the cth category; Step 7: Calculate the distance between the query feature and the prototype feature of each category: in represents the probability that the i-th query video belongs to the c-th category, Step 8: Calculate the cross entropy classification loss for each query video, calculate the gradient through back propagation, and update the parameters. Note that only the adapter parameters within each layer of the entire model are learnable, and all parameters of the original pre-trained model are frozen and not updated. Step 9: Determine whether the specified number of meta-learning tasks has been reached. If so, end the training; otherwise, jump to step 1 to continue.

2. According to the small sample behavior recognition method of the task-specific adaptive image pre-training model according to claim 1, It is characterized in that The step 3 is specifically as follows: Step 3-1: For each RGB video sample v∈R T×H×W×3 , first divide each frame into N = HW / P 2 image blocks, where P represents the size of each image block; T, H, and W represent the number of frames, the number of pixels in the vertical direction of the frame, and the number of pixels in the horizontal direction of the frame, respectively; Step 3-2: Map each image block to the D-dimensional word embedding space to obtain v p ∈R T×N×D ; Step 3-3: Add a learnable classification word at the beginning of the word sequence to get v 0 ∈R T×(N+1)×D ; Step 3-4: Add learnable positional encoding: with 0 =in 0 +E pos The position code E pos ∈R (N+1)×D ; z 0 Represents the features of the input video sample after tokenization.

3. According to the small sample behavior recognition method of the task-specific adaptive image pre-training model according to claim 2, It is characterized in that The step 4 is specifically as follows: The first NL layers keep the network structure of the original pre-trained model unchanged. Starting from the N-L+1th layer, learnable adapter parameters are introduced. For the lth layer ViT block, where l∈[N-L+1,N-L+2,…,N], the following steps are included: Step 4-1: Video feature z l ∈R T×(N+1)×D Perform timing adaptation: in represents the features after temporal adaptation in the lth layer ViT, z l-1 represents the output of the l-1th layer ViT; MSA(·) represents the multi-head self-attention layer with frozen parameters in the original pre-trained model, which is applied to the time dimension T; LN(·) represents layer normalization, and Adapter(·) represents an additional learnable adapter layer, which contains two fully connected layers and an intermediate layer activation function; Step 4-2: Video features To adapt to the space: in represents the features after spatial adaptation in the lth layer ViT, and the frozen multi-head self-attention layer MSA(·) is applied on the spatial dimension (N+1); Step 4-3: Video features Performing task-specific adaptations: in represents the features in the lth layer ViT after task-specific adaptation, and the frozen multi-head self-attention layer MSA(·) is applied to different video dimensions; Step 4-4: Video features Perform joint adaptation: where z l Represents the output of the lth layer ViT. The multi-layer perceptron MLP(·) also uses the parameters frozen in the original pre-training model.

Citation Information

Patent Citations

  • Continuous relation extraction method and system based on multi-head self-attention mechanism adapter

    CN116186171A

  • Self-adaptive children autism spectrum disorder behavior identification method

    CN117789286A

  • Personnel abnormal behavior identification system and method based on TSAFormer model

    CN117935121A

  • Small sample behavior recognition method of visual language pre-training large model

    CN118070878A

  • Systems and Methods for Programmatic Labeling of Training Data for Machine Learning Models via Clustering and Language Model Prompting

    US20240160900A1

Cited By

  • DTSADTER video action recognition method based on efficient fine tuning of parameters

    CN119810708A

  • RGBT target tracking method based on domain adaptation and spatio-temporal information fusion

    CN119863491A