未验证 提交 2f52d598 编写于 作者: H huangjun12 提交者: GitHub

fix video bug in reader/metric/benchmark (#4918)

* fix video bug and slowfast benchmark bug

* refine bmn doc
上级 5e574d41
......@@ -37,7 +37,7 @@ def calculate_hit_at_one(predictions, actuals):
float: The average hit at one across the entire batch.
"""
top_prediction = numpy.argmax(predictions, 1)
hits = actuals[:, top_prediction]
hits = actuals[numpy.arange(actuals.shape[0]), top_prediction]
return numpy.average(hits)
......
......@@ -27,7 +27,15 @@ __all__ = ["BMN"]
class BMN(ModelBase):
"""BMN model"""
"""BMN model from
`"BMN: Boundary-Matching Network for Temporal Action Proposal Generation" <https://arxiv.org/abs/1907.09702>`_
Args:
tscale (int): sequence length, default 100.
dscale (int): max duration length, default 100.
prop_boundary_ratio (float): ratio of expanded temporal region in proposal boundary, default 0.5.
num_sample (int): number of samples betweent starting boundary and ending boundary of each propoasl, default 32.
num_sample_perbin (int): number of selected points in each sample, default 3.
"""
def __init__(self, name, cfg, mode='train'):
super(BMN, self).__init__(name, cfg, mode=mode)
......
......@@ -425,9 +425,9 @@ class CTCNReader(DataReader):
tmp_list = fl[i * file_num:]
reader_lists[i] = tmp_list
queue = multiprocessing.Queue(queue_size)
manager = multiprocessing.Manager()
queue = manager.Queue(queue_size)
p_list = [None] * len(reader_lists)
# for reader_list in reader_lists:
for i in range(len(reader_lists)):
reader_list = reader_lists[i]
p_list[i] = multiprocessing.Process(
......
......@@ -68,31 +68,8 @@ SlowFast Overview
## 数据准备
SlowFast模型的训练数据采用Kinetics400数据集,直接输入mp4文件进行训练,数据准备方式如下:
SlowFast模型的训练数据采用Kinetics400数据集,数据下载及准备请参考[数据说明](../PaddleCV/video/data/dataset/README.md)
### mp4视频下载
在Code\_Root目录下创建文件夹
```
cd $Code_Root/ && mkdir data
cd data && mkdir data_k400 && cd data_k400
mkdir train_mp4 && mkdir val_mp4
```
ActivityNet官方提供了Kinetics的下载工具,具体参考其[官方repo](https://github.com/activitynet/ActivityNet/tree/master/Crawler/Kinetics)即可下载Kinetics400的mp4视频集合。将kinetics400的训练与验证集合分别下载到data/data\_k400/train\_mp4与data/data\_k400/val\_mp4。
### 生成训练和验证集list
验证(Validation)和评估(Evaluation)使用同一份数据集,预测(Predict)可以从验证数据集中挑选少量样本进行预测
```
cd $Code_Root/data/
ls $Code_Root/data/data_k400/train_mp4/* > train.csv
ls $Code_Root/data/data_k400/val_mp4/* > val.csv
ls $Code_Root/data/data_k400/val_mp4/* > test.csv
ls $Code_Root/data/data_k400/val_mp4/* > infer.csv
```
## 模型训练
......
......@@ -268,7 +268,7 @@ def train(args):
random.seed(0)
np.random.seed(0)
paddle.framework.manual_seed(0)
paddle.framework.seed(0)
with fluid.dygraph.guard(place):
# 1. init net
if args.use_data_parallel:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册