Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
曾经的那一瞬间
Models
提交
d41a1626
M
Models
项目概览
曾经的那一瞬间
/
Models
11 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
Models
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d41a1626
编写于
2月 16, 2023
作者:
A
A. Unique TensorFlower
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Internal change
PiperOrigin-RevId: 510189719
上级
8b35b7ab
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
16 addition
and
58 deletion
+16
-58
official/legacy/detection/modeling/architecture/heads.py
official/legacy/detection/modeling/architecture/heads.py
+6
-12
official/projects/deepmac_maskrcnn/modeling/heads/instance_heads.py
...rojects/deepmac_maskrcnn/modeling/heads/instance_heads.py
+5
-24
official/vision/modeling/heads/instance_heads.py
official/vision/modeling/heads/instance_heads.py
+5
-22
未找到文件。
official/legacy/detection/modeling/architecture/heads.py
浏览文件 @
d41a1626
...
...
@@ -673,18 +673,12 @@ class MaskrcnnHead(tf.keras.layers.Layer):
])
with
tf
.
name_scope
(
'masks_post_processing'
):
# TODO(pengchong): Figure out the way not to use the static inferred
# batch size.
batch_size
,
num_masks
=
class_indices
.
get_shape
().
as_list
()
mask_outputs
=
tf
.
transpose
(
a
=
mask_outputs
,
perm
=
[
0
,
1
,
4
,
2
,
3
])
# Constructs indices for gather.
batch_indices
=
tf
.
tile
(
tf
.
expand_dims
(
tf
.
range
(
batch_size
),
axis
=
1
),
[
1
,
num_masks
])
mask_indices
=
tf
.
tile
(
tf
.
expand_dims
(
tf
.
range
(
num_masks
),
axis
=
0
),
[
batch_size
,
1
])
gather_indices
=
tf
.
stack
(
[
batch_indices
,
mask_indices
,
class_indices
],
axis
=
2
)
mask_outputs
=
tf
.
gather_nd
(
mask_outputs
,
gather_indices
)
mask_outputs
=
tf
.
gather
(
mask_outputs
,
tf
.
cast
(
class_indices
,
tf
.
int32
),
axis
=-
1
,
batch_dims
=
2
,
)
return
mask_outputs
...
...
official/projects/deepmac_maskrcnn/modeling/heads/instance_heads.py
浏览文件 @
d41a1626
...
...
@@ -208,12 +208,7 @@ class DeepMaskHead(tf.keras.layers.Layer):
roi_width * upsample_factor], representing the mask predictions.
"""
roi_features
,
roi_classes
=
inputs
features_shape
=
tf
.
shape
(
roi_features
)
batch_size
,
num_rois
,
height
,
width
,
filters
=
(
features_shape
[
0
],
features_shape
[
1
],
features_shape
[
2
],
features_shape
[
3
],
features_shape
[
4
])
if
batch_size
is
None
:
batch_size
=
tf
.
shape
(
roi_features
)[
0
]
_
,
num_rois
,
height
,
width
,
filters
=
roi_features
.
get_shape
().
as_list
()
x
=
tf
.
reshape
(
roi_features
,
[
-
1
,
height
,
width
,
filters
])
...
...
@@ -229,29 +224,15 @@ class DeepMaskHead(tf.keras.layers.Layer):
mask_width
=
width
*
self
.
_config_dict
[
'upsample_factor'
]
if
self
.
_config_dict
[
'class_agnostic'
]:
logits
=
tf
.
reshape
(
logits
,
[
-
1
,
num_rois
,
mask_height
,
mask_width
,
1
])
return
tf
.
reshape
(
logits
,
[
-
1
,
num_rois
,
mask_height
,
mask_width
])
else
:
logits
=
tf
.
reshape
(
logits
,
[
-
1
,
num_rois
,
mask_height
,
mask_width
,
self
.
_config_dict
[
'num_classes'
]])
batch_indices
=
tf
.
tile
(
tf
.
expand_dims
(
tf
.
range
(
batch_size
),
axis
=
1
),
[
1
,
num_rois
])
mask_indices
=
tf
.
tile
(
tf
.
expand_dims
(
tf
.
range
(
num_rois
),
axis
=
0
),
[
batch_size
,
1
])
if
self
.
_config_dict
[
'class_agnostic'
]:
class_gather_indices
=
tf
.
zeros_like
(
roi_classes
,
dtype
=
tf
.
int32
)
else
:
class_gather_indices
=
tf
.
cast
(
roi_classes
,
dtype
=
tf
.
int32
)
gather_indices
=
tf
.
stack
(
[
batch_indices
,
mask_indices
,
class_gather_indices
],
axis
=
2
)
mask_outputs
=
tf
.
gather_nd
(
tf
.
transpose
(
logits
,
[
0
,
1
,
4
,
2
,
3
]),
gather_indices
)
return
mask_outputs
return
tf
.
gather
(
logits
,
tf
.
cast
(
roi_classes
,
dtype
=
tf
.
int32
),
axis
=-
1
,
batch_dims
=
2
)
def
_build_convnet_variant
(
self
):
...
...
official/vision/modeling/heads/instance_heads.py
浏览文件 @
d41a1626
...
...
@@ -399,10 +399,7 @@ class MaskHead(tf.keras.layers.Layer):
roi_width * upsample_factor], representing the mask predictions.
"""
roi_features
,
roi_classes
=
inputs
batch_size
,
num_rois
,
height
,
width
,
filters
=
(
roi_features
.
get_shape
().
as_list
())
if
batch_size
is
None
:
batch_size
=
tf
.
shape
(
roi_features
)[
0
]
_
,
num_rois
,
height
,
width
,
filters
=
roi_features
.
get_shape
().
as_list
()
x
=
tf
.
reshape
(
roi_features
,
[
-
1
,
height
,
width
,
filters
])
for
conv
,
bn
in
zip
(
self
.
_convs
,
self
.
_conv_norms
):
...
...
@@ -420,29 +417,15 @@ class MaskHead(tf.keras.layers.Layer):
mask_width
=
width
*
self
.
_config_dict
[
'upsample_factor'
]
if
self
.
_config_dict
[
'class_agnostic'
]:
logits
=
tf
.
reshape
(
logits
,
[
-
1
,
num_rois
,
mask_height
,
mask_width
,
1
])
return
tf
.
reshape
(
logits
,
[
-
1
,
num_rois
,
mask_height
,
mask_width
])
else
:
logits
=
tf
.
reshape
(
logits
,
[
-
1
,
num_rois
,
mask_height
,
mask_width
,
self
.
_config_dict
[
'num_classes'
]])
batch_indices
=
tf
.
tile
(
tf
.
expand_dims
(
tf
.
range
(
batch_size
),
axis
=
1
),
[
1
,
num_rois
])
mask_indices
=
tf
.
tile
(
tf
.
expand_dims
(
tf
.
range
(
num_rois
),
axis
=
0
),
[
batch_size
,
1
])
if
self
.
_config_dict
[
'class_agnostic'
]:
class_gather_indices
=
tf
.
zeros_like
(
roi_classes
,
dtype
=
tf
.
int32
)
else
:
class_gather_indices
=
tf
.
cast
(
roi_classes
,
dtype
=
tf
.
int32
)
gather_indices
=
tf
.
stack
(
[
batch_indices
,
mask_indices
,
class_gather_indices
],
axis
=
2
)
mask_outputs
=
tf
.
gather_nd
(
tf
.
transpose
(
logits
,
[
0
,
1
,
4
,
2
,
3
]),
gather_indices
)
return
mask_outputs
return
tf
.
gather
(
logits
,
tf
.
cast
(
roi_classes
,
dtype
=
tf
.
int32
),
axis
=-
1
,
batch_dims
=
2
)
def
get_config
(
self
):
return
self
.
_config_dict
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录