Cross-dataset Training of Transformers for Robust Action Recognition
Anonymous Author(s)
AffiliationAddress
Abstract
We study on robust feature representations that can generalize on multiple datasetsfor action recognition using transformers.
Although we have witnessed greatprogress of action recognition in the past decade, it remains challenging yet
valuablehow to train a single model that can perform well across multiple datasets.
Herewe propose a novel cross-dataset training paradigm, CrossRoad , with the design oftwo new loss terms, namely informative loss and projection loss, aiming to learnrobust representations for action recognition.
We verify the effectiveness of ourmethod on five challenging datasets, Kinetics-400, Kinetics-700, Moments-in-Time,
Activitynet and Something-something-v2 datasets.
Extensive experimental resultsshow that our method can consistently improve the state-of-the-art performance.
We will release our code and models.
Introduction
Human vision can recognize video actions efficiently despite the variations of scenes and domains.
Convolutional neural networks (CNNs) [37, 38, 6, 33, 14] fully utilize the power of modern computational devices and employ spatial-temporal filters to recognize actions, which outperform traditionalmodels such as oriented filtering in space time (HOG3D) [23].
However, due to the high variations inspace-time, the state-of-the-art of action recognition is still far from being satisfactory, compared withthe success of 2D CNNs in image recognition [19].
Recently, vision transformers like ViT [10], MViT[12] that are based on the self-attention [40] mechanism are proposed to tackle the problems of imageand video recognition.
Instead of modeling pixels as CNNs, transformers apply attentions on top ofvisual tokens.
The inductive bias of translation invariance in CNNs makes it require less training datathan pure-attention-transformers in general.
However, transformer has the advantage that it can betterharness the parallel processing units of modern computing devices such as GPUs and TPUs, makingit more computationally efficient than CNNs.
We have seen a rapid growth in video datasets [21] inrecent years, which would make up for the shortcomings of data-hungry transformers.
The videodata has not only grown in quantity from hundreds to millions of videos [31] but also evolved fromsimple actions such as handshaking to complicated daily activities from the Kinetics-700 dataset [7].
Meanwhile, transformers combined with low-level convolutional operations have been proposed [12]to further improve the original design.
Due to the data-hungry nature of transformers, most transformer-based models for action recognitionrequires large-scale pre-training with image datasets such as ImageNet-21K [9] and JFT-3B [44] toachieve good performance.
This pre-training and fine-tuning training paradigm is time-consumingand it is not parameter-efficient, meaning that for each action dataset, a new model need to be trainedend-to-end.
Different from large image datasets such as ImageNet-21K that covers a wide rangeof object classes, currently the most diverse action dataset, Kinetics-700, only contains 700 classes.
Each action dataset may be also limited to a certain topic or camera views.
For example, Moments- in-Time [31] only contains short actions that happen in 3 seconds and Something-Something-v2 [18]focuses on close-up camera view of person-object interactions.
These dataset biases might hindersmodels trained on a single dataset to generalize and be used in a practical way.
These challenges inaction datasets make learning a general-purpose action model difficult.
An ideal model should beable to cover a wide range of action classes meanwhile keeping the computation cost low.
However,simply combining all these datasets to train a joint model does not lead to good performance [27].
In previous work [45], the authors have shown the benefit of training a joint model using multipleaction datasets but their method requires large-scale image datasets such as ImageNet-21K [9] and
JFT-3B [44], which is not available to the research community.
In this paper, we propose a general training paradigm for Cross -dataset training of Ro bust a ctionrecognition mo d els, CrossRoad .
Our method is designed to learn robust and informative featurerepresentations in a principled way, using the informative loss for regularization.
We do not assumethe availability of large-scale image dataset pre-training (although one can certainly start with).
Sincethere are intrinsic relations between different classes across different action datasets (See Fig.
1 forexamples of similar classes from two datasets), we propose a projection loss to mine such relationssuch that the whole network is trained to avoid over-fitting to certain dataset biases.
Finally, allproposed loss terms are weighted using learned parameters, so no hyper-parameter tuning is needed.
Our empirical findings as shown in Table 1 indicate that our robust training method can consistentlyimprove model backbone performance across multiple datasets.
We show that our model can achievecompetitive results compared to state-of-the-art methods, even without large-scale image datasetpre-training, and with lower computational cost.
The main contributions of this paper are three-fold:
• To our knowledge, this is the first work to introduce informative representation regularization
into cross-dataset training for action recognition.
• We propose an effective approach to mine intrinsic class relations in cross-dataset trainingby introducing the projection loss.
• Our method requires negligible computation overhead during training and no additionalcomputation during inference to the backbone network.
Extensive experiments on various
datasets suggest our method can consistently improve performance
Related Work
CNNs and Vision Transformers.
CNNs work as the standard backbones throughout computer visiontasks for image and video.
Various effective convolutional neural architectures have been raised toimprove the precision and efficiency ( e.g. , VGG [34], ResNet [19] and DenseNet [20]).
Although
CNNs are still the primary models for computer vision, the Vision Transformers have alreadyshown their enormous potential.
Vision Transformer (ViT [10]) directly applies the architecture of
Transformer on image classification and get encouraging performance.
ViT and its variants ( e.g. ,
ViViT [2], TimesFormer [4], MViT [12], Swin [29], MTV [41]) achieve outstanding results in bothimage and video processing in recent years.
These transformer-based modeling approaches havedriven most of the recent advancements in the action recognition task.
We focus on the trainingparadigm instead and study how training on various datasets can lead to robust general-purposemodels.
Action Recognition/Classification.
The research of action recognition has advanced with both newdatasets and new models.
The modern benchmarks for action recognition is the Kinetics dataset[21].
The Kinetics dataset proposes a large benchmark with more categories and more videos ( e.g. ,400 categories 160,000 clips in [21] and 700 categories in [7]) as a harder benchmark compared toprevious datasets like UCF-101 [36].
The Moments-in-Time [31] (MiT) dataset provides a millionshort video clips that covers 305 action categories.
Note that it is impossible for Kinetics and MiTdatasets to cover all the possible actions in all possible scales.
For example, surveillance actions aremissing in the two datasets.
Many new approaches [39, 46, 28, 15, 42] have been carried out onthese datasets, of which the SlowFast network [15] and MViT [12] obtain promising performance.
We can see the trend of action recognition in the last two decades is to collect larger datasets ( e.g. ,
Kinetics) and build models with a larger capacity.
Cross-dataset Training.
Different datasets are constructed using different data sources ( e.g. , movies,internet videos, and daily photography), labeling definitions (actions by a single person, actionsbetween persons, and actions by a person with some objects). Thus, dataset bias and domain shiftare inevitably involved. The domain shift hampers the generalization of the recognition modeland restrict application feasibility.
Several works [32, 8, 35] were proposed to tackle this issue.
Previous works typically focused on the issue of domain adaption or transfer learning.
However,the transferred models still suffer from problem of parameter-inefficiency, meaning that separatemodels are needed for different datasets.
Larger datasets often deliver better results.
Combiningmultiple datasets to boost data size, and improve the final performance [17], and the simultaneoususe of multiple datasets is also likely to alleviate the damaging impact of dataset bias.
OmniSource[11] utilizes web images as part of the training dataset to expand the diversity of the training datato reduce dataset bias.
VATT [1] uses additional multi-modal data for self-supversied pretrainingand finetunes on downstream datasets.
CoVeR [45] combines image and video training even duringthe finetuning stage and reports significant performance boost compared to single-dataset training.
Within each batch, CoVeR randomly samples from both image and video datasets and the samplingrate is proportional to the size of the datasets.
PolyViT [27] further extends to training with image,video and audio datasets.
Several sampling procedures including Task-by-Task, Alternating, Uniformtask sampling, etc., are proposed to facilitate effective co-training.
In this paper, we propose to utilizeregularization methods and simple random sampling to fully leverage information across differentdatasets to produce general-purpose representations, without the use of any image or additional datafrom other modality.
Method
Our method is built upon the backbone of the Improved Multi-scale Vision Transformers(MViTv2)
Note that our approach works with any action recognition backbones.
Givenvideos from multiple datasets during training, the model backbone takes the video frames and produces feature embeddings for each video.
The same number of Multi-layer Perceptron (MLP) as thedatasets are constructed as model heads to predict action classes for each dataset.
To facilitate robustcross-dataset training, we propose two loss terms, namely, the informative loss and projection loss .
The informative loss aims to maximize the embeddings’ representative power.
The projection loss,with the help of multiple cross-dataset projection layers, guides the model to learn intrinsic relationsbetween classes of different dataset, hence the model heads can be trained jointly.
See Fig.
1 for anoverview of our framework.
In this section, we first briefly describe the MViTv2 backbone design,and then present our proposed robust cross-dataset training paradigm.
3.1 The MViTv2 Backbone
Our model is based on the improved multi-scale vision transformers (MViTv2) [12, 26], which learnsa hierarchy from dense (in space) and simple (in channels) to coarse and complex features.
The series of work of vision transformers [10] (ViTs) follows the basic self-attention architecture [40] originallyproposed for machine translation. In contrast to natural language which can be directly tokenizedinto words, given the input video V ∈ R T × H × W × 3 , ViTs extract tokens by splitting the video into N = ⌊ T/t ⌋ ×
⌊ H/h ⌋ ×
⌊ W/w ⌋ non-overlapping patches, { v 1 , · · · , v N ∈ R t × h × w } . Each patch isthen projected into a patch embedding by a 3D convolution operator E . All patch embeddings arethen concatenated into a sequence, and separate learnable spatial-temporal positional embeddingsp s , p t are also added to this sequence. The patch embedding process is denoted by:
[Equation] The P function extends the separate position embedding into the length of the sequence by repeatingat the same spatial or temporal location. d p is the dimension of the patch embedding. The key component of the MViTv1 model [12] is the Multi Head Pooling Attention (MHPA), whichpools the sequence of latent tensors to reduce the spatial or temporal dimension of the featurerepresentations.
In MViTv2 [26], a residual connection in MHPA for the pooled query tensor and adecomposed relative position embedding 1 are added.
In this paper, we use 3D convolution as thepooling operation.
Fig. 2 shows the detailed architecture of the MViTv2 block (our implementation).
Each MViTv2 block consists of a multi-head pooling attention layer (MHPA) and a multi-layerperceptron (MLP), and the residual connections are built in each layer.
The feature of each MViTv2block is computed by:
[Equation]
where X is the input tensor to each block.
Multiple MViTv2 blocks are grouped into stages to reducethe spatial dimension while increase the channel dimension.
The full backbone architecture is listedin supplementary material.
Classification head For the action recognition problem, the model produces C-class classificationlogits by first averaging the feature tensor from the last stage along the spatial-temporal dimensions (we do not use the [CLASS] token in our transformer implementation), denoted as z ∈ R d .
Alinear classification layer is then applied on the averaged feature tensor to produce the final output,y =
W out z ∈ R C .
Pre-training and finetuning In the standard training paradigm for action recognition, modelsare pretrained using image datasets (ImageNet [9] or large-scale datasets like JFT-3B [44]) andthen finetune on the target action recognition dataset. For CNN-based backbones, model weightinflation [21] is utilized to adapt the model trained on 2D image data to 3D video input. Fortransformer-based backbones, as the inputs are tokenized into a sequence, to adapt the model fromimage pretraining, the positional embeddings are interpolated to account for the additional temporaldimension before the finetuning.
Cross-dataset training paradigm In general, to facilitate cross-dataset training of K datasets, thesame number of classification heads are appended to the feature embeddings.
The k -th datasetclassification output is defined as Y k
= h k ( Z ; W k ) ∈ R B × C , where h k could be a linear layer or a
MLP and W k is the layer parameter.
3.2 CrossRoad : Robust Cross-dataset Training
Our training process fully leverages different action recognition datasets by enforcing an informativeloss to maximize the expressiveness of the feature embedding and a projection loss for each datasetthat mines the intrinsic relations between classes across other datasets.
We then use uncertainty toweight different loss terms without the need for any hyper-parameters.
Informative loss.
Inspired by the recently proposed VICReg [3] and Barlow Twins [43] methodfor self-supervised learning in image recognition, we propose to utilize an informative loss functionwith two terms, variance and covariance , to maximize the expressiveness of each variable of theembedding.
This loss is applied to each mini-batch, without the need for batch-wise nor featurewise normalization.
Given the feature embeddings of the mini-batch, Z ∈ R B × d , an expander(implemented as a two-layer MLP) maps the representations into an embedding space for theinformative loss to be computed, denoted as Z ′ ∈ R B × d .
The variance loss is computed using ahinge function and the standard deviation of each dimension of the embeddings by:
[Equation]
Where : is a tensor slicing operation that extracts all elements from a dimension, and ¯ Z ′ :
j is themean over the mini-batch for j -th dimension.
ϵ is a small scalar preventing numerical instabilities.
With random sampling videos across multiple datasets for each batch, this criterion encourages thevariance of each dimension in the embedding to be close to 1, preventing embedding collapse [43].
The covariance loss c ( Z ′ ) is defined as:
[Equation]
Inspired by VICReg [3] and Barlow Twins [43], we first compute the covariance matrix of the featureembeddings in the batch, C ( Z ′ ) , and then define the covariance term L c as the sum of the squaredoff-diagonal coefficients of C ( Z ′ ) , scaled by a factor of 1 /d .
Projection Loss.
In previous works [45, 27], the intrinsic relations between classes from acrossdifferent datasets have been mostly ignored during training.
We believe that samples in one datasetcan be utilized to train the classification head of other datasets.
As shown in Fig.
1, the “Cleanand jerk” video sample from Kinetics can be considered as a positive sample for “Weightlifting” in
Moments-in-Time as well (but not vice versa).
Based on this intuition, we propose to add a directedprojection layer for each pair of datasets for the model to learn such intrinsic relations.
One can alsoinitialize the projection using prior knowledge but it is out-of-scope for this paper.
Given the output from the k -th dataset classification output, the projected classification output is defined as:
[Equation]
[Equation]
where C k is the number of classes for the k -th dataset and W projik is the learned directed classprojection weights from i -th to k -th dataset.
In this paper we only consider a linear projectionfunction.
We then use the ground truth labels of the k -th dataset to compute standarad cross-entropyloss:
[Equation]
where ˆ Y k,c is the ground truth label for the c -th class from the k -th dataset.
Training.
We jointly optimize the informative loss and the projection loss during cross-datasettraining.
To avoid tuning loss weights of different terms, we borrow the weighting scheme frommulti-task learning [22] and define the overall objective function as:
[Equation]
where σ is a vector of parameters of size K (the number of datasets) for each projection loss term.
Experiments
In this section, to demonstrate the efficacy of our training framework, we experiment on five action recognition datasets, including Kinetics-400 [21], Something-Something-v2 [18], Momentsin-Time [31], Activitynet [5] and Kinetics-700 [7].
The action recognition task is defined to be aclassification task given a trimmed video clip.
In the experiments, we aim to showcase that ourmethod can achieve significant performance improvement with minimal computation overhead.
4.1 Experimental Setup
Datasets.
We evaluate our method on five datasets.
Kinetics-400 [21] (K400) consists of about 240Ktraining videos and 20K validation videos in 400 human action classes.
The videos are about 10seconds long.
Kinetics-700 [7] (K700) extends the action classes to 700 with 545K training and35K validation videos.
The Something-Something-v2 (SSv2) [18] dataset contains person-objectinteractions, which emphasizes temporal modeling.
SSv2 includes 168K videos for training and24K videos for evaluation on 174 action classes.
The Moments-in-Time (MiT) dataset is one of thelargest action dataset with 727K training and 30k validation videos.
MiT videos are mostly short3-second clips.
The ActivityNet dataset [5] (ActNet) originally contains untrimmed videos withtemporal annotations of 200 action classes.
We cut the videos into 10-second long clips and splitthe dataset into 107K training and 16K testing.
Following previous works [15, 45], we follow thestandard dataset split and report top-1/top-5 classification accuracy on the test split for all datasets.
We conduct two sets of experiments, namely K400 + MiT + SSv2 + ActNet and K700 + MiT + SSv2+ ActNet.
Implementation.
Our backbone model utilizes MViTv2 as described in Section 3.1.
Our modelsare trained from scratch with random initialization, without using any pre-training (same as in [15]and different from previous works [45, 27] that require large-scale image dataset pre-training like
ImageNet-21K [9] or JFT-3B [44]).
We follow standard dataset splits as previous works [26, 15, 41].
See more details in the supplementary material.
Baselines.
PolyViT [27] utilizes multi-task learning on image, video and audio datasets to improvevision transformer performance.
The backbone they used are based on ViT-ViViT [2].
Similarly,
VATT [1] utilizes additional multi-modal data for self-supversied pretraining and finetunes ondownstream datasets.
The backbone network is based on ViT [10].
CoVER [45] is a recentlyproposed co-training method that includes training with images and videos simultaneously.
Theirmodel backbone is based on TimeSFormer [4].
We also compare our method with other recent modelstrained using large-scale image datasets.
See Table 1 and Table 2 for the full list. [Table]
4.2 Main Results
We summarize our method performance in Table 1 and Table 2.
We train our model jointly on MiT,
SSv2, ActNet and two version of the Kinetics datasets.
We first compare our method with the original MViTv2 backbone in Table 1.
The “MViTv2 w/orel” indicates the model without the relative positional embedding in the original paper. As we see,compared to our implementation, the performance difference is minor.
The difference could be dueto the small difference in the datasets (Kinetics videos are taking down from Youtube from the timeof release.
See supplementary material for full dataset statistics.
We train our baseline model on thetraining set of each dataset to investigate the baseline performance.
As we see, after adding robustjoint training proposed in this paper, performance on each dataset has increased by 2.1%, 3.1%,1.9% and 5.9% on K400, MiT, SSv2, ActivityNet, respectively in terms of top-1 accuracy.
Note [Table] that our method achieves such improvement withtout large-scale image pre-training and additionalcomputational cost.
We then compare our method with state-of-the-art on these datasets.
We train a higher resolutionmodel with larger spatial inputs (312p) and achieves better performance compared to recent crossdataset training methods, CoVER [45] and PolyVit [27], on Kinetics-400, and significantly better on
MiT and SSv2, as shown in Table 1.
Note that our model does not use any image training datasets,and our model computation cost is only a fraction of the baselines.
We also show that our performanceboost does not come from the additional training dataset of ActivityNet in Table 3.
Our method also achieves competitive results compared to state-of-the-art models trained with largescale image dataset (ImageNet-21K [9]).
Compared to a recent method, MTV-B [41], our method isable to achieve significantly better top-1 accuracy across Kinetics-400, MiT, SSv2 by 0.8%, 1.4%,0.8%, respectively, at half of the computation cost and without large-scale pre-training.
Note thatour model is parameter-efficient, while multiple MTV-B models need to be trained and tested onthese datasets separately.
Our method can achieve better performance with a deeper base backbone orlarger resolution inputs but we have not tested due to limitation of computation resources.
We then compare our method on the Kinetics-700, MiT, SSv2 and ActivityNet training with baselines.
Our parameter-efficient model can achieve better performance than MTV-B [41] at one-fifth ofthe computation cost.
With a larger resolution model at 312p, we achieves significantly betterperformance than the baseline across Kinetics-400, MiT, SSv2 by 2.2%, 4.9%, 3.4%, respectively.
4.3 Ablation Experiments
In this section, we perform ablation studies on the K400 set.
To understand how action models canbenefit from our training method, we explore the following questions (results are shown in Table 3):
Does our proposed robust loss help?
We compare our model training with vanilla cross datasettraining, where multiple classification heads are attached to the same backbone and the model istrained simply with cross-entropy loss.
The vanilla model is trained from a K400 checkpoint as ours.
As shown in Table 3, we try training the vanilla model with both the same training schedule as oursand a 4x longer schedule.
As we see, there is a significant gap between the overall performance of thevanilla model and ours, validating the efficacy of our proposed method.
Also, longer training schedule [Table] does not lead to better performance on some datasets, including SSv2, suggesting vanilla crossdataset training is unstable.
In terms of performance on ActivityNet, we observe that both trainingmethods achieve good results, which might be because ActivityNet classes are highly overlappedwith Kinetics-400 (65 out of 200).
How important is the informative loss?
We then experiment with removing the informative loss(Section 3.2) during cross-dataset training.
It seems that the feature embedding of the model collapseand the model is not trained at all.
How important is the projection loss?
We then experiment with removing the projection heads(Section 3.2) during cross-dataset training.
The model is trained with the original cross-entropy lossand the informative loss.
As shown in Table 3, the performance on MiT and SSv2 suffers by a largemargin, indicating that the projection design helps boost training by better utilizing cross-datasetinformation.
Does the additional ActivityNet data help?
In previous methods like CoVER and PolyViT,the ActivityNet dataset has not been used.
In this experiment, we investigate the important ofthe ActivityNet dataset by removing it from the training set.
From Table 3, we can see that theperformance across all datasets drop by a small margin, indicating our superior results compared to
CoVER (see Table 1 and Table 2) come from the proposed robust training paradigm rather than theadditional data.
4.4 Discussion
By cross-dataset training transformers on various datasets, we obtain competitive results on multipleaction datasets, without large-scale image datasets pre-training.
Our method, CrossRoad , is parameterefficient and does not require hyper-parameter tuning.
Current limitations of our experiments are thatwe have not tried co-training with image datasets such as ImageNet-21K [9].
Hence we do not knowhow much performance gain that would entail.
We plan to explore this in future work.
In addition,we have not tried training larger model with FLOPs on par with state-of-the-art or other backbonearchitectures (e.g. CNNs) due to limitation of our computational resources.
Hence we are not surehow our algorithm would behave with these models.
Although our model is trained on multipledatasets, potential dataset biases can still cause negative societal impact in real-world deployment, asthe datasets we have do not fully represent all aspects of human actions.
Conclusion
In this paper, we present CrossRoad , a robust cross-dataset training approach that maximizesinformation content of representation and learns intrinsic relations between individual datasets.
Ourmethod can train parameter-efficient models that perform well across multiple datasets.
Checklist
For all authors...
(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s
contributions and scope?
[Yes]
(b) Did you describe the limitations of your work?
[Yes] See Section 4.
(c) Did you discuss any potential negative societal impacts of your work?
[Yes] See
Section 4.
(d) Have you read the ethics review guidelines and ensured that your paper conforms to
them?
[Yes]
If you are including theoretical results...
(a) Did you state the full set of assumptions of all theoretical results?
[N/A]
(b) Did you include complete proofs of all theoretical results?
[N/A]
If you ran experiments...
(a) Did you include the code, data, and instructions needed to reproduce the main exper-
imental results (either in the supplemental material or as a URL)?
[No] We plan to
open-source our code upon paper acceptance.
We have provided detailed implementa-
tion instructions in the main text and in the supplemental material.
(b) Did you specify all the training details (e.g., data splits, hyperparameters,
how they
were chosen)?
[Yes] See Section 4 and the supplemental material.
(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)?
[No] We follow standard data splits and evaluation protocol as
previous works.
See Section 4.
(d) Did you include the total amount of compute and the type of resources used (e.g., typeof GPUs, internal cluster, or cloud provider)?
[Yes] See supplemental material.
If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
(a) If your work uses existing assets, did you cite the creators?
[Yes]
(b) Did you mention the license of the assets?
[No] We used open-source (Apache-2.
licensed) MViTv2 code and standard public datasets
(c) Did you include any new assets either in the supplemental material or as a URL?
[No]
(d) Did you discuss whether and how consent was obtained from people whose data you’re
using/curating?
[No]
(e) Did you discuss whether the data you are using/curating contains personally identifiable
information or offensive content?
[Yes] See Section 4.
If you used crowdsourcing or conducted research with human subjects...
(a) Did you include the full text of instructions given to participants and screenshots, if
applicable?
[N/A](
[Table]
) Did you describe any potential participant risks, with links to Institutional Review
Board ( IRB) approvals, if applicable?
[N/A
c) Did you include the estimated hourly wage paid to participants and the total amount
spent on participant compensation?
[N/A