Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
曾经的那一瞬间
Models
提交
8d9a16ce
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,发现更多精彩内容 >>
提交
8d9a16ce
编写于
12月 16, 2019
作者:
Y
Yeqing Li
提交者:
A. Unique TensorFlower
12月 16, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Internal change
PiperOrigin-RevId: 285844156
上级
913640d4
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
26 addition
and
19 deletion
+26
-19
official/vision/detection/configs/base_config.py
official/vision/detection/configs/base_config.py
+4
-3
official/vision/detection/configs/maskrcnn_config.py
official/vision/detection/configs/maskrcnn_config.py
+1
-0
official/vision/detection/dataloader/maskrcnn_parser.py
official/vision/detection/dataloader/maskrcnn_parser.py
+17
-11
official/vision/detection/modeling/base_model.py
official/vision/detection/modeling/base_model.py
+1
-0
official/vision/detection/modeling/losses.py
official/vision/detection/modeling/losses.py
+2
-4
official/vision/detection/modeling/retinanet_model.py
official/vision/detection/modeling/retinanet_model.py
+1
-1
未找到文件。
official/vision/detection/configs/base_config.py
浏览文件 @
8d9a16ce
...
...
@@ -30,10 +30,11 @@ REGULARIZATION_VAR_REGEX = r'.*(kernel|weight):0$'
BASE_CFG
=
{
'model_dir'
:
''
,
'use_tpu'
:
True
,
'strategy_type'
:
'tpu'
,
'isolate_session_state'
:
False
,
'train'
:
{
'iterations_per_loop'
:
100
,
'
train_
batch_size'
:
64
,
'batch_size'
:
64
,
'total_steps'
:
22500
,
'num_cores_per_replica'
:
None
,
'input_partition_dims'
:
None
,
...
...
@@ -57,13 +58,13 @@ BASE_CFG = {
'frozen_variable_prefix'
:
RESNET_FROZEN_VAR_PREFIX
,
'train_file_pattern'
:
''
,
'train_dataset_type'
:
'tfrecord'
,
'transpose_input'
:
Tru
e
,
'transpose_input'
:
Fals
e
,
'regularization_variable_regex'
:
REGULARIZATION_VAR_REGEX
,
'l2_weight_decay'
:
0.0001
,
'gradient_clip_norm'
:
0.0
,
},
'eval'
:
{
'
eval_
batch_size'
:
8
,
'batch_size'
:
8
,
'eval_samples'
:
5000
,
'min_eval_interval'
:
180
,
'eval_timeout'
:
None
,
...
...
official/vision/detection/configs/maskrcnn_config.py
浏览文件 @
8d9a16ce
...
...
@@ -34,6 +34,7 @@ MASKRCNN_CFG.override({
'maskrcnn_parser'
:
{
'use_bfloat16'
:
True
,
'output_size'
:
[
1024
,
1024
],
'num_channels'
:
3
,
'rpn_match_threshold'
:
0.7
,
'rpn_unmatched_threshold'
:
0.3
,
'rpn_batch_size_per_im'
:
256
,
...
...
official/vision/detection/dataloader/maskrcnn_parser.py
浏览文件 @
8d9a16ce
...
...
@@ -275,6 +275,10 @@ class Parser(object):
if
self
.
_use_bfloat16
:
image
=
tf
.
cast
(
image
,
dtype
=
tf
.
bfloat16
)
inputs
=
{
'image'
:
image
,
'image_info'
:
image_info
,
}
# Packs labels for model_fn outputs.
labels
=
{
'anchor_boxes'
:
input_anchor
.
multilevel_boxes
,
...
...
@@ -282,15 +286,16 @@ class Parser(object):
'rpn_score_targets'
:
rpn_score_targets
,
'rpn_box_targets'
:
rpn_box_targets
,
}
labels
[
'gt_boxes'
]
=
input_utils
.
pad_to_fixed_size
(
boxes
,
self
.
_max_num_instances
,
-
1
)
labels
[
'gt_classes'
]
=
input_utils
.
pad_to_fixed_size
(
inputs
[
'gt_boxes'
]
=
input_utils
.
pad_to_fixed_size
(
boxes
,
self
.
_max_num_instances
,
-
1
)
inputs
[
'gt_classes'
]
=
input_utils
.
pad_to_fixed_size
(
classes
,
self
.
_max_num_instances
,
-
1
)
if
self
.
_include_mask
:
label
s
[
'gt_masks'
]
=
input_utils
.
pad_to_fixed_size
(
input
s
[
'gt_masks'
]
=
input_utils
.
pad_to_fixed_size
(
masks
,
self
.
_max_num_instances
,
-
1
)
return
i
mage
,
labels
return
i
nputs
,
labels
def
_parse_eval_data
(
self
,
data
):
"""Parses data for evaluation."""
...
...
@@ -348,11 +353,7 @@ class Parser(object):
self
.
_anchor_size
,
(
image_height
,
image_width
))
labels
=
{
'source_id'
:
dataloader_utils
.
process_source_id
(
data
[
'source_id'
]),
'anchor_boxes'
:
input_anchor
.
multilevel_boxes
,
'image_info'
:
image_info
,
}
labels
=
{}
if
self
.
_mode
==
ModeKeys
.
PREDICT_WITH_GT
:
# Converts boxes from normalized coordinates to pixel coordinates.
...
...
@@ -372,6 +373,11 @@ class Parser(object):
groundtruths
[
'source_id'
])
groundtruths
=
dataloader_utils
.
pad_groundtruths_to_fixed_size
(
groundtruths
,
self
.
_max_num_instances
)
# TODO(yeqing): Remove the `groundtrtuh` layer key (no longer needed).
labels
[
'groundtruths'
]
=
groundtruths
inputs
=
{
'image'
:
image
,
'image_info'
:
image_info
,
}
return
i
mage
,
labels
return
i
nputs
,
labels
official/vision/detection/modeling/base_model.py
浏览文件 @
8d9a16ce
...
...
@@ -99,6 +99,7 @@ class Model(object):
params
.
train
.
learning_rate
)
self
.
_frozen_variable_prefix
=
params
.
train
.
frozen_variable_prefix
self
.
_l2_weight_decay
=
params
.
train
.
l2_weight_decay
# Checkpoint restoration.
self
.
_checkpoint
=
params
.
train
.
checkpoint
.
as_dict
()
...
...
official/vision/detection/modeling/losses.py
浏览文件 @
8d9a16ce
...
...
@@ -147,6 +147,7 @@ class RpnBoxLoss(object):
"""Region Proposal Network box regression loss function."""
def
__init__
(
self
,
params
):
self
.
_delta
=
params
.
huber_loss_delta
self
.
_huber_loss
=
tf
.
keras
.
losses
.
Huber
(
delta
=
params
.
huber_loss_delta
,
reduction
=
tf
.
keras
.
losses
.
Reduction
.
SUM
)
...
...
@@ -212,7 +213,7 @@ class FastrcnnClassLoss(object):
a scalar tensor representing total class loss.
"""
with
tf
.
name_scope
(
'fast_rcnn_loss'
):
_
,
_
,
_
,
num_classes
=
class_outputs
.
get_shape
().
as_list
()
_
,
_
,
num_classes
=
class_outputs
.
get_shape
().
as_list
()
class_targets
=
tf
.
cast
(
class_targets
,
dtype
=
tf
.
int32
)
class_targets_one_hot
=
tf
.
one_hot
(
class_targets
,
num_classes
)
return
self
.
_fast_rcnn_class_loss
(
class_outputs
,
class_targets_one_hot
)
...
...
@@ -320,9 +321,6 @@ class FastrcnnBoxLoss(object):
class
MaskrcnnLoss
(
object
):
"""Mask R-CNN instance segmentation mask loss function."""
def
__init__
(
self
):
raise
ValueError
(
'Not TF 2.0 ready.'
)
def
__call__
(
self
,
mask_outputs
,
mask_targets
,
select_class_targets
):
"""Computes the mask loss of Mask-RCNN.
...
...
official/vision/detection/modeling/retinanet_model.py
浏览文件 @
8d9a16ce
...
...
@@ -56,7 +56,6 @@ class RetinanetModel(base_model.Model):
self
.
_generate_detections_fn
=
postprocess_ops
.
MultilevelDetectionGenerator
(
params
.
postprocess
)
self
.
_l2_weight_decay
=
params
.
train
.
l2_weight_decay
self
.
_transpose_input
=
params
.
train
.
transpose_input
assert
not
self
.
_transpose_input
,
'Transpose input is not supportted.'
# Input layer.
...
...
@@ -134,6 +133,7 @@ class RetinanetModel(base_model.Model):
return
self
.
_keras_model
def
post_processing
(
self
,
labels
,
outputs
):
# TODO(yeqing): Moves the output related part into build_outputs.
required_output_fields
=
[
'cls_outputs'
,
'box_outputs'
]
for
field
in
required_output_fields
:
if
field
not
in
outputs
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录