• Stars
    star
    366
  • Rank 116,547 (Top 3 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created almost 4 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

[CVPR 2021] TDN: Temporal Difference Networks for Efficient Action Recognition

TDN: Temporal Difference Networks for Efficient Action Recognition (CVPR 2021)

1

PWC
PWC

News

[Mar 24, 2022] We present VideoMAE, a new SOTA on Kinetics, Something-Something, and AVA.
[Dec 1, 2021] We update the TDN-ResNet101 on SSV2 in model zoo.
[Mar 5, 2021] TDN has been accepted by CVPR 2021.
[Dec 26, 2020] We have released the PyTorch code of TDN.

Overview

We release the PyTorch code of the TDN(Temporal Difference Networks). This code is based on the TSN and TSM codebase. The core code to implement the Temporal Difference Module are ops/base_module.py and ops/tdn_net.py.

TL; DR. We generalize the idea of RGB difference to devise an efficient temporal difference module (TDM) for motion modeling in videos, and provide an alternative to 3D convolutions by systematically presenting principled and detailed module design.

Prerequisites

The code is built with following libraries:

Data Preparation

We have successfully trained TDN on Kinetics400, UCF101, HMDB51, Something-Something-V1 and V2 with this codebase.

  • The processing of Something-Something-V1 & V2 can be summarized into 3 steps:

    1. Extract frames from videos(you can use ffmpeg to get frames from video)
    2. Generate annotations needed for dataloader ("<path_to_frames> <frames_num> <video_class>" in annotations) The annotation usually includes train.txt and val.txt. The format of *.txt file is like:
      dataset_root/frames/video_1 num_frames label_1
      dataset_root/frames/video_2 num_frames label_2
      dataset_root/frames/video_3 num_frames label_3
      ...
      dataset_root/frames/video_N num_frames label_N
      
    3. Add the information to ops/dataset_configs.py.
  • The processing of Kinetics400 can be summarized into 3 steps:

    1. We preprocess our data by resizing the short edge of video to 320px. You can refer to MMAction2 Data Benchmark for TSN and SlowOnly.
    2. Generate annotations needed for dataloader ("<path_to_video> <video_class>" in annotations) The annotation usually includes train.txt and val.txt. The format of *.txt file is like:
      dataset_root/video_1.mp4  label_1
      dataset_root/video_2.mp4  label_2
      dataset_root/video_3.mp4  label_3
      ...
      dataset_root/video_N.mp4  label_N
      
    3. Add the information to ops/dataset_configs.py.

    Note: We use decord to decode the Kinetics videos on the fly.

Model Zoo

Here we provide some off-the-shelf pretrained models. The accuracy might vary a little bit compared to the paper, since the raw video of Kinetics downloaded by users may have some differences.

Something-Something-V1

Model Frames x Crops x Clips Top-1 Top-5 checkpoint
TDN-ResNet50 8x1x1 52.3% 80.6% link
TDN-ResNet50 16x1x1 53.9% 82.1% link

Something-Something-V2

Model Frames x Crops x Clips Top-1 Top-5 checkpoint
TDN-ResNet50 8x1x1 64.0% 88.8% link
TDN-ResNet50 16x1x1 65.3% 89.7% link
TDN-ResNet101 8x1x1 65.8% 90.2% link
8x3x1 67.1% 90.5% -
TDN-ResNet101 16x1x1 66.9% 90.9% link
16x3x1 68.2% 91.6% -
TDN-ResNet101 (8+16)x1x1 68.2% 91.6% -
(8+16)x3x1 69.6% 92.2% -

Kinetics400

Model Frames x Crops x Clips Top-1 (30 view) Top-5 (30 view) checkpoint
TDN-ResNet50 8x3x10 76.6% 92.8% link
TDN-ResNet50 16x3x10 77.5% 93.2% link
TDN-ResNet101 8x3x10 77.5% 93.6% link
TDN-ResNet101 16x3x10 78.5% 93.9% link

Testing

  • For center crop single clip, the processing of testing can be summarized into 2 steps:
    1. Run the following testing scripts:
      CUDA_VISIBLE_DEVICES=0 python3 test_models_center_crop.py something \
      --archs='resnet50' --weights <your_checkpoint_path>  --test_segments=8  \
      --test_crops=1 --batch_size=16  --gpus 0 --output_dir <your_pkl_path> -j 4 --clip_index=0
      
    2. Run the following scripts to get result from the raw score:
      python3 pkl_to_results.py --num_clips 1 --test_crops 1 --output_dir <your_pkl_path>  
      
  • For 3 crops, 10 clips, the processing of testing can be summarized into 2 steps:
    1. Run the following testing scripts for 10 times(clip_index from 0 to 9):
      CUDA_VISIBLE_DEVICES=0 python3 test_models_three_crops.py  kinetics \
      --archs='resnet50' --weights <your_checkpoint_path>  --test_segments=8 \
      --test_crops=3 --batch_size=16 --full_res --gpus 0 --output_dir <your_pkl_path>  \
      -j 4 --clip_index <your_clip_index>
      
    2. Run the following scripts to ensemble the raw score of the 30 views:
      python pkl_to_results.py --num_clips 10 --test_crops 3 --output_dir <your_pkl_path> 
      

Training

This implementation supports multi-gpu, DistributedDataParallel training, which is faster and simpler.

  • For example, to train TDN-ResNet50 on Something-Something-V1 with 8 gpus, you can run:
    python -m torch.distributed.launch --master_port 12347 --nproc_per_node=8 \
                main.py  something  RGB --arch resnet50 --num_segments 8 --gd 20 --lr 0.01 \
                --lr_scheduler step --lr_steps  30 45 55 --epochs 60 --batch-size 8 \
                --wd 5e-4 --dropout 0.5 --consensus_type=avg --eval-freq=1 -j 4 --npb 
    
  • For example, to train TDN-ResNet50 on Kinetics400 with 8 gpus, you can run:
    python -m torch.distributed.launch --master_port 12347 --nproc_per_node=8 \
            main.py  kinetics RGB --arch resnet50 --num_segments 8 --gd 20 --lr 0.02 \
            --lr_scheduler step  --lr_steps 50 75 90 --epochs 100 --batch-size 16 \
            --wd 1e-4 --dropout 0.5 --consensus_type=avg --eval-freq=1 -j 4 --npb 
    

Contact

[email protected]

Acknowledgements

We especially thank the contributors of the TSN and TSM codebase for providing helpful code.

License

This repository is released under the Apache-2.0. license as found in the LICENSE file.

Citation

If you think our work is useful, please feel free to cite our paper 😆 :

@InProceedings{Wang_2021_CVPR,
    author    = {Wang, Limin and Tong, Zhan and Ji, Bin and Wu, Gangshan},
    title     = {TDN: Temporal Difference Networks for Efficient Action Recognition},
    booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
    month     = {June},
    year      = {2021},
    pages     = {1895-1904}
}

More Repositories

1

VideoMAE

[NeurIPS 2022 Spotlight] VideoMAE: Masked Autoencoders are Data-Efficient Learners for Self-Supervised Video Pre-Training
Python
1,295
star
2

MixFormer

[CVPR 2022 Oral & TPAMI 2024] MixFormer: End-to-End Tracking with Iterative Mixed Attention
Python
445
star
3

EMA-VFI

[CVPR 2023] Extracting Motion and Appearance via Inter-Frame Attention for Efficient Video Frame Interpolatio
Python
339
star
4

SparseBEV

[ICCV 2023] SparseBEV: High-Performance Sparse 3D Object Detection from Multi-Camera Videos
Python
328
star
5

MOC-Detector

[ECCV 2020] Actions as Moving Points
Python
264
star
6

AdaMixer

[CVPR 2022 Oral] AdaMixer: A Fast-Converging Query-Based Object Detector
Jupyter Notebook
236
star
7

CamLiFlow

[CVPR 2022 Oral & TPAMI 2023] Learning Optical Flow and Scene Flow with Bidirectional Camera-LiDAR Fusion
Python
216
star
8

SparseOcc

[ECCV 2024] Fully Sparse 3D Occupancy Prediction & RayIoU Evaluation Metric
Python
199
star
9

MeMOTR

[ICCV 2023] MeMOTR: Long-Term Memory-Augmented Transformer for Multi-Object Tracking
Python
141
star
10

MixFormerV2

[NeurIPS 2023] MixFormerV2: Efficient Fully Transformer Tracking
Python
136
star
11

SportsMOT

[ICCV 2023] SportsMOT: A Large Multi-Object Tracking Dataset in Multiple Sports Scenes
Python
133
star
12

SADRNet

[TIP 2021] SADRNet: Self-Aligned Dual Face Regression Networks for Robust 3D Dense Face Alignment and Reconstruction
Python
126
star
13

MultiSports

[ICCV 2021] MultiSports: A Multi-Person Video Dataset of Spatio-Temporally Localized Sports Actions
Python
106
star
14

FCOT

[CVIU] Fully Convolutional Online Tracking
Python
91
star
15

MMN

[AAAI 2022] Negative Sample Matters: A Renaissance of Metric Learning for Temporal Grounding
Python
88
star
16

RTD-Action

[ICCV 2021] Relaxed Transformer Decoders for Direct Action Proposal Generation
Python
86
star
17

MOTIP

Multiple Object Tracking as ID Prediction
Python
84
star
18

BCN

[ECCV 2020] Boundary-Aware Cascade Networks for Temporal Action Segmentation
Python
84
star
19

LinK

[CVPR 2023] LinK: Linear Kernel for LiDAR-based 3D Perception
Python
81
star
20

MixSort

[ICCV2023] MixSort: The Customized Tracker in SportsMOT
Python
69
star
21

CPD-Video

Learning Spatiotemporal Features via Video and Text Pair Discrimination
Python
60
star
22

SGM-VFI

[CVPR 2024] Sparse Global Matching for Video Frame Interpolation with Large Motion
Python
59
star
23

Structured-Sparse-RCNN

[CVPR 2022] Structured Sparse R-CNN for Direct Scene Graph Generation
Jupyter Notebook
57
star
24

TRACE

[ICCV 2021] Target Adaptive Context Aggregation for Video Scene Graph Generation
Python
57
star
25

CRCNN-Action

Context-aware RCNN: a Baseline for Action Detection in Videos
Python
53
star
26

STMixer

[CVPR 2023] STMixer: A One-Stage Sparse Action Detector
Python
49
star
27

BasicTAD

BasicTAD: an Astounding RGB-Only Baselinefor Temporal Action Detection
Python
48
star
28

DDM

[CVPR 2022] Progressive Attention on Multi-Level Dense Difference Maps for Generic Event Boundary Detection
Python
48
star
29

VideoMAE-Action-Detection

[NeurIPS 2022 Spotlight] VideoMAE for Action Detection
Python
47
star
30

MGSampler

[ICCV 2021] MGSampler: An Explainable Sampling Strategy for Video Action Recognition
Python
46
star
31

FSL-Video

[BMVC 2021] A Closer Look at Few-Shot Video Classification: A New Baseline and Benchmark
Python
39
star
32

BIVDiff

[CVPR 2024] BIVDiff: A Training-free Framework for General-Purpose Video Synthesis via Bridging Image and Video Diffusion Models
Python
39
star
33

PointTAD

[NeurIPS 2022] PointTAD: Multi-Label Temporal Action Detection with Learnable Query Points
Python
37
star
34

TemporalPerceiver

[T-PAMI 2023] Temporal Perceiver: A General Architecture for Arbitrary Boundary Detection
Python
34
star
35

TIA

[CVPR 2022] Task-specific Inconsistency Alignment for Domain Adaptive Object Detection
Python
33
star
36

CoMAE

[AAAI 2023] CoMAE: Single Model Hybrid Pre-training on Small-Scale RGB-D Datasets
Python
31
star
37

PDPP

[CVPR 2023 Hightlight] PDPP: Projected Diffusion for Procedure Planning in Instructional Videos
Python
27
star
38

JoMoLD

[ECCV 2022] Joint-Modal Label Denoising for Weakly-Supervised Audio-Visual Video Parsing
Python
27
star
39

EVAD

[ICCV 2023] Efficient Video Action Detection with Token Dropout and Context Refinement
Python
24
star
40

CGA-Net

[CVPR 2021] CGA-Net: Category Guided Aggregation for Point Cloud Semantic Segmentation
Python
23
star
41

SSD-LT

[ICCV 2021] Self Supervision to Distillation for Long-Tailed Visual Recognition
Python
22
star
42

TREG

Target Transformed Regression for Accurate Tracking
Python
21
star
43

VFIMamba

VFIMamba: Video Frame Interpolation with State Space Models
Python
21
star
44

DEQDet

[ICCV 2023] Deep Equilibrium Object Detection
Jupyter Notebook
20
star
45

MGMAE

[ICCV 2023] MGMAE: Motion Guided Masking for Video Masked Autoencoding
Python
19
star
46

OCSampler

[CVPR 2022] OCSampler: Compressing Videos to One Clip with Single-step Sampling
Python
17
star
47

SportsHHI

[CVPR 2024] SportsHHI: A Dataset for Human-Human Interaction Detection in Sports Videos
Python
11
star
48

APP-Net

[TIP] APP-Net: Auxiliary-point-based Push and Pull Operations for Efficient Point Cloud Recognition
Python
11
star
49

AMD

[CVPR 2024] Asymmetric Masked Distillation for Pre-Training Small Foundation Models
Python
11
star
50

StageInteractor

[ICCV 2023] StageInteractor: Query-based Object Detector with Cross-stage Interaction
Python
9
star
51

SPLAM

[ECCV 2024 Oral] SPLAM: Accelerating Image Generation with Sub-path Linear Approximation Model
Python
9
star
52

CMPT

[IJCV 2021] Cross-Modal Pyramid Translation for RGB-D Scene Recognition
Python
8
star
53

VLG

VLG: General Video Recognition with Web Textual Knowledge (https://arxiv.org/abs/2212.01638)
Python
8
star
54

DGN

[IJCV 2023] Dual Graph Networks for Pose Estimation in Crowded Scenes
Python
7
star
55

Dynamic-MDETR

[TPAMI 2024] Dynamic MDETR: A Dynamic Multimodal Transformer Decoder for Visual Grounding
Python
7
star
56

BFRNet

Python
6
star
57

ViT-TAD

[CVPR 2024] Adapting Short-Term Transformers for Action Detection in Untrimmed Videos
Python
6
star
58

VideoEval

VideoEval: Comprehensive Benchmark Suite for Low-Cost Evaluation of Video Foundation Model
Python
6
star
59

ZeroI2V

[ECCV 2024] ZeroI2V: Zero-Cost Adaptation of Pre-trained Transformers from Image to Video
Python
5
star
60

PRVG

[CVIU 2024] End-to-end dense video grounding via parallel regression
Python
5
star
61

LogN

[IJCV 2024] Logit Normalization for Long-Tail Object Detection
Python
4
star