@@ -5,16 +5,16 @@ wget https://download.openmmlab.com/mmaction/recognition/tsm/tsm_r50_1x1x8_50e_k
55# Step 2: Convert pytorch checkpoints to TensorRT weights
66python gen_wts.py tsm_r50_1x1x8_50e_kinetics400_rgb_20200607-af7fb746.pth --out-filename ./tsm_r50_kinetics400_mmaction2.wts
77
8- # Step 3: Skip this step since we use default settings .
9-
10- # Step 4: Inference
11- # 1) Save local engine file to `./tsm_r50_kinetics400_mmaction2.trt`.
8+ # Step 3: Test Python API .
9+ # 3.1 Skip this step since we use default settings.
10+ # 3.2 Inference
11+ # 3.2.1 Save local engine file to `./tsm_r50_kinetics400_mmaction2.trt`.
1212python tsm_r50.py \
1313 --tensorrt-weights ./tsm_r50_kinetics400_mmaction2.wts \
1414 --save-engine-path ./tsm_r50_kinetics400_mmaction2.trt
1515
16- # 2) Predict the recognition result using a single video `demo.mp4`.
17- # Should print `Result class id 6`, aka `arm wrestling`
16+ # 3.2.2 Predict the recognition result using a single video `demo.mp4`.
17+ # Should print `Result class id 6`, aka `arm wrestling`
1818# Download demo video
1919wget https://raw.githubusercontent.com/open-mmlab/mmaction2/master/demo/demo.mp4
2020# # use *.wts as input
@@ -24,8 +24,8 @@ wget https://raw.githubusercontent.com/open-mmlab/mmaction2/master/demo/demo.mp4
2424python tsm_r50.py --load-engine-path ./tsm_r50_kinetics400_mmaction2.trt \
2525 --input-video ./demo.mp4
2626
27- # 3) Optional: Compare inference result with MMAction2 TSM-R50 model
28- # Have to install MMAction2 First, please refer to https://github.com/open-mmlab/mmaction2/blob/master/docs/install.md
27+ # 3.2.3 Optional: Compare inference result with MMAction2 TSM-R50 model
28+ # Have to install MMAction2 First, please refer to https://github.com/open-mmlab/mmaction2/blob/master/docs/install.md
2929# pip3 install pytest-runner
3030# pip3 install mmcv
3131# pip3 install mmaction2
@@ -41,3 +41,15 @@ python tsm_r50.py --load-engine-path ./tsm_r50_kinetics400_mmaction2.trt \
4141# --test-mmaction2 \
4242# --mmaction2-config mmaction2_tsm_r50_config.py \
4343# --mmaction2-checkpoint tsm_r50_1x1x8_50e_kinetics400_rgb_20200607-af7fb746.pth
44+
45+ # Step 4: Test Python API.
46+ # 4.1 Skip this step since we use default settings.
47+ # 4.2 Build CPP
48+ mkdir build && cd build && cmake .. && make
49+ # 4.3 Generate Engine file
50+ ./tsm_r50 -s
51+ # 4.4 Get Predictions
52+ ./tsm_r50 -d
53+ # 4.5 Compare C++ Results with Python Results
54+ cd ..
55+ python tsm_r50.py --test-cpp --tensorrt-weights ./tsm_r50_kinetics400_mmaction2.wts
0 commit comments