duan8/tsm/demo.sh
irvingzhang0512 8cfc8ee03f
Support TSM-R50 Python API (#488)
* add tensorrt temporal shift module and related pytorch implementations

* add .gitignore and getn weights script.

* rename get_wts.py script

* Add tsm-r50 demo.

* update readme

* remove useless codes

* update readme

* update readme

* remote video and .gitignore, update tutorial

* update readme and tutorial

* fix a few bugs and test on tensorrt 5.1

* update readme
2021-04-18 16:30:25 +08:00

44 lines
2.0 KiB
Bash

# Step 1: Get checkpoints from mmaction2
# https://github.com/open-mmlab/mmaction2/tree/master/configs/recognition/tsm
wget https://download.openmmlab.com/mmaction/recognition/tsm/tsm_r50_1x1x8_50e_kinetics400_rgb/tsm_r50_1x1x8_50e_kinetics400_rgb_20200607-af7fb746.pth
# Step 2: Convert pytorch checkpoints to TensorRT weights
python gen_wts.py tsm_r50_1x1x8_50e_kinetics400_rgb_20200607-af7fb746.pth --out-filename ./tsm_r50_kinetics400_mmaction2.wts
# Step 3: Skip this step since we use default settings.
# Step 4: Inference
# 1) Save local engine file to `./tsm_r50_kinetics400_mmaction2.trt`.
python tsm_r50.py \
--tensorrt-weights ./tsm_r50_kinetics400_mmaction2.wts \
--save-engine-path ./tsm_r50_kinetics400_mmaction2.trt
# 2) Predict the recognition result using a single video `demo.mp4`.
# Should print `Result class id 6`, aka `arm wrestling`
# Download demo video
wget https://raw.githubusercontent.com/open-mmlab/mmaction2/master/demo/demo.mp4
# # use *.wts as input
# python tsm_r50.py --tensorrt-weights ./tsm_r50_kinetics400_mmaction2.wts \
# --input-video ./demo.mp4
# use engine file as input
python tsm_r50.py --load-engine-path ./tsm_r50_kinetics400_mmaction2.trt \
--input-video ./demo.mp4
# 3) Optional: Compare inference result with MMAction2 TSM-R50 model
# Have to install MMAction2 First, please refer to https://github.com/open-mmlab/mmaction2/blob/master/docs/install.md
# pip3 install pytest-runner
# pip3 install mmcv
# pip3 install mmaction2
# # use *.wts as input
# python tsm_r50.py \
# --tensorrt-weights ./tsm_r50_kinetics400_mmaction2.wts \
# --test-mmaction2 \
# --mmaction2-config mmaction2_tsm_r50_config.py \
# --mmaction2-checkpoint tsm_r50_1x1x8_50e_kinetics400_rgb_20200607-af7fb746.pth
# # use TensorRT engine as input
# python tsm_r50.py \
# --load-engine-path ./tsm_r50_kinetics400_mmaction2.trt \
# --test-mmaction2 \
# --mmaction2-config mmaction2_tsm_r50_config.py \
# --mmaction2-checkpoint tsm_r50_1x1x8_50e_kinetics400_rgb_20200607-af7fb746.pth