Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
曾经的那一瞬间
Models
提交
8f58f396
M
Models
项目概览
曾经的那一瞬间
/
Models
大约 1 年 前同步成功
通知
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,发现更多精彩内容 >>
提交
8f58f396
编写于
5月 03, 2021
作者:
X
Xianzhi Du
提交者:
A. Unique TensorFlower
5月 03, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Internal change
PiperOrigin-RevId: 371847148
上级
71c98d5d
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
212 addition
and
15 deletion
+212
-15
official/vision/beta/configs/experiments/maskrcnn/coco_spinenet143_casrcnn_tpu.yaml
...gs/experiments/maskrcnn/coco_spinenet143_casrcnn_tpu.yaml
+57
-0
official/vision/beta/configs/experiments/maskrcnn/coco_spinenet143_mrcnn_tpu.yaml
...figs/experiments/maskrcnn/coco_spinenet143_mrcnn_tpu.yaml
+0
-0
official/vision/beta/configs/experiments/maskrcnn/coco_spinenet49_casrcnn_tpu.yaml
...igs/experiments/maskrcnn/coco_spinenet49_casrcnn_tpu.yaml
+56
-0
official/vision/beta/configs/experiments/maskrcnn/coco_spinenet49_mrcnn_tpu.yaml
...nfigs/experiments/maskrcnn/coco_spinenet49_mrcnn_tpu.yaml
+0
-0
official/vision/beta/configs/experiments/maskrcnn/coco_spinenet96_casrcnn_tpu.yaml
...igs/experiments/maskrcnn/coco_spinenet96_casrcnn_tpu.yaml
+56
-0
official/vision/beta/configs/experiments/maskrcnn/coco_spinenet96_mrcnn_tpu.yaml
...nfigs/experiments/maskrcnn/coco_spinenet96_mrcnn_tpu.yaml
+0
-0
official/vision/beta/modeling/factory.py
official/vision/beta/modeling/factory.py
+22
-1
official/vision/beta/modeling/maskrcnn_model.py
official/vision/beta/modeling/maskrcnn_model.py
+20
-13
official/vision/beta/modeling/maskrcnn_model_test.py
official/vision/beta/modeling/maskrcnn_model_test.py
+1
-1
未找到文件。
official/vision/beta/configs/experiments/maskrcnn/coco_spinenet143_casrcnn_tpu.yaml
0 → 100644
浏览文件 @
8f58f396
# Expect to reach: box mAP: 51.6%, mask mAP: 44.5% on COCO
runtime
:
distribution_strategy
:
'
tpu'
mixed_precision_dtype
:
'
bfloat16'
task
:
init_checkpoint
:
null
train_data
:
global_batch_size
:
256
parser
:
aug_rand_hflip
:
true
aug_scale_min
:
0.1
aug_scale_max
:
2.5
losses
:
l2_weight_decay
:
0.00004
model
:
anchor
:
anchor_size
:
4.0
num_scales
:
3
min_level
:
3
max_level
:
7
input_size
:
[
1280
,
1280
,
3
]
backbone
:
spinenet
:
stochastic_depth_drop_rate
:
0.2
model_id
:
'
143'
type
:
'
spinenet'
decoder
:
type
:
'
identity'
detection_head
:
cascade_class_ensemble
:
true
class_agnostic_bbox_pred
:
true
rpn_head
:
num_convs
:
2
num_filters
:
256
roi_sampler
:
cascade_iou_thresholds
:
[
0.7
]
foreground_iou_threshold
:
0.6
norm_activation
:
norm_epsilon
:
0.001
norm_momentum
:
0.99
use_sync_bn
:
true
activation
:
'
swish'
detection_generator
:
pre_nms_top_k
:
1000
trainer
:
train_steps
:
162050
optimizer_config
:
learning_rate
:
type
:
'
stepwise'
stepwise
:
boundaries
:
[
148160
,
157420
]
values
:
[
0.32
,
0.032
,
0.0032
]
warmup
:
type
:
'
linear'
linear
:
warmup_steps
:
2000
warmup_learning_rate
:
0.0067
official/vision/beta/configs/experiments/maskrcnn/coco_spinenet143_tpu.yaml
→
official/vision/beta/configs/experiments/maskrcnn/coco_spinenet143_
mrcnn_
tpu.yaml
浏览文件 @
8f58f396
文件已移动
official/vision/beta/configs/experiments/maskrcnn/coco_spinenet49_casrcnn_tpu.yaml
0 → 100644
浏览文件 @
8f58f396
runtime
:
distribution_strategy
:
'
tpu'
mixed_precision_dtype
:
'
bfloat16'
task
:
init_checkpoint
:
null
train_data
:
global_batch_size
:
256
parser
:
aug_rand_hflip
:
true
aug_scale_min
:
0.1
aug_scale_max
:
2.0
losses
:
l2_weight_decay
:
0.00004
model
:
anchor
:
anchor_size
:
3.0
num_scales
:
3
min_level
:
3
max_level
:
7
input_size
:
[
640
,
640
,
3
]
backbone
:
spinenet
:
stochastic_depth_drop_rate
:
0.2
model_id
:
'
49'
type
:
'
spinenet'
decoder
:
type
:
'
identity'
detection_head
:
cascade_class_ensemble
:
true
class_agnostic_bbox_pred
:
true
rpn_head
:
num_convs
:
2
num_filters
:
256
roi_sampler
:
cascade_iou_thresholds
:
[
0.7
]
foreground_iou_threshold
:
0.6
norm_activation
:
norm_epsilon
:
0.001
norm_momentum
:
0.99
use_sync_bn
:
true
activation
:
'
swish'
detection_generator
:
pre_nms_top_k
:
1000
trainer
:
train_steps
:
231000
optimizer_config
:
learning_rate
:
type
:
'
stepwise'
stepwise
:
boundaries
:
[
219450
,
226380
]
values
:
[
0.28
,
0.028
,
0.0028
]
warmup
:
type
:
'
linear'
linear
:
warmup_steps
:
2000
warmup_learning_rate
:
0.0067
official/vision/beta/configs/experiments/maskrcnn/coco_spinenet49_tpu.yaml
→
official/vision/beta/configs/experiments/maskrcnn/coco_spinenet49_
mrcnn_
tpu.yaml
浏览文件 @
8f58f396
文件已移动
official/vision/beta/configs/experiments/maskrcnn/coco_spinenet96_casrcnn_tpu.yaml
0 → 100644
浏览文件 @
8f58f396
runtime
:
distribution_strategy
:
'
tpu'
mixed_precision_dtype
:
'
bfloat16'
task
:
init_checkpoint
:
null
train_data
:
global_batch_size
:
256
parser
:
aug_rand_hflip
:
true
aug_scale_min
:
0.1
aug_scale_max
:
2.0
losses
:
l2_weight_decay
:
0.00004
model
:
anchor
:
anchor_size
:
3.0
num_scales
:
3
min_level
:
3
max_level
:
7
input_size
:
[
1024
,
1024
,
3
]
backbone
:
spinenet
:
stochastic_depth_drop_rate
:
0.2
model_id
:
'
96'
type
:
'
spinenet'
decoder
:
type
:
'
identity'
detection_head
:
cascade_class_ensemble
:
true
class_agnostic_bbox_pred
:
true
rpn_head
:
num_convs
:
2
num_filters
:
256
roi_sampler
:
cascade_iou_thresholds
:
[
0.7
]
foreground_iou_threshold
:
0.6
norm_activation
:
norm_epsilon
:
0.001
norm_momentum
:
0.99
use_sync_bn
:
true
activation
:
'
swish'
detection_generator
:
pre_nms_top_k
:
1000
trainer
:
train_steps
:
231000
optimizer_config
:
learning_rate
:
type
:
'
stepwise'
stepwise
:
boundaries
:
[
219450
,
226380
]
values
:
[
0.32
,
0.032
,
0.0032
]
warmup
:
type
:
'
linear'
linear
:
warmup_steps
:
2000
warmup_learning_rate
:
0.0067
official/vision/beta/configs/experiments/maskrcnn/coco_spinenet96_tpu.yaml
→
official/vision/beta/configs/experiments/maskrcnn/coco_spinenet96_
mrcnn_
tpu.yaml
浏览文件 @
8f58f396
文件已移动
official/vision/beta/modeling/factory.py
浏览文件 @
8f58f396
...
...
@@ -114,7 +114,28 @@ def build_maskrcnn(
use_sync_bn
=
norm_activation_config
.
use_sync_bn
,
norm_momentum
=
norm_activation_config
.
norm_momentum
,
norm_epsilon
=
norm_activation_config
.
norm_epsilon
,
kernel_regularizer
=
l2_regularizer
)
kernel_regularizer
=
l2_regularizer
,
name
=
'detection_head'
)
if
roi_sampler_config
.
cascade_iou_thresholds
:
detection_head_cascade
=
[
detection_head
]
for
cascade_num
in
range
(
len
(
roi_sampler_config
.
cascade_iou_thresholds
)):
detection_head
=
instance_heads
.
DetectionHead
(
num_classes
=
model_config
.
num_classes
,
num_convs
=
detection_head_config
.
num_convs
,
num_filters
=
detection_head_config
.
num_filters
,
use_separable_conv
=
detection_head_config
.
use_separable_conv
,
num_fcs
=
detection_head_config
.
num_fcs
,
fc_dims
=
detection_head_config
.
fc_dims
,
class_agnostic_bbox_pred
=
detection_head_config
.
class_agnostic_bbox_pred
,
activation
=
norm_activation_config
.
activation
,
use_sync_bn
=
norm_activation_config
.
use_sync_bn
,
norm_momentum
=
norm_activation_config
.
norm_momentum
,
norm_epsilon
=
norm_activation_config
.
norm_epsilon
,
kernel_regularizer
=
l2_regularizer
,
name
=
'detection_head_{}'
.
format
(
cascade_num
+
1
))
detection_head_cascade
.
append
(
detection_head
)
detection_head
=
detection_head_cascade
roi_generator_obj
=
roi_generator
.
MultilevelROIGenerator
(
pre_nms_top_k
=
roi_generator_config
.
pre_nms_top_k
,
...
...
official/vision/beta/modeling/maskrcnn_model.py
浏览文件 @
8f58f396
...
...
@@ -31,7 +31,8 @@ class MaskRCNNModel(tf.keras.Model):
backbone
:
tf
.
keras
.
Model
,
decoder
:
tf
.
keras
.
Model
,
rpn_head
:
tf
.
keras
.
layers
.
Layer
,
detection_head
:
tf
.
keras
.
layers
.
Layer
,
detection_head
:
Union
[
tf
.
keras
.
layers
.
Layer
,
List
[
tf
.
keras
.
layers
.
Layer
]],
roi_generator
:
tf
.
keras
.
layers
.
Layer
,
roi_sampler
:
Union
[
tf
.
keras
.
layers
.
Layer
,
List
[
tf
.
keras
.
layers
.
Layer
]],
...
...
@@ -54,7 +55,7 @@ class MaskRCNNModel(tf.keras.Model):
backbone: `tf.keras.Model`, the backbone network.
decoder: `tf.keras.Model`, the decoder network.
rpn_head: the RPN head.
detection_head: the detection head.
detection_head: the detection head
or a list of heads
.
roi_generator: the ROI generator.
roi_sampler: a single ROI sampler or a list of ROI samplers for cascade
detection heads.
...
...
@@ -104,7 +105,10 @@ class MaskRCNNModel(tf.keras.Model):
self
.
backbone
=
backbone
self
.
decoder
=
decoder
self
.
rpn_head
=
rpn_head
self
.
detection_head
=
detection_head
if
not
isinstance
(
detection_head
,
(
list
,
tuple
)):
self
.
detection_head
=
[
detection_head
]
else
:
self
.
detection_head
=
detection_head
self
.
roi_generator
=
roi_generator
if
not
isinstance
(
roi_sampler
,
(
list
,
tuple
)):
self
.
roi_sampler
=
[
roi_sampler
]
...
...
@@ -191,7 +195,7 @@ class MaskRCNNModel(tf.keras.Model):
gt_classes
=
gt_classes
,
training
=
training
,
model_outputs
=
model_outputs
,
layer
_num
=
cascade_num
,
cascade
_num
=
cascade_num
,
regression_weights
=
regression_weights
)
all_class_outputs
.
append
(
class_outputs
)
...
...
@@ -266,7 +270,7 @@ class MaskRCNNModel(tf.keras.Model):
return
model_outputs
def
_run_frcnn_head
(
self
,
features
,
rois
,
gt_boxes
,
gt_classes
,
training
,
model_outputs
,
layer
_num
,
regression_weights
):
model_outputs
,
cascade
_num
,
regression_weights
):
"""Runs the frcnn head that does both class and box prediction.
Args:
...
...
@@ -279,7 +283,7 @@ class MaskRCNNModel(tf.keras.Model):
classes. It is padded with -1s to indicate the invalid classes.
training: `bool`, if model is training or being evaluated.
model_outputs: `dict`, used for storing outputs used for eval and losses.
layer
_num: `int`, the current frcnn layer in the cascade.
cascade
_num: `int`, the current frcnn layer in the cascade.
regression_weights: `list`, weights used for l1 loss in bounding box
regression.
...
...
@@ -305,7 +309,7 @@ class MaskRCNNModel(tf.keras.Model):
if
training
and
gt_boxes
is
not
None
:
rois
=
tf
.
stop_gradient
(
rois
)
current_roi_sampler
=
self
.
roi_sampler
[
layer
_num
]
current_roi_sampler
=
self
.
roi_sampler
[
cascade
_num
]
rois
,
matched_gt_boxes
,
matched_gt_classes
,
matched_gt_indices
=
(
current_roi_sampler
(
rois
,
gt_boxes
,
gt_classes
))
# Create bounding box training targets.
...
...
@@ -317,10 +321,11 @@ class MaskRCNNModel(tf.keras.Model):
tf
.
expand_dims
(
tf
.
equal
(
matched_gt_classes
,
0
),
axis
=-
1
),
[
1
,
1
,
4
]),
tf
.
zeros_like
(
box_targets
),
box_targets
)
model_outputs
.
update
({
'class_targets_{}'
.
format
(
layer
_num
)
if
layer
_num
else
'class_targets'
:
'class_targets_{}'
.
format
(
cascade
_num
)
if
cascade
_num
else
'class_targets'
:
matched_gt_classes
,
'box_targets_{}'
.
format
(
layer_num
)
if
layer_num
else
'box_targets'
:
'box_targets_{}'
.
format
(
cascade_num
)
if
cascade_num
else
'box_targets'
:
box_targets
,
})
...
...
@@ -328,12 +333,14 @@ class MaskRCNNModel(tf.keras.Model):
roi_features
=
self
.
roi_aligner
(
features
,
rois
)
# Run frcnn head to get class and bbox predictions.
class_outputs
,
box_outputs
=
self
.
detection_head
(
roi_features
)
current_detection_head
=
self
.
detection_head
[
cascade_num
]
class_outputs
,
box_outputs
=
current_detection_head
(
roi_features
)
model_outputs
.
update
({
'class_outputs_{}'
.
format
(
layer_num
)
if
layer_num
else
'class_outputs'
:
'class_outputs_{}'
.
format
(
cascade_num
)
if
cascade_num
else
'class_outputs'
:
class_outputs
,
'box_outputs_{}'
.
format
(
layer_num
)
if
layer
_num
else
'box_outputs'
:
'box_outputs_{}'
.
format
(
cascade_num
)
if
cascade
_num
else
'box_outputs'
:
box_outputs
,
})
return
(
class_outputs
,
box_outputs
,
model_outputs
,
matched_gt_boxes
,
...
...
official/vision/beta/modeling/maskrcnn_model_test.py
浏览文件 @
8f58f396
...
...
@@ -373,7 +373,7 @@ class MaskRCNNModelTest(parameterized.TestCase, tf.test.TestCase):
backbone
=
backbone
,
decoder
=
decoder
,
rpn_head
=
rpn_head
,
detection_head
=
detection_head
)
detection_head
=
[
detection_head
]
)
if
include_mask
:
expect_checkpoint_items
[
'mask_head'
]
=
mask_head
self
.
assertAllEqual
(
expect_checkpoint_items
,
model
.
checkpoint_items
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录