Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
曾经的那一瞬间
Models
提交
c21d3c25
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,发现更多精彩内容 >>
提交
c21d3c25
编写于
3月 05, 2018
作者:
Z
Zhichao Lu
提交者:
lzc5123016
3月 07, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Allow model.py to be extended with custom model building functions.
PiperOrigin-RevId: 187941168
上级
307f1f77
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
37 addition
and
10 deletion
+37
-10
research/object_detection/inputs.py
research/object_detection/inputs.py
+4
-4
research/object_detection/model.py
research/object_detection/model.py
+33
-6
未找到文件。
research/object_detection/inputs.py
浏览文件 @
c21d3c25
...
...
@@ -200,8 +200,8 @@ def create_train_input_fn(train_config, train_input_config,
keypoints for each box.
Raises:
TypeError: if the `train_config`
or `train_input_config` are not of the
correct type.
TypeError: if the `train_config`
, `train_input_config` or `model_config`
are not of the
correct type.
"""
if
not
isinstance
(
train_config
,
train_pb2
.
TrainConfig
):
raise
TypeError
(
'For training mode, the `train_config` must be a '
...
...
@@ -316,8 +316,8 @@ def create_eval_input_fn(eval_config, eval_input_config, model_config):
which represent instance masks for objects.
Raises:
TypeError: if the `eval_config`
or `eval_input_config` are not of the
correct type.
TypeError: if the `eval_config`
, `eval_input_config` or `model_config`
are not of the
correct type.
"""
del
params
if
not
isinstance
(
eval_config
,
eval_pb2
.
EvalConfig
):
...
...
research/object_detection/model.py
浏览文件 @
c21d3c25
...
...
@@ -32,6 +32,7 @@ import tensorflow as tf
from
google.protobuf
import
text_format
from
tensorflow.contrib.learn.python.learn
import
learn_runner
from
tensorflow.contrib.tpu.python.tpu
import
tpu_optimizer
from
tensorflow.python.lib.io
import
file_io
from
object_detection
import
eval_util
from
object_detection
import
inputs
from
object_detection
import
model_hparams
...
...
@@ -54,6 +55,20 @@ tf.flags.DEFINE_integer('num_eval_steps', 10000, 'Number of train steps.')
FLAGS
=
tf
.
flags
.
FLAGS
# A map of names to methods that help build the model.
MODEL_BUILD_UTIL_MAP
=
{
'get_configs_from_pipeline_file'
:
config_util
.
get_configs_from_pipeline_file
,
'create_pipeline_proto_from_configs'
:
config_util
.
create_pipeline_proto_from_configs
,
'merge_external_params_with_configs'
:
config_util
.
merge_external_params_with_configs
,
'create_train_input_fn'
:
inputs
.
create_train_input_fn
,
'create_eval_input_fn'
:
inputs
.
create_eval_input_fn
,
'create_predict_input_fn'
:
inputs
.
create_predict_input_fn
,
}
def
_get_groundtruth_data
(
detection_model
,
class_agnostic
):
"""Extracts groundtruth data from detection_model.
...
...
@@ -413,8 +428,18 @@ def populate_experiment(run_config,
An `Experiment` that defines all aspects of training, evaluation, and
export.
"""
configs
=
config_util
.
get_configs_from_pipeline_file
(
pipeline_config_path
)
configs
=
config_util
.
merge_external_params_with_configs
(
get_configs_from_pipeline_file
=
MODEL_BUILD_UTIL_MAP
[
'get_configs_from_pipeline_file'
]
create_pipeline_proto_from_configs
=
MODEL_BUILD_UTIL_MAP
[
'create_pipeline_proto_from_configs'
]
merge_external_params_with_configs
=
MODEL_BUILD_UTIL_MAP
[
'merge_external_params_with_configs'
]
create_train_input_fn
=
MODEL_BUILD_UTIL_MAP
[
'create_train_input_fn'
]
create_eval_input_fn
=
MODEL_BUILD_UTIL_MAP
[
'create_eval_input_fn'
]
create_predict_input_fn
=
MODEL_BUILD_UTIL_MAP
[
'create_predict_input_fn'
]
configs
=
get_configs_from_pipeline_file
(
pipeline_config_path
)
configs
=
merge_external_params_with_configs
(
configs
,
hparams
,
train_steps
=
train_steps
,
...
...
@@ -436,18 +461,18 @@ def populate_experiment(run_config,
model_builder
.
build
,
model_config
=
model_config
)
# Create the input functions for TRAIN/EVAL.
train_input_fn
=
inputs
.
create_train_input_fn
(
train_input_fn
=
create_train_input_fn
(
train_config
=
train_config
,
train_input_config
=
train_input_config
,
model_config
=
model_config
)
eval_input_fn
=
inputs
.
create_eval_input_fn
(
eval_input_fn
=
create_eval_input_fn
(
eval_config
=
eval_config
,
eval_input_config
=
eval_input_config
,
model_config
=
model_config
)
export_strategies
=
[
tf
.
contrib
.
learn
.
utils
.
saved_model_export_utils
.
make_export_strategy
(
serving_input_fn
=
inputs
.
create_predict_input_fn
(
serving_input_fn
=
create_predict_input_fn
(
model_config
=
model_config
))
]
...
...
@@ -457,8 +482,10 @@ def populate_experiment(run_config,
if
run_config
.
is_chief
:
# Store the final pipeline config for traceability.
pipeline_config_final
=
c
onfig_util
.
c
reate_pipeline_proto_from_configs
(
pipeline_config_final
=
create_pipeline_proto_from_configs
(
configs
)
if
not
file_io
.
file_exists
(
estimator
.
model_dir
):
file_io
.
recursive_create_dir
(
estimator
.
model_dir
)
pipeline_config_final_path
=
os
.
path
.
join
(
estimator
.
model_dir
,
'pipeline.config'
)
config_text
=
text_format
.
MessageToString
(
pipeline_config_final
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录