Giter Site home page Giter Site logo

lukashedegaard / trn.pytorch Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xumingze0308/trn.pytorch

0.0 2.0 0.0 467 KB

Fork with added FLOPs for the paper: "Temporal Recurrent Networks for Online Action Detection"

License: MIT License

Python 100.00%

trn.pytorch's Introduction

Temporal Recurrent Networks for Online Action Detection

Updates

๐Ÿ’ฅ November 18th 2021: The code of Long Short-Term Transformer (LSTR) is released here.

๐Ÿ’ฅ July 08th 2021: We are releasing Long Short-Term Transformer (LSTR), a more effective and efficient method for modeling prolonged sequence data! LSTR achieves SoTA on Online Action Detection benchmarks.

๐Ÿ’ฅ May 25th 2021: For future comparison with TRN using Kinetics pretrained features, we report our results on THUMOS as 62.1% in mAP, on TVSeries as 86.2% in cAP, and on HACS Segment as 78.9% in mAP.

For feature encoding, we use ResNet-50 model for the RGB input, and the BN-Inception model for the optical flow input. To replicate our results, please use the pretrained weights of ResNet-50 in MMAction2 and BN-Inception in this repo.

Introduction

This is a PyTorch reimplementation for our ICCV 2019 paper "Temporal Recurrent Networks for Online Action Detection".

network

Environment

  • The code is developed with CUDA 9.0, Python >= 3.6, PyTorch >= 1.0

Data Preparation

  1. Download the HDD and THUMOS'14 datasets.

  2. Extract feature representations for video frames.

    Note: We compute the optical flow for the THUMOS'14 dataset using FlowNet2.0.

  3. If you want to use our dataloaders, please make sure to put the files as the following structure:

    • HDD dataset:
    $YOUR_PATH_TO_HDD_DATASET
    โ”œโ”€โ”€ inceptionresnetv2/
    |   โ”œโ”€โ”€ 201702271017.npy (of size L x 1536 x 8 x 8)
    โ”‚ย ย  โ”œโ”€โ”€ ...
    โ”œโ”€โ”€ sensor/
    |   โ”œโ”€โ”€ 201702271017.npy (of size L x 8)
    |   โ”œโ”€โ”€ ...
    โ”œโ”€โ”€ target/
    |   โ”œโ”€โ”€ 201702271017.npy (of size L)
    |   โ”œโ”€โ”€ ...
    
    • THUMOS'14 dataset:
    $YOUR_PATH_TO_THUMOS_DATASET
    โ”œโ”€โ”€ resnet200-fc/
    |   โ”œโ”€โ”€ video_validation_0000051.npy (of size L x 2048)
    โ”‚ย ย  โ”œโ”€โ”€ ...
    โ”œโ”€โ”€ bn_inception/
    |   โ”œโ”€โ”€ video_validation_0000051.npy (of size L x 1024)
    |   โ”œโ”€โ”€ ...
    โ”œโ”€โ”€ target/
    |   โ”œโ”€โ”€ video_validation_0000051.npy (of size L x 22)
    |   โ”œโ”€โ”€ ...
    
  4. Create softlinks of datasets:

    cd TRN.pytorch
    ln -s $YOUR_PATH_TO_HDD_DATASET data/HDD
    ln -s $YOUR_PATH_TO_THUMOS_DATASET data/THUMOS
    

Training

  • Single GPU training on HDD dataset:
cd TRN.pytorch
# Training from scratch
python tools/trn_hdd/train.py --gpu $CUDA_VISIBLE_DEVICES
# Finetuning from a pretrained model
python tools/trn_hdd/train.py --checkpoint $PATH_TO_CHECKPOINT --gpu $CUDA_VISIBLE_DEVICES
  • Multi-GPU training on HDD dataset:
cd TRN.pytorch
# Training from scratch
python tools/trn_hdd/train.py --gpu $CUDA_VISIBLE_DEVICES --distributed
# Finetuning from a pretrained model
python tools/trn_hdd/train.py --checkpoint $PATH_TO_CHECKPOINT --gpu $CUDA_VISIBLE_DEVICES --distributed
  • Single GPU training on THUMOS'14 dataset:
cd TRN.pytorch
# Training from scratch
python tools/trn_thumos/train.py --gpu $CUDA_VISIBLE_DEVICES
# Finetuning from a pretrained model
python tools/trn_thumos/train.py --checkpoint $PATH_TO_CHECKPOINT --gpu $CUDA_VISIBLE_DEVICES
  • Multi-GPU training on THUMOS'14 dataset:
cd TRN.pytorch
# Training from scratch
python tools/trn_thumos/train.py --gpu $CUDA_VISIBLE_DEVICES --distributed
# Finetuning from a pretrained model
python tools/trn_thumos/train.py --checkpoint $PATH_TO_CHECKPOINT --gpu $CUDA_VISIBLE_DEVICES --distributed

Evaluation

  • HDD dataset:
cd TRN.pytorch
python tools/trn_hdd/eval.py --checkpoint $PATH_TO_CHECKPOINT --gpu $CUDA_VISIBLE_DEVICES
  • THUMOS'14 dataset:
cd TRN.pytorch
python tools/trn_thumos/eval.py --checkpoint $PATH_TO_CHECKPOINT --gpu $CUDA_VISIBLE_DEVICES

NOTE: There are two kinds of evaluation methods in our code. (1) Using --debug during training considers each short video clip (consisting of 90 and 64 consecutive frames for HDD and THUMOS'14 datasets, respectively) as one test sample, and separately runs inference and evaluates on all short video clips (even though some of them are from the same long video). (2) Using eval.py after training runs inference and evaluates on long videos (frame by frame, from the beginning to the end), which is the evaluation method we reported in the paper.

Citations

If you are using the data/code/model provided here in a publication, please cite our paper:

@inproceedings{onlineaction2019iccv,
    title = {Temporal Recurrent Networks for Online Action Detection},
    author = {Mingze Xu and Mingfei Gao and Yi-Ting Chen and Larry S. Davis and David J. Crandall},
    booktitle = {IEEE International Conference on Computer Vision (ICCV)},
    year = {2019}
}

trn.pytorch's People

Contributors

xumingze0308 avatar lukashedegaard avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.