Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
8ce83816
P
PaddleDetection
项目概览
s920243400
/
PaddleDetection
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleDetection
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
8ce83816
编写于
2月 17, 2020
作者:
Y
Yang Zhang
提交者:
GitHub
2月 17, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove leftover `Switch` ops (#240)
* Replace `switch` ops with `cond` * Use func instead of lambda
上级
582d3c25
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
40 addition
and
36 deletion
+40
-36
ppdet/modeling/architectures/cascade_mask_rcnn.py
ppdet/modeling/architectures/cascade_mask_rcnn.py
+20
-18
ppdet/modeling/architectures/mask_rcnn.py
ppdet/modeling/architectures/mask_rcnn.py
+20
-18
未找到文件。
ppdet/modeling/architectures/cascade_mask_rcnn.py
浏览文件 @
8ce83816
...
...
@@ -321,26 +321,28 @@ class CascadeMaskRCNN(object):
dtype
=
'float32'
,
persistable
=
False
,
name
=
mask_name
)
with
fluid
.
layers
.
control_flow
.
Switch
()
as
switch
:
with
switch
.
case
(
cond
):
fluid
.
layers
.
assign
(
input
=
bbox_pred
,
output
=
mask_pred
)
with
switch
.
default
():
bbox
=
fluid
.
layers
.
slice
(
bbox_pred
,
[
1
],
starts
=
[
2
],
ends
=
[
6
])
im_scale
=
fluid
.
layers
.
slice
(
im_info
,
[
1
],
starts
=
[
2
],
ends
=
[
3
])
im_scale
=
fluid
.
layers
.
sequence_expand
(
im_scale
,
bbox
)
def
noop
():
fluid
.
layers
.
assign
(
input
=
bbox_pred
,
output
=
mask_pred
)
mask_rois
=
bbox
*
im_scale
if
self
.
fpn
is
None
:
mask_feat
=
self
.
roi_extractor
(
last_feat
,
mask_rois
)
mask_feat
=
self
.
bbox_head
.
get_head_feat
(
mask_feat
)
else
:
mask_feat
=
self
.
roi_extractor
(
body_feats
,
mask_rois
,
spatial_scale
,
is_mask
=
True
)
mask_out
=
self
.
mask_head
.
get_prediction
(
mask_feat
,
bbox
)
fluid
.
layers
.
assign
(
input
=
mask_out
,
output
=
mask_pred
)
def
process_boxes
():
bbox
=
fluid
.
layers
.
slice
(
bbox_pred
,
[
1
],
starts
=
[
2
],
ends
=
[
6
])
im_scale
=
fluid
.
layers
.
slice
(
im_info
,
[
1
],
starts
=
[
2
],
ends
=
[
3
])
im_scale
=
fluid
.
layers
.
sequence_expand
(
im_scale
,
bbox
)
mask_rois
=
bbox
*
im_scale
if
self
.
fpn
is
None
:
mask_feat
=
self
.
roi_extractor
(
last_feat
,
mask_rois
)
mask_feat
=
self
.
bbox_head
.
get_head_feat
(
mask_feat
)
else
:
mask_feat
=
self
.
roi_extractor
(
body_feats
,
mask_rois
,
spatial_scale
,
is_mask
=
True
)
mask_out
=
self
.
mask_head
.
get_prediction
(
mask_feat
,
bbox
)
fluid
.
layers
.
assign
(
input
=
mask_out
,
output
=
mask_pred
)
fluid
.
layers
.
cond
(
cond
,
noop
,
process_boxes
)
return
mask_pred
,
bbox_pred
def
_input_check
(
self
,
require_fields
,
feed_vars
):
...
...
ppdet/modeling/architectures/mask_rcnn.py
浏览文件 @
8ce83816
...
...
@@ -240,27 +240,29 @@ class MaskRCNN(object):
dtype
=
'float32'
,
persistable
=
False
,
name
=
mask_name
)
with
fluid
.
layers
.
control_flow
.
Switch
()
as
switch
:
with
switch
.
case
(
cond
):
fluid
.
layers
.
assign
(
input
=
bbox_pred
,
output
=
mask_pred
)
with
switch
.
default
():
bbox
=
fluid
.
layers
.
slice
(
bbox_pred
,
[
1
],
starts
=
[
2
],
ends
=
[
6
])
im_scale
=
fluid
.
layers
.
slice
(
im_info
,
[
1
],
starts
=
[
2
],
ends
=
[
3
])
im_scale
=
fluid
.
layers
.
sequence_expand
(
im_scale
,
bbox
)
def
noop
():
fluid
.
layers
.
assign
(
input
=
bbox_pred
,
output
=
mask_pred
)
mask_rois
=
bbox
*
im_scale
if
self
.
fpn
is
None
:
last_feat
=
body_feats
[
list
(
body_feats
.
keys
())[
-
1
]]
mask_feat
=
self
.
roi_extractor
(
last_feat
,
mask_rois
)
mask_feat
=
self
.
bbox_head
.
get_head_feat
(
mask_feat
)
else
:
mask_feat
=
self
.
roi_extractor
(
body_feats
,
mask_rois
,
spatial_scale
,
is_mask
=
True
)
def
process_boxes
():
bbox
=
fluid
.
layers
.
slice
(
bbox_pred
,
[
1
],
starts
=
[
2
],
ends
=
[
6
])
im_scale
=
fluid
.
layers
.
slice
(
im_info
,
[
1
],
starts
=
[
2
],
ends
=
[
3
])
im_scale
=
fluid
.
layers
.
sequence_expand
(
im_scale
,
bbox
)
mask_rois
=
bbox
*
im_scale
if
self
.
fpn
is
None
:
last_feat
=
body_feats
[
list
(
body_feats
.
keys
())[
-
1
]]
mask_feat
=
self
.
roi_extractor
(
last_feat
,
mask_rois
)
mask_feat
=
self
.
bbox_head
.
get_head_feat
(
mask_feat
)
else
:
mask_feat
=
self
.
roi_extractor
(
body_feats
,
mask_rois
,
spatial_scale
,
is_mask
=
True
)
mask_out
=
self
.
mask_head
.
get_prediction
(
mask_feat
,
bbox
)
fluid
.
layers
.
assign
(
input
=
mask_out
,
output
=
mask_pred
)
mask_out
=
self
.
mask_head
.
get_prediction
(
mask_feat
,
bbox
)
fluid
.
layers
.
assign
(
input
=
mask_out
,
output
=
mask_pred
)
fluid
.
layers
.
cond
(
cond
,
noop
,
process_boxes
)
return
mask_pred
,
bbox_pred
def
_input_check
(
self
,
require_fields
,
feed_vars
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录