Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
1137c0c0
M
models
项目概览
PaddlePaddle
/
models
1 年多 前同步成功
通知
226
Star
6828
Fork
2962
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
602
列表
看板
标记
里程碑
合并请求
255
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
models
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
602
Issue
602
列表
看板
标记
里程碑
合并请求
255
合并请求
255
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
1137c0c0
编写于
10月 14, 2019
作者:
S
SunGaofeng
提交者:
GitHub
10月 14, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert "fix fluid.data and fluid.io.DataLoader (#3533)" (#3560)
This reverts commit
0be3697c
.
上级
8be4d011
变更
18
显示空白变更内容
内联
并排
Showing
18 changed file
with
171 addition
and
188 deletion
+171
-188
PaddleCV/PaddleVideo/README.md
PaddleCV/PaddleVideo/README.md
+1
-1
PaddleCV/PaddleVideo/eval.py
PaddleCV/PaddleVideo/eval.py
+1
-3
PaddleCV/PaddleVideo/inference_model.py
PaddleCV/PaddleVideo/inference_model.py
+1
-1
PaddleCV/PaddleVideo/models/attention_cluster/attention_cluster.py
...PaddleVideo/models/attention_cluster/attention_cluster.py
+8
-8
PaddleCV/PaddleVideo/models/attention_lstm/attention_lstm.py
PaddleCV/PaddleVideo/models/attention_lstm/attention_lstm.py
+8
-8
PaddleCV/PaddleVideo/models/bmn/bmn.py
PaddleCV/PaddleVideo/models/bmn/bmn.py
+20
-19
PaddleCV/PaddleVideo/models/bsn/bsn.py
PaddleCV/PaddleVideo/models/bsn/bsn.py
+37
-35
PaddleCV/PaddleVideo/models/ctcn/ctcn.py
PaddleCV/PaddleVideo/models/ctcn/ctcn.py
+17
-16
PaddleCV/PaddleVideo/models/model.py
PaddleCV/PaddleVideo/models/model.py
+4
-4
PaddleCV/PaddleVideo/models/nextvlad/nextvlad.py
PaddleCV/PaddleVideo/models/nextvlad/nextvlad.py
+11
-11
PaddleCV/PaddleVideo/models/nonlocal_model/nonlocal_model.py
PaddleCV/PaddleVideo/models/nonlocal_model/nonlocal_model.py
+9
-9
PaddleCV/PaddleVideo/models/stnet/stnet.py
PaddleCV/PaddleVideo/models/stnet/stnet.py
+10
-10
PaddleCV/PaddleVideo/models/tsm/tsm.py
PaddleCV/PaddleVideo/models/tsm/tsm.py
+10
-9
PaddleCV/PaddleVideo/models/tsn/tsn.py
PaddleCV/PaddleVideo/models/tsn/tsn.py
+10
-9
PaddleCV/PaddleVideo/predict.py
PaddleCV/PaddleVideo/predict.py
+1
-3
PaddleCV/PaddleVideo/train.py
PaddleCV/PaddleVideo/train.py
+12
-14
PaddleCV/PaddleVideo/utils/train_utils.py
PaddleCV/PaddleVideo/utils/train_utils.py
+11
-11
PaddleCV/PaddleVideo/utils/utility.py
PaddleCV/PaddleVideo/utils/utility.py
+0
-17
未找到文件。
PaddleCV/PaddleVideo/README.md
浏览文件 @
1137c0c0
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
## 安装
## 安装
在当前模型库运行样例代码需要PaddlePaddle Fluid v.1.
6.0或以上的版本。如果你的运行环境中的PaddlePaddle低于此版本,请根据
[
安装文档
](
http://www.paddlepaddle.org/documentation/docs/zh/1.6
/beginners_guide/install/index_cn.html
)
中的说明来更新PaddlePaddle。
在当前模型库运行样例代码需要PaddlePaddle Fluid v.1.
5.0或以上的版本。如果你的运行环境中的PaddlePaddle低于此版本,请根据
[
安装文档
](
http://www.paddlepaddle.org/documentation/docs/zh/1.5
/beginners_guide/install/index_cn.html
)
中的说明来更新PaddlePaddle。
### 其他环境依赖
### 其他环境依赖
...
...
PaddleCV/PaddleVideo/eval.py
浏览文件 @
1137c0c0
...
@@ -26,7 +26,6 @@ import models
...
@@ -26,7 +26,6 @@ import models
from
reader
import
get_reader
from
reader
import
get_reader
from
metrics
import
get_metrics
from
metrics
import
get_metrics
from
utils.utility
import
check_cuda
from
utils.utility
import
check_cuda
from
utils.utility
import
check_version
logging
.
root
.
handlers
=
[]
logging
.
root
.
handlers
=
[]
FORMAT
=
'[%(levelname)s: %(filename)s: %(lineno)4d]: %(message)s'
FORMAT
=
'[%(levelname)s: %(filename)s: %(lineno)4d]: %(message)s'
...
@@ -84,7 +83,7 @@ def test(args):
...
@@ -84,7 +83,7 @@ def test(args):
# build model
# build model
test_model
=
models
.
get_model
(
args
.
model_name
,
test_config
,
mode
=
'test'
)
test_model
=
models
.
get_model
(
args
.
model_name
,
test_config
,
mode
=
'test'
)
test_model
.
build_input
(
use_
datalo
ader
=
False
)
test_model
.
build_input
(
use_
pyre
ader
=
False
)
test_model
.
build_model
()
test_model
.
build_model
()
test_feeds
=
test_model
.
feeds
()
test_feeds
=
test_model
.
feeds
()
test_fetch_list
=
test_model
.
fetches
()
test_fetch_list
=
test_model
.
fetches
()
...
@@ -131,7 +130,6 @@ if __name__ == "__main__":
...
@@ -131,7 +130,6 @@ if __name__ == "__main__":
args
=
parse_args
()
args
=
parse_args
()
# check whether the installed paddle is compiled with GPU
# check whether the installed paddle is compiled with GPU
check_cuda
(
args
.
use_gpu
)
check_cuda
(
args
.
use_gpu
)
check_version
()
logger
.
info
(
args
)
logger
.
info
(
args
)
test
(
args
)
test
(
args
)
PaddleCV/PaddleVideo/inference_model.py
浏览文件 @
1137c0c0
...
@@ -80,7 +80,7 @@ def save_inference_model(args):
...
@@ -80,7 +80,7 @@ def save_inference_model(args):
infer_config
=
merge_configs
(
config
,
'infer'
,
vars
(
args
))
infer_config
=
merge_configs
(
config
,
'infer'
,
vars
(
args
))
print_configs
(
infer_config
,
"Infer"
)
print_configs
(
infer_config
,
"Infer"
)
infer_model
=
models
.
get_model
(
args
.
model_name
,
infer_config
,
mode
=
'infer'
)
infer_model
=
models
.
get_model
(
args
.
model_name
,
infer_config
,
mode
=
'infer'
)
infer_model
.
build_input
(
use_
datalo
ader
=
False
)
infer_model
.
build_input
(
use_
pyre
ader
=
False
)
infer_model
.
build_model
()
infer_model
.
build_model
()
infer_feeds
=
infer_model
.
feeds
()
infer_feeds
=
infer_model
.
feeds
()
infer_outputs
=
infer_model
.
outputs
()
infer_outputs
=
infer_model
.
outputs
()
...
...
PaddleCV/PaddleVideo/models/attention_cluster/attention_cluster.py
浏览文件 @
1137c0c0
...
@@ -41,21 +41,21 @@ class AttentionCluster(ModelBase):
...
@@ -41,21 +41,21 @@ class AttentionCluster(ModelBase):
self
.
learning_rate
=
self
.
get_config_from_sec
(
'train'
,
self
.
learning_rate
=
self
.
get_config_from_sec
(
'train'
,
'learning_rate'
,
1e-3
)
'learning_rate'
,
1e-3
)
def
build_input
(
self
,
use_
datalo
ader
=
True
):
def
build_input
(
self
,
use_
pyre
ader
=
True
):
self
.
feature_input
=
[]
self
.
feature_input
=
[]
for
name
,
dim
in
zip
(
self
.
feature_names
,
self
.
feature_dims
):
for
name
,
dim
in
zip
(
self
.
feature_names
,
self
.
feature_dims
):
self
.
feature_input
.
append
(
self
.
feature_input
.
append
(
fluid
.
data
(
fluid
.
layers
.
data
(
shape
=
[
None
,
self
.
seg_num
,
dim
],
dtype
=
'float32'
,
name
=
name
))
shape
=
[
self
.
seg_num
,
dim
],
dtype
=
'float32'
,
name
=
name
))
if
self
.
mode
!=
'infer'
:
if
self
.
mode
!=
'infer'
:
self
.
label_input
=
fluid
.
data
(
self
.
label_input
=
fluid
.
layers
.
data
(
shape
=
[
None
,
self
.
class_num
],
dtype
=
'float32'
,
name
=
'label'
)
shape
=
[
self
.
class_num
],
dtype
=
'float32'
,
name
=
'label'
)
else
:
else
:
self
.
label_input
=
None
self
.
label_input
=
None
if
use_
datalo
ader
:
if
use_
pyre
ader
:
assert
self
.
mode
!=
'infer'
,
\
assert
self
.
mode
!=
'infer'
,
\
'
dataloader is not recommendated when infer, please set use_datalo
ader to be false.'
'
pyreader is not recommendated when infer, please set use_pyre
ader to be false.'
self
.
dataloader
=
fluid
.
io
.
DataLoader
.
from_generato
r
(
self
.
py_reader
=
fluid
.
io
.
PyReade
r
(
feed_list
=
self
.
feature_input
+
[
self
.
label_input
],
feed_list
=
self
.
feature_input
+
[
self
.
label_input
],
capacity
=
8
,
capacity
=
8
,
iterable
=
True
)
iterable
=
True
)
...
...
PaddleCV/PaddleVideo/models/attention_lstm/attention_lstm.py
浏览文件 @
1137c0c0
...
@@ -52,21 +52,21 @@ class AttentionLSTM(ModelBase):
...
@@ -52,21 +52,21 @@ class AttentionLSTM(ModelBase):
self
.
decay_gamma
=
self
.
get_config_from_sec
(
'train'
,
'decay_gamma'
,
self
.
decay_gamma
=
self
.
get_config_from_sec
(
'train'
,
'decay_gamma'
,
0.1
)
0.1
)
def
build_input
(
self
,
use_
datalo
ader
):
def
build_input
(
self
,
use_
pyre
ader
):
self
.
feature_input
=
[]
self
.
feature_input
=
[]
for
name
,
dim
in
zip
(
self
.
feature_names
,
self
.
feature_dims
):
for
name
,
dim
in
zip
(
self
.
feature_names
,
self
.
feature_dims
):
self
.
feature_input
.
append
(
self
.
feature_input
.
append
(
fluid
.
data
(
fluid
.
layers
.
data
(
shape
=
[
None
,
dim
],
lod_level
=
1
,
dtype
=
'float32'
,
name
=
name
))
shape
=
[
dim
],
lod_level
=
1
,
dtype
=
'float32'
,
name
=
name
))
if
self
.
mode
!=
'infer'
:
if
self
.
mode
!=
'infer'
:
self
.
label_input
=
fluid
.
data
(
self
.
label_input
=
fluid
.
layers
.
data
(
shape
=
[
None
,
self
.
num_classes
],
dtype
=
'float32'
,
name
=
'label'
)
shape
=
[
self
.
num_classes
],
dtype
=
'float32'
,
name
=
'label'
)
else
:
else
:
self
.
label_input
=
None
self
.
label_input
=
None
if
use_
datalo
ader
:
if
use_
pyre
ader
:
assert
self
.
mode
!=
'infer'
,
\
assert
self
.
mode
!=
'infer'
,
\
'
dataloader is not recommendated when infer, please set use_datalo
ader to be false.'
'
pyreader is not recommendated when infer, please set use_pyre
ader to be false.'
self
.
dataloader
=
fluid
.
io
.
DataLoader
.
from_generato
r
(
self
.
py_reader
=
fluid
.
io
.
PyReade
r
(
feed_list
=
self
.
feature_input
+
[
self
.
label_input
],
feed_list
=
self
.
feature_input
+
[
self
.
label_input
],
capacity
=
8
,
capacity
=
8
,
iterable
=
True
)
iterable
=
True
)
...
...
PaddleCV/PaddleVideo/models/bmn/bmn.py
浏览文件 @
1137c0c0
...
@@ -52,46 +52,47 @@ class BMN(ModelBase):
...
@@ -52,46 +52,47 @@ class BMN(ModelBase):
'l2_weight_decay'
)
'l2_weight_decay'
)
self
.
lr_decay_iter
=
self
.
get_config_from_sec
(
'train'
,
'lr_decay_iter'
)
self
.
lr_decay_iter
=
self
.
get_config_from_sec
(
'train'
,
'lr_decay_iter'
)
def
build_input
(
self
,
use_
datalo
ader
=
True
):
def
build_input
(
self
,
use_
pyre
ader
=
True
):
feat_shape
=
[
None
,
self
.
feat_dim
,
self
.
tscale
]
feat_shape
=
[
self
.
feat_dim
,
self
.
tscale
]
gt_iou_map_shape
=
[
None
,
self
.
dscale
,
self
.
tscale
]
gt_iou_map_shape
=
[
self
.
dscale
,
self
.
tscale
]
gt_start_shape
=
[
None
,
self
.
tscale
]
gt_start_shape
=
[
self
.
tscale
]
gt_end_shape
=
[
None
,
self
.
tscale
]
gt_end_shape
=
[
self
.
tscale
]
fileid_shape
=
[
None
,
1
]
fileid_shape
=
[
1
]
self
.
use_
dataloader
=
use_datalo
ader
self
.
use_
pyreader
=
use_pyre
ader
# set init data to None
# set init data to None
py_reader
=
None
feat
=
None
feat
=
None
gt_iou_map
=
None
gt_iou_map
=
None
gt_start
=
None
gt_start
=
None
gt_end
=
None
gt_end
=
None
fileid
=
None
fileid
=
None
feat
=
fluid
.
data
(
name
=
'feat'
,
shape
=
feat_shape
,
dtype
=
'float32'
)
feat
=
fluid
.
layers
.
data
(
name
=
'feat'
,
shape
=
feat_shape
,
dtype
=
'float32'
)
feed_list
=
[]
feed_list
=
[]
feed_list
.
append
(
feat
)
feed_list
.
append
(
feat
)
if
(
self
.
mode
==
'train'
)
or
(
self
.
mode
==
'valid'
):
if
(
self
.
mode
==
'train'
)
or
(
self
.
mode
==
'valid'
):
gt_start
=
fluid
.
data
(
gt_start
=
fluid
.
layers
.
data
(
name
=
'gt_start'
,
shape
=
gt_start_shape
,
dtype
=
'float32'
)
name
=
'gt_start'
,
shape
=
gt_start_shape
,
dtype
=
'float32'
)
gt_end
=
fluid
.
data
(
gt_end
=
fluid
.
layers
.
data
(
name
=
'gt_end'
,
shape
=
gt_end_shape
,
dtype
=
'float32'
)
name
=
'gt_end'
,
shape
=
gt_end_shape
,
dtype
=
'float32'
)
gt_iou_map
=
fluid
.
data
(
gt_iou_map
=
fluid
.
layers
.
data
(
name
=
'gt_iou_map'
,
shape
=
gt_iou_map_shape
,
dtype
=
'float32'
)
name
=
'gt_iou_map'
,
shape
=
gt_iou_map_shape
,
dtype
=
'float32'
)
feed_list
.
append
(
gt_iou_map
)
feed_list
.
append
(
gt_iou_map
)
feed_list
.
append
(
gt_start
)
feed_list
.
append
(
gt_start
)
feed_list
.
append
(
gt_end
)
feed_list
.
append
(
gt_end
)
elif
self
.
mode
==
'test'
:
elif
self
.
mode
==
'test'
:
gt_start
=
fluid
.
data
(
gt_start
=
fluid
.
layers
.
data
(
name
=
'gt_start'
,
shape
=
gt_start_shape
,
dtype
=
'float32'
)
name
=
'gt_start'
,
shape
=
gt_start_shape
,
dtype
=
'float32'
)
gt_end
=
fluid
.
data
(
gt_end
=
fluid
.
layers
.
data
(
name
=
'gt_end'
,
shape
=
gt_end_shape
,
dtype
=
'float32'
)
name
=
'gt_end'
,
shape
=
gt_end_shape
,
dtype
=
'float32'
)
gt_iou_map
=
fluid
.
data
(
gt_iou_map
=
fluid
.
layers
.
data
(
name
=
'gt_iou_map'
,
shape
=
gt_iou_map_shape
,
dtype
=
'float32'
)
name
=
'gt_iou_map'
,
shape
=
gt_iou_map_shape
,
dtype
=
'float32'
)
feed_list
.
append
(
gt_iou_map
)
feed_list
.
append
(
gt_iou_map
)
feed_list
.
append
(
gt_start
)
feed_list
.
append
(
gt_start
)
feed_list
.
append
(
gt_end
)
feed_list
.
append
(
gt_end
)
fileid
=
fluid
.
data
(
fileid
=
fluid
.
layers
.
data
(
name
=
'fileid'
,
shape
=
fileid_shape
,
dtype
=
'int64'
)
name
=
'fileid'
,
shape
=
fileid_shape
,
dtype
=
'int64'
)
feed_list
.
append
(
fileid
)
feed_list
.
append
(
fileid
)
elif
self
.
mode
==
'infer'
:
elif
self
.
mode
==
'infer'
:
...
@@ -101,10 +102,10 @@ class BMN(ModelBase):
...
@@ -101,10 +102,10 @@ class BMN(ModelBase):
raise
NotImplementedError
(
'mode {} not implemented'
.
format
(
raise
NotImplementedError
(
'mode {} not implemented'
.
format
(
self
.
mode
))
self
.
mode
))
if
use_
datalo
ader
:
if
use_
pyre
ader
:
assert
self
.
mode
!=
'infer'
,
\
assert
self
.
mode
!=
'infer'
,
\
'
dataloader is not recommendated when infer, please set use_datalo
ader to be false.'
'
pyreader is not recommendated when infer, please set use_pyre
ader to be false.'
self
.
dataloader
=
fluid
.
io
.
DataLoader
.
from_generato
r
(
self
.
py_reader
=
fluid
.
io
.
PyReade
r
(
feed_list
=
feed_list
,
capacity
=
8
,
iterable
=
True
)
feed_list
=
feed_list
,
capacity
=
8
,
iterable
=
True
)
self
.
feat_input
=
[
feat
]
self
.
feat_input
=
[
feat
]
...
...
PaddleCV/PaddleVideo/models/bsn/bsn.py
浏览文件 @
1137c0c0
...
@@ -47,46 +47,47 @@ class BsnTem(ModelBase):
...
@@ -47,46 +47,47 @@ class BsnTem(ModelBase):
'l2_weight_decay'
)
'l2_weight_decay'
)
self
.
lr_decay_iter
=
self
.
get_config_from_sec
(
'train'
,
'lr_decay_iter'
)
self
.
lr_decay_iter
=
self
.
get_config_from_sec
(
'train'
,
'lr_decay_iter'
)
def
build_input
(
self
,
use_
datalo
ader
=
True
):
def
build_input
(
self
,
use_
pyre
ader
=
True
):
feat_shape
=
[
None
,
self
.
feat_dim
,
self
.
tscale
]
feat_shape
=
[
self
.
feat_dim
,
self
.
tscale
]
gt_start_shape
=
[
None
,
self
.
tscale
]
gt_start_shape
=
[
self
.
tscale
]
gt_end_shape
=
[
None
,
self
.
tscale
]
gt_end_shape
=
[
self
.
tscale
]
gt_action_shape
=
[
None
,
self
.
tscale
]
gt_action_shape
=
[
self
.
tscale
]
fileid_shape
=
[
None
,
1
]
fileid_shape
=
[
1
]
self
.
use_
dataloader
=
use_datalo
ader
self
.
use_
pyreader
=
use_pyre
ader
# set init data to None
# set init data to None
py_reader
=
None
feat
=
None
feat
=
None
gt_start
=
None
gt_start
=
None
gt_end
=
None
gt_end
=
None
gt_action
=
None
gt_action
=
None
fileid
=
None
fileid
=
None
feat
=
fluid
.
data
(
name
=
'feat'
,
shape
=
feat_shape
,
dtype
=
'float32'
)
feat
=
fluid
.
layers
.
data
(
name
=
'feat'
,
shape
=
feat_shape
,
dtype
=
'float32'
)
feed_list
=
[]
feed_list
=
[]
feed_list
.
append
(
feat
)
feed_list
.
append
(
feat
)
if
(
self
.
mode
==
'train'
)
or
(
self
.
mode
==
'valid'
):
if
(
self
.
mode
==
'train'
)
or
(
self
.
mode
==
'valid'
):
gt_start
=
fluid
.
data
(
gt_start
=
fluid
.
layers
.
data
(
name
=
'gt_start'
,
shape
=
gt_start_shape
,
dtype
=
'float32'
)
name
=
'gt_start'
,
shape
=
gt_start_shape
,
dtype
=
'float32'
)
gt_end
=
fluid
.
data
(
gt_end
=
fluid
.
layers
.
data
(
name
=
'gt_end'
,
shape
=
gt_end_shape
,
dtype
=
'float32'
)
name
=
'gt_end'
,
shape
=
gt_end_shape
,
dtype
=
'float32'
)
gt_action
=
fluid
.
data
(
gt_action
=
fluid
.
layers
.
data
(
name
=
'gt_action'
,
shape
=
gt_action_shape
,
dtype
=
'float32'
)
name
=
'gt_action'
,
shape
=
gt_action_shape
,
dtype
=
'float32'
)
feed_list
.
append
(
gt_start
)
feed_list
.
append
(
gt_start
)
feed_list
.
append
(
gt_end
)
feed_list
.
append
(
gt_end
)
feed_list
.
append
(
gt_action
)
feed_list
.
append
(
gt_action
)
elif
self
.
mode
==
'test'
:
elif
self
.
mode
==
'test'
:
gt_start
=
fluid
.
data
(
gt_start
=
fluid
.
layers
.
data
(
name
=
'gt_start'
,
shape
=
gt_start_shape
,
dtype
=
'float32'
)
name
=
'gt_start'
,
shape
=
gt_start_shape
,
dtype
=
'float32'
)
gt_end
=
fluid
.
data
(
gt_end
=
fluid
.
layers
.
data
(
name
=
'gt_end'
,
shape
=
gt_end_shape
,
dtype
=
'float32'
)
name
=
'gt_end'
,
shape
=
gt_end_shape
,
dtype
=
'float32'
)
gt_action
=
fluid
.
data
(
gt_action
=
fluid
.
layers
.
data
(
name
=
'gt_action'
,
shape
=
gt_action_shape
,
dtype
=
'float32'
)
name
=
'gt_action'
,
shape
=
gt_action_shape
,
dtype
=
'float32'
)
feed_list
.
append
(
gt_start
)
feed_list
.
append
(
gt_start
)
feed_list
.
append
(
gt_end
)
feed_list
.
append
(
gt_end
)
feed_list
.
append
(
gt_action
)
feed_list
.
append
(
gt_action
)
fileid
=
fluid
.
data
(
fileid
=
fluid
.
layers
.
data
(
name
=
'fileid'
,
shape
=
fileid_shape
,
dtype
=
'int64'
)
name
=
'fileid'
,
shape
=
fileid_shape
,
dtype
=
'int64'
)
feed_list
.
append
(
fileid
)
feed_list
.
append
(
fileid
)
elif
self
.
mode
==
'infer'
:
elif
self
.
mode
==
'infer'
:
...
@@ -96,10 +97,10 @@ class BsnTem(ModelBase):
...
@@ -96,10 +97,10 @@ class BsnTem(ModelBase):
raise
NotImplementedError
(
'mode {} not implemented'
.
format
(
raise
NotImplementedError
(
'mode {} not implemented'
.
format
(
self
.
mode
))
self
.
mode
))
if
use_
datalo
ader
:
if
use_
pyre
ader
:
assert
self
.
mode
!=
'infer'
,
\
assert
self
.
mode
!=
'infer'
,
\
'
dataloader is not recommendated when infer, please set use_datalo
ader to be false.'
'
pyreader is not recommendated when infer, please set use_pyre
ader to be false.'
self
.
dataloader
=
fluid
.
io
.
DataLoader
.
from_generato
r
(
self
.
py_reader
=
fluid
.
io
.
PyReade
r
(
feed_list
=
feed_list
,
capacity
=
8
,
iterable
=
True
)
feed_list
=
feed_list
,
capacity
=
8
,
iterable
=
True
)
self
.
feat_input
=
[
feat
]
self
.
feat_input
=
[
feat
]
...
@@ -211,49 +212,50 @@ class BsnPem(ModelBase):
...
@@ -211,49 +212,50 @@ class BsnPem(ModelBase):
'l2_weight_decay'
)
'l2_weight_decay'
)
self
.
lr_decay_iter
=
self
.
get_config_from_sec
(
'train'
,
'lr_decay_iter'
)
self
.
lr_decay_iter
=
self
.
get_config_from_sec
(
'train'
,
'lr_decay_iter'
)
def
build_input
(
self
,
use_
datalo
ader
=
True
):
def
build_input
(
self
,
use_
pyre
ader
=
True
):
feat_shape
=
[
None
,
self
.
top_K
,
self
.
feat_dim
]
feat_shape
=
[
self
.
top_K
,
self
.
feat_dim
]
gt_iou_shape
=
[
None
.
self
.
top_K
,
1
]
gt_iou_shape
=
[
self
.
top_K
,
1
]
props_info_shape
=
[
None
,
self
.
top_K
,
4
]
props_info_shape
=
[
self
.
top_K
,
4
]
fileid_shape
=
[
None
,
1
]
fileid_shape
=
[
1
]
self
.
use_
dataloader
=
use_datalo
ader
self
.
use_
pyreader
=
use_pyre
ader
# set init data to None
# set init data to None
py_reader
=
None
feat
=
None
feat
=
None
gt_iou
=
None
gt_iou
=
None
props_info
=
None
props_info
=
None
fileid
=
None
fileid
=
None
feat
=
fluid
.
data
(
name
=
'feat'
,
shape
=
feat_shape
,
dtype
=
'float32'
)
feat
=
fluid
.
layers
.
data
(
name
=
'feat'
,
shape
=
feat_shape
,
dtype
=
'float32'
)
feed_list
=
[]
feed_list
=
[]
feed_list
.
append
(
feat
)
feed_list
.
append
(
feat
)
if
(
self
.
mode
==
'train'
)
or
(
self
.
mode
==
'valid'
):
if
(
self
.
mode
==
'train'
)
or
(
self
.
mode
==
'valid'
):
gt_iou
=
fluid
.
data
(
gt_iou
=
fluid
.
layers
.
data
(
name
=
'gt_iou'
,
shape
=
gt_iou_shape
,
dtype
=
'float32'
)
name
=
'gt_iou'
,
shape
=
gt_iou_shape
,
dtype
=
'float32'
)
feed_list
.
append
(
gt_iou
)
feed_list
.
append
(
gt_iou
)
elif
self
.
mode
==
'test'
:
elif
self
.
mode
==
'test'
:
gt_iou
=
fluid
.
data
(
gt_iou
=
fluid
.
layers
.
data
(
name
=
'gt_iou'
,
shape
=
gt_iou_shape
,
dtype
=
'float32'
)
name
=
'gt_iou'
,
shape
=
gt_iou_shape
,
dtype
=
'float32'
)
props_info
=
fluid
.
data
(
props_info
=
fluid
.
layers
.
data
(
name
=
'props_info'
,
shape
=
props_info_shape
,
dtype
=
'float32'
)
name
=
'props_info'
,
shape
=
props_info_shape
,
dtype
=
'float32'
)
feed_list
.
append
(
gt_iou
)
feed_list
.
append
(
gt_iou
)
feed_list
.
append
(
props_info
)
feed_list
.
append
(
props_info
)
fileid
=
fluid
.
data
(
fileid
=
fluid
.
layers
.
data
(
name
=
'fileid'
,
shape
=
fileid_shape
,
dtype
=
'int64'
)
name
=
'fileid'
,
shape
=
fileid_shape
,
dtype
=
'int64'
)
feed_list
.
append
(
fileid
)
feed_list
.
append
(
fileid
)
elif
self
.
mode
==
'infer'
:
elif
self
.
mode
==
'infer'
:
props_info
=
fluid
.
data
(
props_info
=
fluid
.
layers
.
data
(
name
=
'props_info'
,
shape
=
props_info_shape
,
dtype
=
'float32'
)
name
=
'props_info'
,
shape
=
props_info_shape
,
dtype
=
'float32'
)
feed_list
.
append
(
props_info
)
feed_list
.
append
(
props_info
)
else
:
else
:
raise
NotImplementedError
(
'mode {} not implemented'
.
format
(
raise
NotImplementedError
(
'mode {} not implemented'
.
format
(
self
.
mode
))
self
.
mode
))
if
use_
datalo
ader
:
if
use_
pyre
ader
:
assert
self
.
mode
!=
'infer'
,
\
assert
self
.
mode
!=
'infer'
,
\
'
dataloader is not recommendated when infer, please set use_datalo
ader to be false.'
'
pyreader is not recommendated when infer, please set use_pyre
ader to be false.'
self
.
dataloader
=
fluid
.
io
.
DataLoader
.
from_generato
r
(
self
.
py_reader
=
fluid
.
io
.
PyReade
r
(
feed_list
=
feed_list
,
capacity
=
4
,
iterable
=
True
)
feed_list
=
feed_list
,
capacity
=
4
,
iterable
=
True
)
self
.
feat_input
=
[
feat
]
self
.
feat_input
=
[
feat
]
...
...
PaddleCV/PaddleVideo/models/ctcn/ctcn.py
浏览文件 @
1137c0c0
...
@@ -51,36 +51,37 @@ class CTCN(ModelBase):
...
@@ -51,36 +51,37 @@ class CTCN(ModelBase):
self
.
momentum
=
self
.
get_config_from_sec
(
'train'
,
'momentum'
)
self
.
momentum
=
self
.
get_config_from_sec
(
'train'
,
'momentum'
)
self
.
lr_decay_iter
=
self
.
get_config_from_sec
(
'train'
,
'lr_decay_iter'
)
self
.
lr_decay_iter
=
self
.
get_config_from_sec
(
'train'
,
'lr_decay_iter'
)
def
build_input
(
self
,
use_
datalo
ader
=
True
):
def
build_input
(
self
,
use_
pyre
ader
=
True
):
image_shape
=
[
None
,
1
,
self
.
img_size
,
self
.
concept_size
]
image_shape
=
[
1
,
self
.
img_size
,
self
.
concept_size
]
loc_shape
=
[
None
,
self
.
total_num_anchors
,
2
]
loc_shape
=
[
self
.
total_num_anchors
,
2
]
cls_shape
=
[
None
,
self
.
total_num_anchors
]
cls_shape
=
[
self
.
total_num_anchors
]
fileid_shape
=
[
None
,
1
]
fileid_shape
=
[
1
]
self
.
use_
dataloader
=
use_datalo
ader
self
.
use_
pyreader
=
use_pyre
ader
# set init data to None
# set init data to None
py_reader
=
None
image
=
None
image
=
None
loc_targets
=
None
loc_targets
=
None
cls_targets
=
None
cls_targets
=
None
fileid
=
None
fileid
=
None
image
=
fluid
.
data
(
image
=
fluid
.
layers
.
data
(
name
=
'image'
,
shape
=
image_shape
,
dtype
=
'float32'
)
name
=
'image'
,
shape
=
image_shape
,
dtype
=
'float32'
)
feed_list
=
[]
feed_list
=
[]
feed_list
.
append
(
image
)
feed_list
.
append
(
image
)
if
(
self
.
mode
==
'train'
)
or
(
self
.
mode
==
'valid'
):
if
(
self
.
mode
==
'train'
)
or
(
self
.
mode
==
'valid'
):
loc_targets
=
fluid
.
data
(
loc_targets
=
fluid
.
layers
.
data
(
name
=
'loc_targets'
,
shape
=
loc_shape
,
dtype
=
'float32'
)
name
=
'loc_targets'
,
shape
=
loc_shape
,
dtype
=
'float32'
)
cls_targets
=
fluid
.
data
(
cls_targets
=
fluid
.
layers
.
data
(
name
=
'cls_targets'
,
shape
=
cls_shape
,
dtype
=
'int64'
)
name
=
'cls_targets'
,
shape
=
cls_shape
,
dtype
=
'int64'
)
feed_list
.
append
(
loc_targets
)
feed_list
.
append
(
loc_targets
)
feed_list
.
append
(
cls_targets
)
feed_list
.
append
(
cls_targets
)
elif
self
.
mode
==
'test'
:
elif
self
.
mode
==
'test'
:
loc_targets
=
fluid
.
data
(
loc_targets
=
fluid
.
layers
.
data
(
name
=
'loc_targets'
,
shape
=
loc_shape
,
dtype
=
'float32'
)
name
=
'loc_targets'
,
shape
=
loc_shape
,
dtype
=
'float32'
)
cls_targets
=
fluid
.
data
(
cls_targets
=
fluid
.
layers
.
data
(
name
=
'cls_targets'
,
shape
=
cls_shape
,
dtype
=
'int64'
)
name
=
'cls_targets'
,
shape
=
cls_shape
,
dtype
=
'int64'
)
fileid
=
fluid
.
data
(
fileid
=
fluid
.
layers
.
data
(
name
=
'fileid'
,
shape
=
fileid_shape
,
dtype
=
'int64'
)
name
=
'fileid'
,
shape
=
fileid_shape
,
dtype
=
'int64'
)
feed_list
.
append
(
loc_targets
)
feed_list
.
append
(
loc_targets
)
feed_list
.
append
(
cls_targets
)
feed_list
.
append
(
cls_targets
)
...
@@ -92,10 +93,10 @@ class CTCN(ModelBase):
...
@@ -92,10 +93,10 @@ class CTCN(ModelBase):
raise
NotImplementedError
(
'mode {} not implemented'
.
format
(
raise
NotImplementedError
(
'mode {} not implemented'
.
format
(
self
.
mode
))
self
.
mode
))
if
use_
datalo
ader
:
if
use_
pyre
ader
:
assert
self
.
mode
!=
'infer'
,
\
assert
self
.
mode
!=
'infer'
,
\
'
dataloader is not recommendated when infer, please set use_datalo
ader to be false.'
'
pyreader is not recommendated when infer, please set use_pyre
ader to be false.'
self
.
dataloader
=
fluid
.
io
.
DataLoader
.
from_generato
r
(
self
.
py_reader
=
fluid
.
io
.
PyReade
r
(
feed_list
=
feed_list
,
capacity
=
4
,
iterable
=
True
)
feed_list
=
feed_list
,
capacity
=
4
,
iterable
=
True
)
self
.
feature_input
=
[
image
]
self
.
feature_input
=
[
image
]
...
...
PaddleCV/PaddleVideo/models/model.py
浏览文件 @
1137c0c0
...
@@ -65,13 +65,13 @@ class ModelBase(object):
...
@@ -65,13 +65,13 @@ class ModelBase(object):
self
.
is_training
=
(
mode
==
'train'
)
self
.
is_training
=
(
mode
==
'train'
)
self
.
mode
=
mode
self
.
mode
=
mode
self
.
cfg
=
cfg
self
.
cfg
=
cfg
self
.
datalo
ader
=
None
self
.
py_re
ader
=
None
def
build_model
(
self
):
def
build_model
(
self
):
"build model struct"
"build model struct"
raise
NotImplementError
(
self
,
self
.
build_model
)
raise
NotImplementError
(
self
,
self
.
build_model
)
def
build_input
(
self
,
use_
datalo
ader
):
def
build_input
(
self
,
use_
pyre
ader
):
"build input Variable"
"build input Variable"
raise
NotImplementError
(
self
,
self
.
build_input
)
raise
NotImplementError
(
self
,
self
.
build_input
)
...
@@ -114,8 +114,8 @@ class ModelBase(object):
...
@@ -114,8 +114,8 @@ class ModelBase(object):
wget
.
download
(
url
,
path
)
wget
.
download
(
url
,
path
)
return
path
return
path
def
datalo
ader
(
self
):
def
pyre
ader
(
self
):
return
self
.
datalo
ader
return
self
.
py_re
ader
def
epoch_num
(
self
):
def
epoch_num
(
self
):
"get train epoch num"
"get train epoch num"
...
...
PaddleCV/PaddleVideo/models/nextvlad/nextvlad.py
浏览文件 @
1137c0c0
...
@@ -61,17 +61,17 @@ class NEXTVLAD(ModelBase):
...
@@ -61,17 +61,17 @@ class NEXTVLAD(ModelBase):
# other params
# other params
self
.
batch_size
=
self
.
get_config_from_sec
(
self
.
mode
,
'batch_size'
)
self
.
batch_size
=
self
.
get_config_from_sec
(
self
.
mode
,
'batch_size'
)
def
build_input
(
self
,
use_
datalo
ader
=
True
):
def
build_input
(
self
,
use_
pyre
ader
=
True
):
rgb_shape
=
[
None
,
self
.
video_feature_size
]
rgb_shape
=
[
self
.
video_feature_size
]
audio_shape
=
[
None
,
self
.
audio_feature_size
]
audio_shape
=
[
self
.
audio_feature_size
]
label_shape
=
[
None
,
self
.
num_classes
]
label_shape
=
[
self
.
num_classes
]
rgb
=
fluid
.
data
(
rgb
=
fluid
.
layers
.
data
(
name
=
'train_rgb'
if
self
.
is_training
else
'test_rgb'
,
name
=
'train_rgb'
if
self
.
is_training
else
'test_rgb'
,
shape
=
rgb_shape
,
shape
=
rgb_shape
,
dtype
=
'uint8'
,
dtype
=
'uint8'
,
lod_level
=
1
)
lod_level
=
1
)
audio
=
fluid
.
data
(
audio
=
fluid
.
layers
.
data
(
name
=
'train_audio'
if
self
.
is_training
else
'test_audio'
,
name
=
'train_audio'
if
self
.
is_training
else
'test_audio'
,
shape
=
audio_shape
,
shape
=
audio_shape
,
dtype
=
'uint8'
,
dtype
=
'uint8'
,
...
@@ -79,15 +79,15 @@ class NEXTVLAD(ModelBase):
...
@@ -79,15 +79,15 @@ class NEXTVLAD(ModelBase):
if
self
.
mode
==
'infer'
:
if
self
.
mode
==
'infer'
:
label
=
None
label
=
None
else
:
else
:
label
=
fluid
.
data
(
label
=
fluid
.
layers
.
data
(
name
=
'train_label'
if
self
.
is_training
else
'test_label'
,
name
=
'train_label'
if
self
.
is_training
else
'test_label'
,
shape
=
label_shape
,
shape
=
label_shape
,
dtype
=
'float32'
)
dtype
=
'float32'
)
if
use_
datalo
ader
:
if
use_
pyre
ader
:
assert
self
.
mode
!=
'infer'
,
\
assert
self
.
mode
!=
'infer'
,
\
'
dataloader is not recommendated when infer, please set use_datalo
ader to be false.'
'
pyreader is not recommendated when infer, please set use_pyre
ader to be false.'
self
.
dataloader
=
fluid
.
io
.
DataLoader
.
from_generato
r
(
self
.
py_reader
=
fluid
.
io
.
PyReade
r
(
feed_list
=
[
rgb
,
audio
,
label
],
capacity
=
8
,
iterable
=
True
)
feed_list
=
[
rgb
,
audio
,
label
],
capacity
=
8
,
iterable
=
True
)
self
.
feature_input
=
[
rgb
,
audio
]
self
.
feature_input
=
[
rgb
,
audio
]
self
.
label_input
=
label
self
.
label_input
=
label
...
...
PaddleCV/PaddleVideo/models/nonlocal_model/nonlocal_model.py
浏览文件 @
1137c0c0
...
@@ -39,26 +39,26 @@ class NonLocal(ModelBase):
...
@@ -39,26 +39,26 @@ class NonLocal(ModelBase):
# crop size
# crop size
self
.
crop_size
=
self
.
get_config_from_sec
(
self
.
mode
,
'crop_size'
)
self
.
crop_size
=
self
.
get_config_from_sec
(
self
.
mode
,
'crop_size'
)
def
build_input
(
self
,
use_
datalo
ader
=
True
):
def
build_input
(
self
,
use_
pyre
ader
=
True
):
input_shape
=
[
None
,
3
,
self
.
video_length
,
self
.
crop_size
,
self
.
crop_size
]
input_shape
=
[
3
,
self
.
video_length
,
self
.
crop_size
,
self
.
crop_size
]
label_shape
=
[
None
,
1
]
label_shape
=
[
1
]
data
=
fluid
.
data
(
data
=
fluid
.
layers
.
data
(
name
=
'train_data'
if
self
.
is_training
else
'test_data'
,
name
=
'train_data'
if
self
.
is_training
else
'test_data'
,
shape
=
input_shape
,
shape
=
input_shape
,
dtype
=
'float32'
)
dtype
=
'float32'
)
if
self
.
mode
!=
'infer'
:
if
self
.
mode
!=
'infer'
:
label
=
fluid
.
data
(
label
=
fluid
.
layers
.
data
(
name
=
'train_label'
if
self
.
is_training
else
'test_label'
,
name
=
'train_label'
if
self
.
is_training
else
'test_label'
,
shape
=
label_shape
,
shape
=
label_shape
,
dtype
=
'int64'
)
dtype
=
'int64'
)
else
:
else
:
label
=
None
label
=
None
if
use_
datalo
ader
:
if
use_
pyre
ader
:
assert
self
.
mode
!=
'infer'
,
\
assert
self
.
mode
!=
'infer'
,
\
'
dataloader is not recommendated when infer, please set use_datalo
ader to be false.'
'
pyreader is not recommendated when infer, please set use_pyre
ader to be false.'
self
.
dataloader
=
fluid
.
io
.
DataLoader
.
from_generato
r
(
self
.
py_reader
=
fluid
.
io
.
PyReade
r
(
feed_list
=
[
data
,
label
],
capacity
=
4
,
iterable
=
True
)
feed_list
=
[
data
,
label
],
capacity
=
4
,
iterable
=
True
)
self
.
feature_input
=
[
data
]
self
.
feature_input
=
[
data
]
...
...
PaddleCV/PaddleVideo/models/stnet/stnet.py
浏览文件 @
1137c0c0
...
@@ -51,24 +51,25 @@ class STNET(ModelBase):
...
@@ -51,24 +51,25 @@ class STNET(ModelBase):
self
.
target_size
=
self
.
get_config_from_sec
(
self
.
mode
,
'target_size'
)
self
.
target_size
=
self
.
get_config_from_sec
(
self
.
mode
,
'target_size'
)
self
.
batch_size
=
self
.
get_config_from_sec
(
self
.
mode
,
'batch_size'
)
self
.
batch_size
=
self
.
get_config_from_sec
(
self
.
mode
,
'batch_size'
)
def
build_input
(
self
,
use_
datalo
ader
=
True
):
def
build_input
(
self
,
use_
pyre
ader
=
True
):
image_shape
=
[
3
,
self
.
target_size
,
self
.
target_size
]
image_shape
=
[
3
,
self
.
target_size
,
self
.
target_size
]
image_shape
[
0
]
=
image_shape
[
0
]
*
self
.
seglen
image_shape
[
0
]
=
image_shape
[
0
]
*
self
.
seglen
image_shape
=
[
None
,
self
.
seg_num
]
+
image_shape
image_shape
=
[
self
.
seg_num
]
+
image_shape
self
.
use_
dataloader
=
use_datalo
ader
self
.
use_
pyreader
=
use_pyre
ader
image
=
fluid
.
data
(
image
=
fluid
.
layers
.
data
(
name
=
'image'
,
shape
=
image_shape
,
dtype
=
'float32'
)
name
=
'image'
,
shape
=
image_shape
,
dtype
=
'float32'
)
if
self
.
mode
!=
'infer'
:
if
self
.
mode
!=
'infer'
:
label
=
fluid
.
data
(
name
=
'label'
,
shape
=
[
None
,
1
],
dtype
=
'int64'
)
label
=
fluid
.
layers
.
data
(
name
=
'label'
,
shape
=
[
1
],
dtype
=
'int64'
)
else
:
else
:
label
=
None
label
=
None
if
use_
datalo
ader
:
if
use_
pyre
ader
:
assert
self
.
mode
!=
'infer'
,
\
assert
self
.
mode
!=
'infer'
,
\
'
dataloader is not recommendated when infer, please set use_datalo
ader to be false.'
'
pyreader is not recommendated when infer, please set use_pyre
ader to be false.'
self
.
dataloader
=
fluid
.
io
.
DataLoader
.
from_generato
r
(
py_reader
=
fluid
.
io
.
PyReade
r
(
feed_list
=
[
image
,
label
],
capacity
=
4
,
iterable
=
True
)
feed_list
=
[
image
,
label
],
capacity
=
4
,
iterable
=
True
)
self
.
py_reader
=
py_reader
self
.
feature_input
=
[
image
]
self
.
feature_input
=
[
image
]
self
.
label_input
=
label
self
.
label_input
=
label
...
@@ -166,4 +167,3 @@ class STNET(ModelBase):
...
@@ -166,4 +167,3 @@ class STNET(ModelBase):
param_numpy
=
np
.
mean
(
param_numpy
,
axis
=
1
,
keepdims
=
True
)
/
self
.
seglen
param_numpy
=
np
.
mean
(
param_numpy
,
axis
=
1
,
keepdims
=
True
)
/
self
.
seglen
param_numpy
=
np
.
repeat
(
param_numpy
,
3
*
self
.
seglen
,
axis
=
1
)
param_numpy
=
np
.
repeat
(
param_numpy
,
3
*
self
.
seglen
,
axis
=
1
)
param_tensor
.
set
(
param_numpy
.
astype
(
np
.
float32
),
place
)
param_tensor
.
set
(
param_numpy
.
astype
(
np
.
float32
),
place
)
PaddleCV/PaddleVideo/models/tsm/tsm.py
浏览文件 @
1137c0c0
...
@@ -51,24 +51,25 @@ class TSM(ModelBase):
...
@@ -51,24 +51,25 @@ class TSM(ModelBase):
self
.
target_size
=
self
.
get_config_from_sec
(
self
.
mode
,
'target_size'
)
self
.
target_size
=
self
.
get_config_from_sec
(
self
.
mode
,
'target_size'
)
self
.
batch_size
=
self
.
get_config_from_sec
(
self
.
mode
,
'batch_size'
)
self
.
batch_size
=
self
.
get_config_from_sec
(
self
.
mode
,
'batch_size'
)
def
build_input
(
self
,
use_
datalo
ader
=
True
):
def
build_input
(
self
,
use_
pyre
ader
=
True
):
image_shape
=
[
3
,
self
.
target_size
,
self
.
target_size
]
image_shape
=
[
3
,
self
.
target_size
,
self
.
target_size
]
image_shape
[
0
]
=
image_shape
[
0
]
*
self
.
seglen
image_shape
[
0
]
=
image_shape
[
0
]
*
self
.
seglen
image_shape
=
[
None
,
self
.
seg_num
]
+
image_shape
image_shape
=
[
self
.
seg_num
]
+
image_shape
self
.
use_
dataloader
=
use_datalo
ader
self
.
use_
pyreader
=
use_pyre
ader
image
=
fluid
.
data
(
image
=
fluid
.
layers
.
data
(
name
=
'image'
,
shape
=
image_shape
,
dtype
=
'float32'
)
name
=
'image'
,
shape
=
image_shape
,
dtype
=
'float32'
)
if
self
.
mode
!=
'infer'
:
if
self
.
mode
!=
'infer'
:
label
=
fluid
.
data
(
name
=
'label'
,
shape
=
[
None
,
1
],
dtype
=
'int64'
)
label
=
fluid
.
layers
.
data
(
name
=
'label'
,
shape
=
[
1
],
dtype
=
'int64'
)
else
:
else
:
label
=
None
label
=
None
if
use_
datalo
ader
:
if
use_
pyre
ader
:
assert
self
.
mode
!=
'infer'
,
\
assert
self
.
mode
!=
'infer'
,
\
'
dataloader is not recommendated when infer, please set use_datalo
ader to be false.'
'
pyreader is not recommendated when infer, please set use_pyre
ader to be false.'
self
.
dataloader
=
fluid
.
io
.
DataLoader
.
from_generato
r
(
py_reader
=
fluid
.
io
.
PyReade
r
(
feed_list
=
[
image
,
label
],
capacity
=
4
,
iterable
=
True
)
feed_list
=
[
image
,
label
],
capacity
=
4
,
iterable
=
True
)
self
.
py_reader
=
py_reader
self
.
feature_input
=
[
image
]
self
.
feature_input
=
[
image
]
self
.
label_input
=
label
self
.
label_input
=
label
...
...
PaddleCV/PaddleVideo/models/tsn/tsn.py
浏览文件 @
1137c0c0
...
@@ -52,24 +52,25 @@ class TSN(ModelBase):
...
@@ -52,24 +52,25 @@ class TSN(ModelBase):
self
.
target_size
=
self
.
get_config_from_sec
(
self
.
mode
,
'target_size'
)
self
.
target_size
=
self
.
get_config_from_sec
(
self
.
mode
,
'target_size'
)
self
.
batch_size
=
self
.
get_config_from_sec
(
self
.
mode
,
'batch_size'
)
self
.
batch_size
=
self
.
get_config_from_sec
(
self
.
mode
,
'batch_size'
)
def
build_input
(
self
,
use_
datalo
ader
=
True
):
def
build_input
(
self
,
use_
pyre
ader
=
True
):
image_shape
=
[
3
,
self
.
target_size
,
self
.
target_size
]
image_shape
=
[
3
,
self
.
target_size
,
self
.
target_size
]
image_shape
[
0
]
=
image_shape
[
0
]
*
self
.
seglen
image_shape
[
0
]
=
image_shape
[
0
]
*
self
.
seglen
image_shape
=
[
None
,
self
.
seg_num
]
+
image_shape
image_shape
=
[
self
.
seg_num
]
+
image_shape
self
.
use_
dataloader
=
use_datalo
ader
self
.
use_
pyreader
=
use_pyre
ader
image
=
fluid
.
data
(
image
=
fluid
.
layers
.
data
(
name
=
'image'
,
shape
=
image_shape
,
dtype
=
'float32'
)
name
=
'image'
,
shape
=
image_shape
,
dtype
=
'float32'
)
if
self
.
mode
!=
'infer'
:
if
self
.
mode
!=
'infer'
:
label
=
fluid
.
data
(
name
=
'label'
,
shape
=
[
None
,
1
],
dtype
=
'int64'
)
label
=
fluid
.
layers
.
data
(
name
=
'label'
,
shape
=
[
1
],
dtype
=
'int64'
)
else
:
else
:
label
=
None
label
=
None
if
use_
datalo
ader
:
if
use_
pyre
ader
:
assert
self
.
mode
!=
'infer'
,
\
assert
self
.
mode
!=
'infer'
,
\
'
dataloader is not recommendated when infer, please set use_datalo
ader to be false.'
'
pyreader is not recommendated when infer, please set use_pyre
ader to be false.'
self
.
dataloader
=
fluid
.
io
.
DataLoader
.
from_generato
r
(
py_reader
=
fluid
.
io
.
PyReade
r
(
feed_list
=
[
image
,
label
],
capacity
=
4
,
iterable
=
True
)
feed_list
=
[
image
,
label
],
capacity
=
4
,
iterable
=
True
)
self
.
py_reader
=
py_reader
self
.
feature_input
=
[
image
]
self
.
feature_input
=
[
image
]
self
.
label_input
=
label
self
.
label_input
=
label
...
...
PaddleCV/PaddleVideo/predict.py
浏览文件 @
1137c0c0
...
@@ -30,7 +30,6 @@ import models
...
@@ -30,7 +30,6 @@ import models
from
reader
import
get_reader
from
reader
import
get_reader
from
metrics
import
get_metrics
from
metrics
import
get_metrics
from
utils.utility
import
check_cuda
from
utils.utility
import
check_cuda
from
utils.utility
import
check_version
logging
.
root
.
handlers
=
[]
logging
.
root
.
handlers
=
[]
FORMAT
=
'[%(levelname)s: %(filename)s: %(lineno)4d]: %(message)s'
FORMAT
=
'[%(levelname)s: %(filename)s: %(lineno)4d]: %(message)s'
...
@@ -101,7 +100,7 @@ def infer(args):
...
@@ -101,7 +100,7 @@ def infer(args):
infer_config
=
merge_configs
(
config
,
'infer'
,
vars
(
args
))
infer_config
=
merge_configs
(
config
,
'infer'
,
vars
(
args
))
print_configs
(
infer_config
,
"Infer"
)
print_configs
(
infer_config
,
"Infer"
)
infer_model
=
models
.
get_model
(
args
.
model_name
,
infer_config
,
mode
=
'infer'
)
infer_model
=
models
.
get_model
(
args
.
model_name
,
infer_config
,
mode
=
'infer'
)
infer_model
.
build_input
(
use_
datalo
ader
=
False
)
infer_model
.
build_input
(
use_
pyre
ader
=
False
)
infer_model
.
build_model
()
infer_model
.
build_model
()
infer_feeds
=
infer_model
.
feeds
()
infer_feeds
=
infer_model
.
feeds
()
infer_outputs
=
infer_model
.
outputs
()
infer_outputs
=
infer_model
.
outputs
()
...
@@ -166,7 +165,6 @@ if __name__ == "__main__":
...
@@ -166,7 +165,6 @@ if __name__ == "__main__":
args
=
parse_args
()
args
=
parse_args
()
# check whether the installed paddle is compiled with GPU
# check whether the installed paddle is compiled with GPU
check_cuda
(
args
.
use_gpu
)
check_cuda
(
args
.
use_gpu
)
check_version
()
logger
.
info
(
args
)
logger
.
info
(
args
)
infer
(
args
)
infer
(
args
)
PaddleCV/PaddleVideo/train.py
浏览文件 @
1137c0c0
...
@@ -21,13 +21,12 @@ import logging
...
@@ -21,13 +21,12 @@ import logging
import
numpy
as
np
import
numpy
as
np
import
paddle.fluid
as
fluid
import
paddle.fluid
as
fluid
from
utils.train_utils
import
train_with_
datalo
ader
from
utils.train_utils
import
train_with_
pyre
ader
import
models
import
models
from
utils.config_utils
import
*
from
utils.config_utils
import
*
from
reader
import
get_reader
from
reader
import
get_reader
from
metrics
import
get_metrics
from
metrics
import
get_metrics
from
utils.utility
import
check_cuda
from
utils.utility
import
check_cuda
from
utils.utility
import
check_version
logging
.
root
.
handlers
=
[]
logging
.
root
.
handlers
=
[]
FORMAT
=
'[%(levelname)s: %(filename)s: %(lineno)4d]: %(message)s'
FORMAT
=
'[%(levelname)s: %(filename)s: %(lineno)4d]: %(message)s'
...
@@ -125,7 +124,7 @@ def train(args):
...
@@ -125,7 +124,7 @@ def train(args):
train_prog
.
random_seed
=
1000
train_prog
.
random_seed
=
1000
with
fluid
.
program_guard
(
train_prog
,
startup
):
with
fluid
.
program_guard
(
train_prog
,
startup
):
with
fluid
.
unique_name
.
guard
():
with
fluid
.
unique_name
.
guard
():
train_model
.
build_input
(
use_
datalo
ader
=
True
)
train_model
.
build_input
(
use_
pyre
ader
=
True
)
train_model
.
build_model
()
train_model
.
build_model
()
# for the input, has the form [data1, data2,..., label], so train_feeds[-1] is label
# for the input, has the form [data1, data2,..., label], so train_feeds[-1] is label
train_feeds
=
train_model
.
feeds
()
train_feeds
=
train_model
.
feeds
()
...
@@ -135,16 +134,16 @@ def train(args):
...
@@ -135,16 +134,16 @@ def train(args):
item
.
persistable
=
True
item
.
persistable
=
True
optimizer
=
train_model
.
optimizer
()
optimizer
=
train_model
.
optimizer
()
optimizer
.
minimize
(
train_loss
)
optimizer
.
minimize
(
train_loss
)
train_
dataloader
=
train_model
.
datalo
ader
()
train_
pyreader
=
train_model
.
pyre
ader
()
valid_prog
=
fluid
.
Program
()
valid_prog
=
fluid
.
Program
()
with
fluid
.
program_guard
(
valid_prog
,
startup
):
with
fluid
.
program_guard
(
valid_prog
,
startup
):
with
fluid
.
unique_name
.
guard
():
with
fluid
.
unique_name
.
guard
():
valid_model
.
build_input
(
use_
datalo
ader
=
True
)
valid_model
.
build_input
(
use_
pyre
ader
=
True
)
valid_model
.
build_model
()
valid_model
.
build_model
()
valid_feeds
=
valid_model
.
feeds
()
valid_feeds
=
valid_model
.
feeds
()
valid_fetch_list
=
valid_model
.
fetches
()
valid_fetch_list
=
valid_model
.
fetches
()
valid_
dataloader
=
valid_model
.
datalo
ader
()
valid_
pyreader
=
valid_model
.
pyre
ader
()
for
item
in
valid_fetch_list
:
for
item
in
valid_fetch_list
:
item
.
persistable
=
True
item
.
persistable
=
True
...
@@ -191,8 +190,8 @@ def train(args):
...
@@ -191,8 +190,8 @@ def train(args):
gpus
=
gpus
.
split
(
","
)
gpus
=
gpus
.
split
(
","
)
num_gpus
=
len
(
gpus
)
num_gpus
=
len
(
gpus
)
assert
num_gpus
==
train_config
.
TRAIN
.
num_gpus
,
\
assert
num_gpus
==
train_config
.
TRAIN
.
num_gpus
,
\
"num_gpus({}) set by CUDA_VISIBLE_DEVICES
"
\
"num_gpus({}) set by CUDA_VISIBLE_DEVICES"
\
"shoud be the same as that
"
\
"shoud be the same as that"
\
"set in {}({})"
.
format
(
"set in {}({})"
.
format
(
num_gpus
,
args
.
config
,
train_config
.
TRAIN
.
num_gpus
)
num_gpus
,
args
.
config
,
train_config
.
TRAIN
.
num_gpus
)
bs_denominator
=
train_config
.
TRAIN
.
num_gpus
bs_denominator
=
train_config
.
TRAIN
.
num_gpus
...
@@ -211,16 +210,16 @@ def train(args):
...
@@ -211,16 +210,16 @@ def train(args):
epochs
=
args
.
epoch
or
train_model
.
epoch_num
()
epochs
=
args
.
epoch
or
train_model
.
epoch_num
()
exe_places
=
fluid
.
cuda_places
()
if
args
.
use_gpu
else
fluid
.
cpu_places
()
exe_places
=
fluid
.
cuda_places
()
if
args
.
use_gpu
else
fluid
.
cpu_places
()
train_
dataloader
.
set
_sample_list_generator
(
train_
pyreader
.
decorate
_sample_list_generator
(
train_reader
,
places
=
exe_places
)
train_reader
,
places
=
exe_places
)
valid_
dataloader
.
set
_sample_list_generator
(
valid_
pyreader
.
decorate
_sample_list_generator
(
valid_reader
,
places
=
exe_places
)
valid_reader
,
places
=
exe_places
)
train_with_
datalo
ader
(
train_with_
pyre
ader
(
exe
,
exe
,
train_prog
,
train_prog
,
compiled_train_prog
,
#train_exe,
compiled_train_prog
,
#train_exe,
train_
datalo
ader
,
train_
pyre
ader
,
train_fetch_list
,
train_fetch_list
,
train_metrics
,
train_metrics
,
epochs
=
epochs
,
epochs
=
epochs
,
...
@@ -230,7 +229,7 @@ def train(args):
...
@@ -230,7 +229,7 @@ def train(args):
save_model_name
=
args
.
model_name
,
save_model_name
=
args
.
model_name
,
fix_random_seed
=
args
.
fix_random_seed
,
fix_random_seed
=
args
.
fix_random_seed
,
compiled_test_prog
=
compiled_valid_prog
,
#test_exe=valid_exe,
compiled_test_prog
=
compiled_valid_prog
,
#test_exe=valid_exe,
test_
dataloader
=
valid_datalo
ader
,
test_
pyreader
=
valid_pyre
ader
,
test_fetch_list
=
valid_fetch_list
,
test_fetch_list
=
valid_fetch_list
,
test_metrics
=
valid_metrics
)
test_metrics
=
valid_metrics
)
...
@@ -239,7 +238,6 @@ if __name__ == "__main__":
...
@@ -239,7 +238,6 @@ if __name__ == "__main__":
args
=
parse_args
()
args
=
parse_args
()
# check whether the installed paddle is compiled with GPU
# check whether the installed paddle is compiled with GPU
check_cuda
(
args
.
use_gpu
)
check_cuda
(
args
.
use_gpu
)
check_version
()
logger
.
info
(
args
)
logger
.
info
(
args
)
if
not
os
.
path
.
exists
(
args
.
save_dir
):
if
not
os
.
path
.
exists
(
args
.
save_dir
):
...
...
PaddleCV/PaddleVideo/utils/train_utils.py
浏览文件 @
1137c0c0
...
@@ -47,19 +47,19 @@ def log_lr_and_step():
...
@@ -47,19 +47,19 @@ def log_lr_and_step():
logger
.
warn
(
"Unable to get learning_rate and LR_DECAY_COUNTER."
)
logger
.
warn
(
"Unable to get learning_rate and LR_DECAY_COUNTER."
)
def
test_with_
datalo
ader
(
exe
,
def
test_with_
pyre
ader
(
exe
,
compiled_test_prog
,
compiled_test_prog
,
test_
datalo
ader
,
test_
pyre
ader
,
test_fetch_list
,
test_fetch_list
,
test_metrics
,
test_metrics
,
log_interval
=
0
,
log_interval
=
0
,
save_model_name
=
''
):
save_model_name
=
''
):
if
not
test_
datalo
ader
:
if
not
test_
pyre
ader
:
logger
.
error
(
"[TEST] get
datalo
ader failed."
)
logger
.
error
(
"[TEST] get
pyre
ader failed."
)
test_metrics
.
reset
()
test_metrics
.
reset
()
test_iter
=
0
test_iter
=
0
for
data
in
test_
datalo
ader
():
for
data
in
test_
pyre
ader
():
test_outs
=
exe
.
run
(
compiled_test_prog
,
test_outs
=
exe
.
run
(
compiled_test_prog
,
fetch_list
=
test_fetch_list
,
fetch_list
=
test_fetch_list
,
feed
=
data
)
feed
=
data
)
...
@@ -71,14 +71,14 @@ def test_with_dataloader(exe,
...
@@ -71,14 +71,14 @@ def test_with_dataloader(exe,
test_metrics
.
finalize_and_log_out
(
"[TEST] Finish"
)
test_metrics
.
finalize_and_log_out
(
"[TEST] Finish"
)
def
train_with_
dataloader
(
exe
,
train_prog
,
compiled_train_prog
,
train_datalo
ader
,
\
def
train_with_
pyreader
(
exe
,
train_prog
,
compiled_train_prog
,
train_pyre
ader
,
\
train_fetch_list
,
train_metrics
,
epochs
=
10
,
\
train_fetch_list
,
train_metrics
,
epochs
=
10
,
\
log_interval
=
0
,
valid_interval
=
0
,
save_dir
=
'./'
,
\
log_interval
=
0
,
valid_interval
=
0
,
save_dir
=
'./'
,
\
save_model_name
=
'model'
,
fix_random_seed
=
False
,
\
save_model_name
=
'model'
,
fix_random_seed
=
False
,
\
compiled_test_prog
=
None
,
test_
datalo
ader
=
None
,
\
compiled_test_prog
=
None
,
test_
pyre
ader
=
None
,
\
test_fetch_list
=
None
,
test_metrics
=
None
):
test_fetch_list
=
None
,
test_metrics
=
None
):
if
not
train_
datalo
ader
:
if
not
train_
pyre
ader
:
logger
.
error
(
"[TRAIN] get
datalo
ader failed."
)
logger
.
error
(
"[TRAIN] get
pyre
ader failed."
)
epoch_periods
=
[]
epoch_periods
=
[]
train_loss
=
0
train_loss
=
0
for
epoch
in
range
(
epochs
):
for
epoch
in
range
(
epochs
):
...
@@ -87,7 +87,7 @@ def train_with_dataloader(exe, train_prog, compiled_train_prog, train_dataloader
...
@@ -87,7 +87,7 @@ def train_with_dataloader(exe, train_prog, compiled_train_prog, train_dataloader
train_iter
=
0
train_iter
=
0
epoch_periods
=
[]
epoch_periods
=
[]
for
data
in
train_
datalo
ader
():
for
data
in
train_
pyre
ader
():
cur_time
=
time
.
time
()
cur_time
=
time
.
time
()
train_outs
=
exe
.
run
(
compiled_train_prog
,
train_outs
=
exe
.
run
(
compiled_train_prog
,
fetch_list
=
train_fetch_list
,
fetch_list
=
train_fetch_list
,
...
@@ -122,7 +122,7 @@ def train_with_dataloader(exe, train_prog, compiled_train_prog, train_dataloader
...
@@ -122,7 +122,7 @@ def train_with_dataloader(exe, train_prog, compiled_train_prog, train_dataloader
save_type
=
'.pdparams'
)
save_type
=
'.pdparams'
)
if
compiled_test_prog
and
valid_interval
>
0
and
(
if
compiled_test_prog
and
valid_interval
>
0
and
(
epoch
+
1
)
%
valid_interval
==
0
:
epoch
+
1
)
%
valid_interval
==
0
:
test_with_
dataloader
(
exe
,
compiled_test_prog
,
test_datalo
ader
,
test_with_
pyreader
(
exe
,
compiled_test_prog
,
test_pyre
ader
,
test_fetch_list
,
test_metrics
,
log_interval
,
test_fetch_list
,
test_metrics
,
log_interval
,
save_model_name
)
save_model_name
)
...
...
PaddleCV/PaddleVideo/utils/utility.py
浏览文件 @
1137c0c0
...
@@ -14,13 +14,11 @@
...
@@ -14,13 +14,11 @@
import
os
import
os
import
signal
import
signal
import
logging
import
paddle
import
paddle
import
paddle.fluid
as
fluid
import
paddle.fluid
as
fluid
__all__
=
[
'AttrDict'
]
__all__
=
[
'AttrDict'
]
logger
=
logging
.
getLogger
(
__name__
)
def
_term
(
sig_num
,
addition
):
def
_term
(
sig_num
,
addition
):
print
(
'current pid is %s, group id is %s'
%
(
os
.
getpid
(),
os
.
getpgrp
()))
print
(
'current pid is %s, group id is %s'
%
(
os
.
getpid
(),
os
.
getpgrp
()))
...
@@ -51,18 +49,3 @@ def check_cuda(use_cuda, err = \
...
@@ -51,18 +49,3 @@ def check_cuda(use_cuda, err = \
sys
.
exit
(
1
)
sys
.
exit
(
1
)
except
Exception
as
e
:
except
Exception
as
e
:
pass
pass
def
check_version
():
"""
Log error and exit when the installed version of paddlepaddle is
not satisfied.
"""
err
=
"PaddlePaddle version 1.6 or higher is required, "
\
"or a suitable develop version is satisfied as well.
\n
"
\
"Please make sure the version is good with your code."
\
try
:
fluid
.
require_version
(
'1.6.0'
)
except
Exception
as
e
:
logger
.
error
(
err
)
sys
.
exit
(
1
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录