Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
hapi
提交
0b8b4815
H
hapi
项目概览
PaddlePaddle
/
hapi
通知
11
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
4
列表
看板
标记
里程碑
合并请求
7
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hapi
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
4
Issue
4
列表
看板
标记
里程碑
合并请求
7
合并请求
7
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
0b8b4815
编写于
4月 14, 2020
作者:
D
dengkaipeng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
use in_dygraph_mode
上级
4643cad7
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
8 addition
and
10 deletion
+8
-10
examples/bmn/eval.py
examples/bmn/eval.py
+1
-1
examples/bmn/predict.py
examples/bmn/predict.py
+1
-1
examples/bmn/train.py
examples/bmn/train.py
+1
-1
hapi/vision/models/bmn_model.py
hapi/vision/models/bmn_model.py
+5
-7
未找到文件。
examples/bmn/eval.py
浏览文件 @
0b8b4815
...
...
@@ -97,7 +97,7 @@ def test_bmn(args):
eval_dataset
=
BmnDataset
(
eval_cfg
,
'test'
)
#model
model
=
bmn
(
config
,
args
.
dynamic
,
pretrained
=
args
.
weights
is
None
)
model
=
bmn
(
config
,
pretrained
=
args
.
weights
is
None
)
model
.
prepare
(
loss_function
=
BmnLoss
(
config
),
metrics
=
BmnMetric
(
...
...
examples/bmn/predict.py
浏览文件 @
0b8b4815
...
...
@@ -92,7 +92,7 @@ def infer_bmn(args):
#data
infer_dataset
=
BmnDataset
(
infer_cfg
,
'infer'
)
model
=
bmn
(
config
,
args
.
dynamic
,
pretrained
=
args
.
weights
is
None
)
model
=
bmn
(
config
,
pretrained
=
args
.
weights
is
None
)
model
.
prepare
(
metrics
=
BmnMetric
(
config
,
mode
=
'infer'
),
...
...
examples/bmn/train.py
浏览文件 @
0b8b4815
...
...
@@ -136,7 +136,7 @@ def train_bmn(args):
val_dataset
=
BmnDataset
(
val_cfg
,
'valid'
)
# model
model
=
bmn
(
config
,
args
.
dynamic
,
pretrained
=
False
)
model
=
bmn
(
config
,
pretrained
=
False
)
optim
=
optimizer
(
config
,
parameter_list
=
model
.
parameters
())
model
.
prepare
(
optimizer
=
optim
,
...
...
hapi/vision/models/bmn_model.py
浏览文件 @
0b8b4815
...
...
@@ -14,6 +14,7 @@
import
paddle.fluid
as
fluid
from
paddle.fluid
import
ParamAttr
from
paddle.fluid.framework
import
in_dygraph_mode
import
numpy
as
np
import
math
...
...
@@ -131,9 +132,8 @@ class BMN(Model):
Args:
cfg (AttrDict): configs for BMN model
is_dygraph (bool): whether in dygraph mode, default True.
"""
def
__init__
(
self
,
cfg
,
is_dygraph
=
True
):
def
__init__
(
self
,
cfg
):
super
(
BMN
,
self
).
__init__
()
#init config
...
...
@@ -142,7 +142,6 @@ class BMN(Model):
self
.
prop_boundary_ratio
=
cfg
.
MODEL
.
prop_boundary_ratio
self
.
num_sample
=
cfg
.
MODEL
.
num_sample
self
.
num_sample_perbin
=
cfg
.
MODEL
.
num_sample_perbin
self
.
is_dygraph
=
is_dygraph
self
.
hidden_dim_1d
=
256
self
.
hidden_dim_2d
=
128
...
...
@@ -197,7 +196,7 @@ class BMN(Model):
sample_mask_array
=
get_interp1d_mask
(
self
.
tscale
,
self
.
dscale
,
self
.
prop_boundary_ratio
,
self
.
num_sample
,
self
.
num_sample_perbin
)
if
self
.
is_dygraph
:
if
in_dygraph_mode
():
self
.
sample_mask
=
fluid
.
dygraph
.
base
.
to_variable
(
sample_mask_array
)
else
:
# static
...
...
@@ -438,16 +437,15 @@ class BmnLoss(Loss):
return
loss
def
bmn
(
cfg
,
is_dygraph
=
True
,
pretrained
=
True
):
def
bmn
(
cfg
,
pretrained
=
True
):
"""BMN model
Args:
cfg (AttrDict): configs for BMN model
is_dygraph (bool): whether in dygraph mode, default True.
pretrained (bool): If True, returns a model with pre-trained model
on COCO, default True
"""
model
=
BMN
(
cfg
,
is_dygraph
=
is_dygraph
)
model
=
BMN
(
cfg
)
if
pretrained
:
weight_path
=
get_weights_path
(
*
(
pretrain_infos
[
'bmn'
]))
assert
weight_path
.
endswith
(
'.pdparams'
),
\
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录