48 Star 501 Fork 1.3K

Ascend/ModelZoo-PyTorch

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

TSN(mmaction2)

This implements training of TSN on the UCF101 dataset, mainly modified from open-mmlab/mmaction2.

TSN Detail

As of the current date, Ascend-Pytorch is still inefficient for contiguous operations. Therefore, TSN is re-implemented using semantics such as custom OP.

Requirements

  • Install PyTorch (pytorch.org)
  • pip install -r requirements.txt
  • Download the UCF101 dataset according to dataset/README.md

Build MMCV

Download mmcv form source

git clone -b v1.3.9 https://github.com/open-mmlab/mmcv.git
mv mmcv/ mmcv-master/
mv mmcv-master/mmcv ./
rm -rf mmcv-master/

Change file of mmcv

/bin/cp -f mmcv_need/base_runner.py mmcv/runner/base_runner.py
/bin/cp -f mmcv_need/builder.py mmcv/runner/optimizer/builder.py
/bin/cp -f mmcv_need/checkpoint.py mmcv/runner/hooks/checkpoint.py
/bin/cp -f mmcv_need/data_parallel.py mmcv/parallel/data_parallel.py
/bin/cp -f mmcv_need/dist_utils.py mmcv/runner/dist_utils.py
/bin/cp -f mmcv_need/distributed.py mmcv/parallel/distributed.py
/bin/cp -f mmcv_need/epoch_based_runner.py mmcv/runner/epoch_based_runner.py
/bin/cp -f mmcv_need/iter_timer.py mmcv/runner/hooks/iter_timer.py
/bin/cp -f mmcv_need/optimizer.py mmcv/runner/hooks/optimizer.py
/bin/cp -f mmcv_need/test.py mmcv/engine/test.py
/bin/cp -f mmcv_need/transformer.py mmcv/cnn/bricks/transformer.py

Training

To train a model, run train.py with the desired model architecture.

# 1p train perf
bash test/train_performance_1p.sh --data_path=/opt/npu

# 8p train perf
bash test/train_performance_8p.sh --data_path=/opt/npu

# 8p train full
bash test/train_full_8p.sh --data_path=/opt/npu

# 8p eval 
bash test/train_eval_8p.sh --data_path=/opt/npu

# finetuning
bash test/train_finetune_1p.sh --data_path=/opt/npu

# online inference demo
source test/env_npu.sh
python3 demo.py

Note:

  • If you save dataset in another path but not /opt/npu, please specify argument --data_path. For example, if your dataset path is /home/dataset/ucf101, then --data_path=/home/dataset.
  • You can modify train_finetune_1p.sh to use another pretrain model.
  • You can use argument --test_num to choose which video to be tested when using demo.py.

Log Path:

  • tsn_performance_1p.log # 1p Training performance result log
  • tsn_performance_8p.log # 8p Training performance result log
  • tsn_full_1p.log # 1p Training performance and accuracy result log
  • tsn_full_8p.log # 8p Training performance and accuracy result log
  • tsn_eval_8p.log # 8p validating accuracy result log
  • tsn_finetune_1p.log # 1p fine-tuning result log

TSM training result

Top1 acc FPS Epochs AMP_Type Device
- 111.82 1 O2 1p Npu
83.27 638.85 75 O2 8p Npu
- 59.88 1 O2 1p Gpu
82.29 958.66 75 O2 8p Gpu

Statement

For details about the public address of the code in this repository, you can get from the file public_address_statement.md

马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/ascend/ModelZoo-PyTorch.git
git@gitee.com:ascend/ModelZoo-PyTorch.git
ascend
ModelZoo-PyTorch
ModelZoo-PyTorch
master

搜索帮助