diff --git a/tsm/README.md b/tsm/README.md index bb5d148376bc0c1dd8c610d89e378b6b1fbcf1d1..5d4e2b708743f5aa4b451c646c67a70d6f6c408c 100644 --- a/tsm/README.md +++ b/tsm/README.md @@ -35,7 +35,8 @@ TSM模型是将Temporal Shift Module插入到ResNet网络中构建的视频分 #### 代码下载及环境变量设置 克隆代码库到本地,并设置`PYTHONPATH`环境变量 - ```shell + + ```bash git clone https://github.com/PaddlePaddle/hapi cd hapi export PYTHONPATH=$PYTHONPATH:`pwd` @@ -56,7 +57,7 @@ TSM的训练数据采用由DeepMind公布的Kinetics-400动作识别数据集。 `main.py`脚本参数可通过如下命令查询 -```shell +```bash python main.py --help ``` @@ -64,14 +65,14 @@ python main.py --help 使用如下方式进行单卡训练: -```shell +```bash export CUDA_VISIBLE_DEVICES=0 python main.py --data= --batch_size=16 ``` 使用如下方式进行多卡训练: -```shell +```bash CUDA_VISIBLE_DEVICES=0,1 python main.py --data= --batch_size=8 ``` @@ -81,14 +82,14 @@ CUDA_VISIBLE_DEVICES=0,1 python main.py --data= --batch_size=8 使用如下方式进行单卡训练: -```shell +```bash export CUDA_VISIBLE_DEVICES=0 python main.py --data= --batch_size=16 -d ``` 使用如下方式进行多卡训练: -```shell +```bash CUDA_VISIBLE_DEVICES=0,1 python main.py --data= --batch_size=8 -d ``` @@ -100,14 +101,14 @@ CUDA_VISIBLE_DEVICES=0,1 python main.py --data= --batch_size=8 1. 自动下载Paddle发布的[TSM-ResNet50](https://paddlemodels.bj.bcebos.com/hapi/tsm_resnet50.pdparams)权重评估 -``` -python main.py --data --eval_only +```bash +python main.py --data= --eval_only ``` 2. 加载checkpoint进行精度评估 -``` -python main.py --data --eval_only --weights=tsm_checkpoint/final +```bash +python main.py --data= --eval_only --weights=tsm_checkpoint/final ``` #### 评估精度 @@ -116,7 +117,7 @@ python main.py --data --eval_only --weights=tsm_checkpoint/fina |Top-1|Top-5| |:-:|:-:| -|76.5%|98.0%| +|76%|98%| ## 参考论文 diff --git a/tsm/main.py b/tsm/main.py index 2266bb46e83d176bc1505d3903c6525f7e3947bb..b1d023f326a2e3cca09bad6366a7bb9b4a718440 100644 --- a/tsm/main.py +++ b/tsm/main.py @@ -92,7 +92,7 @@ def main(): if FLAGS.eval_only: if FLAGS.weights is not None: - model.load(FLAGS.weights) + model.load(FLAGS.weights, reset_optimizer=True) model.evaluate( val_dataset, diff --git a/tsm/modeling.py b/tsm/modeling.py index bac51016851edfe44a00ae88335b546cdaaf80f9..b2002f2ccc258fe2f16f563cc25e12718ad97aed 100644 --- a/tsm/modeling.py +++ b/tsm/modeling.py @@ -191,8 +191,8 @@ def _tsm_resnet(num_layers, seg_num=8, num_classes=400, pretrained=True): model = TSM_ResNet(num_layers, seg_num, num_classes) if pretrained: assert num_layers in pretrain_infos.keys(), \ - "TSM_ResNet{} do not have pretrained weights now, " \ - "pretrained should be set as False" + "TSM-ResNet{} do not have pretrained weights now, " \ + "pretrained should be set as False".format(num_layers) weight_path = get_weights_path(*(pretrain_infos[num_layers])) assert weight_path.endswith('.pdparams'), \ "suffix of weight must be .pdparams"