Skip to content
This repository was archived by the owner on Jan 24, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions bmn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ BMN Overview
git clone https://github.com/PaddlePaddle/hapi
cd hapi
export PYTHONPATH=`pwd`:$PYTHONPATH
cd examples/bmn
cd bmn
```


Expand Down Expand Up @@ -69,9 +69,9 @@ BMN的训练数据采用ActivityNet1.3提供的数据集,我们提供了处理

python train.py

默认使用静态图训练,若使用动态图训练只需要在运行脚本添加`-d`参数即可,如:
默认使用动态图训练,若使用静态图训练只需要在运行脚本添加`-s`参数即可,如:

python train.py -d
python train.py -s

- 代码运行需要先安装pandas

Expand All @@ -84,7 +84,7 @@ BMN的训练数据采用ActivityNet1.3提供的数据集,我们提供了处理

python eval.py --weights=$PATH_TO_WEIGHTS

- 进行评估时,可修改命令行中的`weights`参数指定需要评估的权重,若未指定,脚本会下载已发布的模型[model](https://paddlemodels.bj.bcebos.com/hapi/bmn.pdparams)进行评估。
- 进行评估时,可修改命令行中的`weights`参数指定需要评估的权重,如--weights='./checkpoint/final.pdparams'。若未指定,脚本会下载已发布的模型[model](https://paddlemodels.bj.bcebos.com/hapi/bmn.pdparams)进行评估。

- 上述程序会将运行结果保存在`--output_path`参数指定的文件夹下,默认为output/EVAL/BMN\_results;测试结果保存在`--result_path`参数指定的文件夹下,默认为evaluate\_results。

Expand All @@ -110,7 +110,7 @@ BMN的训练数据采用ActivityNet1.3提供的数据集,我们提供了处理

| AR@1 | AR@5 | AR@10 | AR@100 | AUC |
| :---: | :---: | :---: | :---: | :---: |
| 33.10 | 49.18 | 56.54 | 75.12 | 67.16% |
| 33.23 | 49.16 | 56.59 | 75.27 | 67.18% |


## 模型推断
Expand All @@ -120,7 +120,7 @@ BMN的训练数据采用ActivityNet1.3提供的数据集,我们提供了处理
python predict.py --weights=$PATH_TO_WEIGHTS \
--filelist=$FILELIST

- 使用python命令行启动程序时,`--filelist`参数指定待推断的文件列表,如果不设置,默认为./infer.list。`--weights`参数为训练好的权重参数,若未指定,脚本会下载已发布的模型[model](https://paddlemodels.bj.bcebos.com/hapi/bmn.pdparams)进行预测。
- 使用python命令行启动程序时,`--filelist`参数指定待推断的文件列表,如果不设置,默认为./infer.list。`--weights`参数指定训练好的权重参数,如--weights='./checkpoint/final.pdparams'。若未指定,脚本会下载已发布的模型[model](https://paddlemodels.bj.bcebos.com/hapi/bmn.pdparams)进行预测。

- 上述程序会将运行结果保存在`--output_path`参数指定的文件夹下,默认为output/INFER/BMN\_results;测试结果保存在`--result_path`参数指定的文件夹下,默认为predict\_results。

Expand Down
2 changes: 1 addition & 1 deletion bmn/bmn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ MODEL:
num_sample: 32
num_sample_perbin: 3
anno_file: "./activitynet_1.3_annotations.json"
feat_path: './fix_feat_100'
feat_path: "./fix_feat_100"

TRAIN:
subset: "train"
Expand Down
10 changes: 3 additions & 7 deletions bmn/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import os
import sys
import logging
import paddle.fluid as fluid

from modeling import bmn, BmnLoss
from bmn_metric import BmnMetric
Expand All @@ -35,10 +34,7 @@
def parse_args():
parser = argparse.ArgumentParser("BMN test for performance evaluation.")
parser.add_argument(
"-d",
"--dynamic",
action='store_true',
help="enable dygraph mode, only support dynamic mode at present time")
"-s", "--static", action='store_true', help="enable static mode")
parser.add_argument(
'--config_file',
type=str,
Expand Down Expand Up @@ -77,8 +73,8 @@ def parse_args():

# Performance Evaluation
def test_bmn(args):
paddle.enable_static() if args.static else None
device = paddle.set_device(args.device)
paddle.disable_static(device) if args.dynamic else None

#config setting
config = parse_config(args.config_file)
Expand Down Expand Up @@ -110,7 +106,7 @@ def test_bmn(args):

#load checkpoint
if args.weights is not None:
assert os.path.exists(args.weights + '.pdparams'), \
assert os.path.exists(args.weights), \
"Given weight dir {} not exist.".format(args.weights)
logger.info('load test weights from {}'.format(args.weights))
model.load(args.weights)
Expand Down
Loading