Code Monkey home page Code Monkey logo

actionbert's Introduction

ActionBERT

Is Attention All That We Need?

Investigating Transformers for Action Recognition (Video classification)

The aim of this work is to understand the sequence modelling capabilities of transformer models (BERT-like) for continuous input spaces such as video frames, unlike language where the inputs are discrete (vocabulary).

PyTorch Implementation


Table of Contents

The project comprises of the following sections.


Dataset

Given the path to UCF-101's raw dataset folder, prepare the dataset in a standardized format as follows:

$ python3 prepare_ucf101.py \
-v /home/axe/Datasets/UCF_101/raw/videos \
-o /home/axe/Datasets/UCF_101 \
-s 0.8 -fps 1

Produces json files for training & validation sets in the following format:

[
  {
    "video_name": "str",
    "label_idx": "int",
  }
]

Also creates a new directory within the output dir -o for storing video frames, organized as follows:

├── out_dir
    │
    └── frames
        │
        ├── video_1
        │    ├── frame_1.jpg
        │    │   ...
        │    └── frame_n.jpg
        │
        └── video_k
             ├── frame_1.jpg
             │   ...
             └── frame_m.jpg

---

Given the above frames dir -f & split set json -j, produces the final json & embeddings file (npy) in the following format:

$ python3 prepare_data.py -s train \
-f /home/axe/Datasets/UCF_101/frames_1_fps \
-j /home/axe/Datasets/UCF_101/train_ucf101.json \
-o /home/axe/Datasets/UCF_101/data_res18_fps_1 \
-m resnet18 -bs 1024 -nw 4

The files are stored in output dir -o.

Processed dataset

{
  "data": [
            {
                "video_idx": "int",
                "video_name": "str",
                "video_length": "int",
                "label_idx": "int"
            }
         ],
  "memmap_size": "tuple(total_videos, max_video_len, emb_dim)",    
  "split": "str"
}

The video_idx refers to the 0th axis of the embeddings array.

Embeddings

np.array(shape=[total_videos, max_video_len, emb_dim])

Architecture

BiLSTM

  • Pre-Trained Conv + LSTM

  • End-to-End Conv + LSTM


Transformer

  • Pre-Trained Conv + Transformer

  • End-to-End Conv + Transformer?



Training

Run the following script for training:

$ python3 main.py --mode train --expt_dir ./results_log  \
--expt_name BERT --model bert \
--data_dir ~/Datasets/UCF_101/processed_fps_1_res18 \
--run_name res18_1fps_lyr_1_bs_256_lr_1e4 \
--num_layers 1 --batch_size 256 --epochs 300 \
--gpu_id 1 --opt_lvl 1  --num_workers 4 --lr 1e-4

Specify --model_ckpt (filename.pth) to load model checkpoint from disk (resume training/inference)

Select the architecture by using --model ('bilstm', 'bert', 'roberta').

For pre-trained transformers see this link.

Note: ...

Inference

  • ....


UCF-101 Dataset `
Crawling Penalty

---

TODO: ....

  • With Pre-Trained (Train+Val)
  • End-to-End (Train+Val)
  • ..

actionbert's People

Contributors

axe-- avatar

Watchers

 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.