Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
ResNet50_tensorflow
Commits
cb7e2650
"git@developer.sourcefind.cn:wangsen/mineru.git" did not exist on "559b34375166c3c73122c470e211fecdf51d067d"
Unverified
Commit
cb7e2650
authored
Mar 28, 2022
by
Srihari Humbarwadi
Committed by
GitHub
Mar 28, 2022
Browse files
Merge branch 'tensorflow:master' into panoptic-deeplab
parents
05300091
74582325
Changes
83
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
44 additions
and
56 deletions
+44
-56
research/object_detection/meta_architectures/context_rcnn_lib_tf2_test.py
...detection/meta_architectures/context_rcnn_lib_tf2_test.py
+0
-1
research/object_detection/meta_architectures/faster_rcnn_meta_arch_test.py
...etection/meta_architectures/faster_rcnn_meta_arch_test.py
+0
-1
research/object_detection/meta_architectures/ssd_meta_arch_test.py
...object_detection/meta_architectures/ssd_meta_arch_test.py
+0
-1
research/object_detection/model_lib.py
research/object_detection/model_lib.py
+22
-21
research/object_detection/model_lib_tf1_test.py
research/object_detection/model_lib_tf1_test.py
+16
-15
research/object_detection/model_main.py
research/object_detection/model_main.py
+3
-2
research/object_detection/model_main_tf2.py
research/object_detection/model_main_tf2.py
+0
-1
research/object_detection/model_tpu_main.py
research/object_detection/model_tpu_main.py
+3
-2
research/object_detection/models/embedded_ssd_mobilenet_v1_feature_extractor.py
...ion/models/embedded_ssd_mobilenet_v1_feature_extractor.py
+0
-1
research/object_detection/models/faster_rcnn_nas_feature_extractor.py
...ect_detection/models/faster_rcnn_nas_feature_extractor.py
+0
-1
research/object_detection/models/faster_rcnn_pnas_feature_extractor.py
...ct_detection/models/faster_rcnn_pnas_feature_extractor.py
+0
-1
research/object_detection/models/feature_map_generators.py
research/object_detection/models/feature_map_generators.py
+0
-1
research/object_detection/models/keras_models/inception_resnet_v2_tf2_test.py
...ction/models/keras_models/inception_resnet_v2_tf2_test.py
+0
-1
research/object_detection/models/keras_models/mobilenet_v1_tf2_test.py
...ct_detection/models/keras_models/mobilenet_v1_tf2_test.py
+0
-1
research/object_detection/models/keras_models/mobilenet_v2_tf2_test.py
...ct_detection/models/keras_models/mobilenet_v2_tf2_test.py
+0
-1
research/object_detection/models/ssd_feature_extractor_test.py
...rch/object_detection/models/ssd_feature_extractor_test.py
+0
-1
research/object_detection/models/ssd_inception_v2_feature_extractor.py
...ct_detection/models/ssd_inception_v2_feature_extractor.py
+0
-1
research/object_detection/models/ssd_inception_v3_feature_extractor.py
...ct_detection/models/ssd_inception_v3_feature_extractor.py
+0
-1
research/object_detection/models/ssd_mobilenet_v1_feature_extractor.py
...ct_detection/models/ssd_mobilenet_v1_feature_extractor.py
+0
-1
research/object_detection/models/ssd_mobilenet_v1_fpn_feature_extractor.py
...etection/models/ssd_mobilenet_v1_fpn_feature_extractor.py
+0
-1
No files found.
research/object_detection/meta_architectures/context_rcnn_lib_tf2_test.py
View file @
cb7e2650
# Lint as: python3
# Copyright 2020 The TensorFlow Authors. All Rights Reserved.
# Copyright 2020 The TensorFlow Authors. All Rights Reserved.
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# Licensed under the Apache License, Version 2.0 (the "License");
...
...
research/object_detection/meta_architectures/faster_rcnn_meta_arch_test.py
View file @
cb7e2650
# Lint as: python2, python3
# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# Licensed under the Apache License, Version 2.0 (the "License");
...
...
research/object_detection/meta_architectures/ssd_meta_arch_test.py
View file @
cb7e2650
# Lint as: python2, python3
# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# Licensed under the Apache License, Version 2.0 (the "License");
...
...
research/object_detection/model_lib.py
View file @
cb7e2650
...
@@ -23,6 +23,7 @@ import functools
...
@@ -23,6 +23,7 @@ import functools
import
os
import
os
import
tensorflow.compat.v1
as
tf
import
tensorflow.compat.v1
as
tf
from
tensorflow.compat.v1
import
estimator
as
tf_estimator
import
tensorflow.compat.v2
as
tf2
import
tensorflow.compat.v2
as
tf2
import
tf_slim
as
slim
import
tf_slim
as
slim
...
@@ -465,7 +466,7 @@ def create_model_fn(detection_model_fn, configs, hparams=None, use_tpu=False,
...
@@ -465,7 +466,7 @@ def create_model_fn(detection_model_fn, configs, hparams=None, use_tpu=False,
"""
"""
params
=
params
or
{}
params
=
params
or
{}
total_loss
,
train_op
,
detections
,
export_outputs
=
None
,
None
,
None
,
None
total_loss
,
train_op
,
detections
,
export_outputs
=
None
,
None
,
None
,
None
is_training
=
mode
==
tf
.
estimator
.
ModeKeys
.
TRAIN
is_training
=
mode
==
tf
_
estimator
.
ModeKeys
.
TRAIN
# Make sure to set the Keras learning phase. True during training,
# Make sure to set the Keras learning phase. True during training,
# False for inference.
# False for inference.
...
@@ -479,11 +480,11 @@ def create_model_fn(detection_model_fn, configs, hparams=None, use_tpu=False,
...
@@ -479,11 +480,11 @@ def create_model_fn(detection_model_fn, configs, hparams=None, use_tpu=False,
is_training
=
is_training
,
add_summaries
=
(
not
use_tpu
))
is_training
=
is_training
,
add_summaries
=
(
not
use_tpu
))
scaffold_fn
=
None
scaffold_fn
=
None
if
mode
==
tf
.
estimator
.
ModeKeys
.
TRAIN
:
if
mode
==
tf
_
estimator
.
ModeKeys
.
TRAIN
:
labels
=
unstack_batch
(
labels
=
unstack_batch
(
labels
,
labels
,
unpad_groundtruth_tensors
=
train_config
.
unpad_groundtruth_tensors
)
unpad_groundtruth_tensors
=
train_config
.
unpad_groundtruth_tensors
)
elif
mode
==
tf
.
estimator
.
ModeKeys
.
EVAL
:
elif
mode
==
tf
_
estimator
.
ModeKeys
.
EVAL
:
# For evaling on train data, it is necessary to check whether groundtruth
# For evaling on train data, it is necessary to check whether groundtruth
# must be unpadded.
# must be unpadded.
boxes_shape
=
(
boxes_shape
=
(
...
@@ -493,7 +494,7 @@ def create_model_fn(detection_model_fn, configs, hparams=None, use_tpu=False,
...
@@ -493,7 +494,7 @@ def create_model_fn(detection_model_fn, configs, hparams=None, use_tpu=False,
labels
=
unstack_batch
(
labels
=
unstack_batch
(
labels
,
unpad_groundtruth_tensors
=
unpad_groundtruth_tensors
)
labels
,
unpad_groundtruth_tensors
=
unpad_groundtruth_tensors
)
if
mode
in
(
tf
.
estimator
.
ModeKeys
.
TRAIN
,
tf
.
estimator
.
ModeKeys
.
EVAL
):
if
mode
in
(
tf
_
estimator
.
ModeKeys
.
TRAIN
,
tf
_
estimator
.
ModeKeys
.
EVAL
):
provide_groundtruth
(
detection_model
,
labels
)
provide_groundtruth
(
detection_model
,
labels
)
preprocessed_images
=
features
[
fields
.
InputDataFields
.
image
]
preprocessed_images
=
features
[
fields
.
InputDataFields
.
image
]
...
@@ -514,7 +515,7 @@ def create_model_fn(detection_model_fn, configs, hparams=None, use_tpu=False,
...
@@ -514,7 +515,7 @@ def create_model_fn(detection_model_fn, configs, hparams=None, use_tpu=False,
def
postprocess_wrapper
(
args
):
def
postprocess_wrapper
(
args
):
return
detection_model
.
postprocess
(
args
[
0
],
args
[
1
])
return
detection_model
.
postprocess
(
args
[
0
],
args
[
1
])
if
mode
in
(
tf
.
estimator
.
ModeKeys
.
EVAL
,
tf
.
estimator
.
ModeKeys
.
PREDICT
):
if
mode
in
(
tf
_
estimator
.
ModeKeys
.
EVAL
,
tf
_
estimator
.
ModeKeys
.
PREDICT
):
if
use_tpu
and
postprocess_on_cpu
:
if
use_tpu
and
postprocess_on_cpu
:
detections
=
tf
.
tpu
.
outside_compilation
(
detections
=
tf
.
tpu
.
outside_compilation
(
postprocess_wrapper
,
postprocess_wrapper
,
...
@@ -525,7 +526,7 @@ def create_model_fn(detection_model_fn, configs, hparams=None, use_tpu=False,
...
@@ -525,7 +526,7 @@ def create_model_fn(detection_model_fn, configs, hparams=None, use_tpu=False,
prediction_dict
,
prediction_dict
,
features
[
fields
.
InputDataFields
.
true_image_shape
]))
features
[
fields
.
InputDataFields
.
true_image_shape
]))
if
mode
==
tf
.
estimator
.
ModeKeys
.
TRAIN
:
if
mode
==
tf
_
estimator
.
ModeKeys
.
TRAIN
:
load_pretrained
=
hparams
.
load_pretrained
if
hparams
else
False
load_pretrained
=
hparams
.
load_pretrained
if
hparams
else
False
if
train_config
.
fine_tune_checkpoint
and
load_pretrained
:
if
train_config
.
fine_tune_checkpoint
and
load_pretrained
:
if
not
train_config
.
fine_tune_checkpoint_type
:
if
not
train_config
.
fine_tune_checkpoint_type
:
...
@@ -557,8 +558,8 @@ def create_model_fn(detection_model_fn, configs, hparams=None, use_tpu=False,
...
@@ -557,8 +558,8 @@ def create_model_fn(detection_model_fn, configs, hparams=None, use_tpu=False,
tf
.
train
.
init_from_checkpoint
(
train_config
.
fine_tune_checkpoint
,
tf
.
train
.
init_from_checkpoint
(
train_config
.
fine_tune_checkpoint
,
available_var_map
)
available_var_map
)
if
mode
in
(
tf
.
estimator
.
ModeKeys
.
TRAIN
,
tf
.
estimator
.
ModeKeys
.
EVAL
):
if
mode
in
(
tf
_
estimator
.
ModeKeys
.
TRAIN
,
tf
_
estimator
.
ModeKeys
.
EVAL
):
if
(
mode
==
tf
.
estimator
.
ModeKeys
.
EVAL
and
if
(
mode
==
tf
_
estimator
.
ModeKeys
.
EVAL
and
eval_config
.
use_dummy_loss_in_eval
):
eval_config
.
use_dummy_loss_in_eval
):
total_loss
=
tf
.
constant
(
1.0
)
total_loss
=
tf
.
constant
(
1.0
)
losses_dict
=
{
'Loss/total_loss'
:
total_loss
}
losses_dict
=
{
'Loss/total_loss'
:
total_loss
}
...
@@ -590,7 +591,7 @@ def create_model_fn(detection_model_fn, configs, hparams=None, use_tpu=False,
...
@@ -590,7 +591,7 @@ def create_model_fn(detection_model_fn, configs, hparams=None, use_tpu=False,
training_optimizer
,
optimizer_summary_vars
=
optimizer_builder
.
build
(
training_optimizer
,
optimizer_summary_vars
=
optimizer_builder
.
build
(
train_config
.
optimizer
)
train_config
.
optimizer
)
if
mode
==
tf
.
estimator
.
ModeKeys
.
TRAIN
:
if
mode
==
tf
_
estimator
.
ModeKeys
.
TRAIN
:
if
use_tpu
:
if
use_tpu
:
training_optimizer
=
tf
.
tpu
.
CrossShardOptimizer
(
training_optimizer
)
training_optimizer
=
tf
.
tpu
.
CrossShardOptimizer
(
training_optimizer
)
...
@@ -628,16 +629,16 @@ def create_model_fn(detection_model_fn, configs, hparams=None, use_tpu=False,
...
@@ -628,16 +629,16 @@ def create_model_fn(detection_model_fn, configs, hparams=None, use_tpu=False,
summaries
=
summaries
,
summaries
=
summaries
,
name
=
''
)
# Preventing scope prefix on all variables.
name
=
''
)
# Preventing scope prefix on all variables.
if
mode
==
tf
.
estimator
.
ModeKeys
.
PREDICT
:
if
mode
==
tf
_
estimator
.
ModeKeys
.
PREDICT
:
exported_output
=
exporter_lib
.
add_output_tensor_nodes
(
detections
)
exported_output
=
exporter_lib
.
add_output_tensor_nodes
(
detections
)
export_outputs
=
{
export_outputs
=
{
tf
.
saved_model
.
signature_constants
.
PREDICT_METHOD_NAME
:
tf
.
saved_model
.
signature_constants
.
PREDICT_METHOD_NAME
:
tf
.
estimator
.
export
.
PredictOutput
(
exported_output
)
tf
_
estimator
.
export
.
PredictOutput
(
exported_output
)
}
}
eval_metric_ops
=
None
eval_metric_ops
=
None
scaffold
=
None
scaffold
=
None
if
mode
==
tf
.
estimator
.
ModeKeys
.
EVAL
:
if
mode
==
tf
_
estimator
.
ModeKeys
.
EVAL
:
class_agnostic
=
(
class_agnostic
=
(
fields
.
DetectionResultFields
.
detection_classes
not
in
detections
)
fields
.
DetectionResultFields
.
detection_classes
not
in
detections
)
groundtruth
=
_prepare_groundtruth_for_eval
(
groundtruth
=
_prepare_groundtruth_for_eval
(
...
@@ -711,8 +712,8 @@ def create_model_fn(detection_model_fn, configs, hparams=None, use_tpu=False,
...
@@ -711,8 +712,8 @@ def create_model_fn(detection_model_fn, configs, hparams=None, use_tpu=False,
scaffold
=
tf
.
train
.
Scaffold
(
saver
=
saver
)
scaffold
=
tf
.
train
.
Scaffold
(
saver
=
saver
)
# EVAL executes on CPU, so use regular non-TPU EstimatorSpec.
# EVAL executes on CPU, so use regular non-TPU EstimatorSpec.
if
use_tpu
and
mode
!=
tf
.
estimator
.
ModeKeys
.
EVAL
:
if
use_tpu
and
mode
!=
tf
_
estimator
.
ModeKeys
.
EVAL
:
return
tf
.
estimator
.
tpu
.
TPUEstimatorSpec
(
return
tf
_
estimator
.
tpu
.
TPUEstimatorSpec
(
mode
=
mode
,
mode
=
mode
,
scaffold_fn
=
scaffold_fn
,
scaffold_fn
=
scaffold_fn
,
predictions
=
detections
,
predictions
=
detections
,
...
@@ -730,7 +731,7 @@ def create_model_fn(detection_model_fn, configs, hparams=None, use_tpu=False,
...
@@ -730,7 +731,7 @@ def create_model_fn(detection_model_fn, configs, hparams=None, use_tpu=False,
save_relative_paths
=
True
)
save_relative_paths
=
True
)
tf
.
add_to_collection
(
tf
.
GraphKeys
.
SAVERS
,
saver
)
tf
.
add_to_collection
(
tf
.
GraphKeys
.
SAVERS
,
saver
)
scaffold
=
tf
.
train
.
Scaffold
(
saver
=
saver
)
scaffold
=
tf
.
train
.
Scaffold
(
saver
=
saver
)
return
tf
.
estimator
.
EstimatorSpec
(
return
tf
_
estimator
.
EstimatorSpec
(
mode
=
mode
,
mode
=
mode
,
predictions
=
detections
,
predictions
=
detections
,
loss
=
total_loss
,
loss
=
total_loss
,
...
@@ -895,7 +896,7 @@ def create_estimator_and_inputs(run_config,
...
@@ -895,7 +896,7 @@ def create_estimator_and_inputs(run_config,
model_fn
=
model_fn_creator
(
detection_model_fn
,
configs
,
hparams
,
use_tpu
,
model_fn
=
model_fn_creator
(
detection_model_fn
,
configs
,
hparams
,
use_tpu
,
postprocess_on_cpu
)
postprocess_on_cpu
)
if
use_tpu_estimator
:
if
use_tpu_estimator
:
estimator
=
tf
.
estimator
.
tpu
.
TPUEstimator
(
estimator
=
tf
_
estimator
.
tpu
.
TPUEstimator
(
model_fn
=
model_fn
,
model_fn
=
model_fn
,
train_batch_size
=
train_config
.
batch_size
,
train_batch_size
=
train_config
.
batch_size
,
# For each core, only batch size 1 is supported for eval.
# For each core, only batch size 1 is supported for eval.
...
@@ -906,7 +907,7 @@ def create_estimator_and_inputs(run_config,
...
@@ -906,7 +907,7 @@ def create_estimator_and_inputs(run_config,
eval_on_tpu
=
False
,
# Eval runs on CPU, so disable eval on TPU
eval_on_tpu
=
False
,
# Eval runs on CPU, so disable eval on TPU
params
=
params
if
params
else
{})
params
=
params
if
params
else
{})
else
:
else
:
estimator
=
tf
.
estimator
.
Estimator
(
model_fn
=
model_fn
,
config
=
run_config
)
estimator
=
tf
_
estimator
.
Estimator
(
model_fn
=
model_fn
,
config
=
run_config
)
# Write the as-run pipeline config to disk.
# Write the as-run pipeline config to disk.
if
run_config
.
is_chief
and
save_final_config
:
if
run_config
.
is_chief
and
save_final_config
:
...
@@ -951,7 +952,7 @@ def create_train_and_eval_specs(train_input_fn,
...
@@ -951,7 +952,7 @@ def create_train_and_eval_specs(train_input_fn,
True, the last `EvalSpec` in the list will correspond to training data. The
True, the last `EvalSpec` in the list will correspond to training data. The
rest EvalSpecs in the list are evaluation datas.
rest EvalSpecs in the list are evaluation datas.
"""
"""
train_spec
=
tf
.
estimator
.
TrainSpec
(
train_spec
=
tf
_
estimator
.
TrainSpec
(
input_fn
=
train_input_fn
,
max_steps
=
train_steps
)
input_fn
=
train_input_fn
,
max_steps
=
train_steps
)
if
eval_spec_names
is
None
:
if
eval_spec_names
is
None
:
...
@@ -966,10 +967,10 @@ def create_train_and_eval_specs(train_input_fn,
...
@@ -966,10 +967,10 @@ def create_train_and_eval_specs(train_input_fn,
exporter_name
=
final_exporter_name
exporter_name
=
final_exporter_name
else
:
else
:
exporter_name
=
'{}_{}'
.
format
(
final_exporter_name
,
eval_spec_name
)
exporter_name
=
'{}_{}'
.
format
(
final_exporter_name
,
eval_spec_name
)
exporter
=
tf
.
estimator
.
FinalExporter
(
exporter
=
tf
_
estimator
.
FinalExporter
(
name
=
exporter_name
,
serving_input_receiver_fn
=
predict_input_fn
)
name
=
exporter_name
,
serving_input_receiver_fn
=
predict_input_fn
)
eval_specs
.
append
(
eval_specs
.
append
(
tf
.
estimator
.
EvalSpec
(
tf
_
estimator
.
EvalSpec
(
name
=
eval_spec_name
,
name
=
eval_spec_name
,
input_fn
=
eval_input_fn
,
input_fn
=
eval_input_fn
,
steps
=
None
,
steps
=
None
,
...
@@ -977,7 +978,7 @@ def create_train_and_eval_specs(train_input_fn,
...
@@ -977,7 +978,7 @@ def create_train_and_eval_specs(train_input_fn,
if
eval_on_train_data
:
if
eval_on_train_data
:
eval_specs
.
append
(
eval_specs
.
append
(
tf
.
estimator
.
EvalSpec
(
tf
_
estimator
.
EvalSpec
(
name
=
'eval_on_train'
,
input_fn
=
eval_on_train_input_fn
,
steps
=
None
))
name
=
'eval_on_train'
,
input_fn
=
eval_on_train_input_fn
,
steps
=
None
))
return
train_spec
,
eval_specs
return
train_spec
,
eval_specs
...
...
research/object_detection/model_lib_tf1_test.py
View file @
cb7e2650
...
@@ -23,6 +23,7 @@ import os
...
@@ -23,6 +23,7 @@ import os
import
unittest
import
unittest
import
numpy
as
np
import
numpy
as
np
import
tensorflow.compat.v1
as
tf
import
tensorflow.compat.v1
as
tf
from
tensorflow.compat.v1
import
estimator
as
tf_estimator
from
object_detection
import
inputs
from
object_detection
import
inputs
from
object_detection
import
model_hparams
from
object_detection
import
model_hparams
...
@@ -137,21 +138,21 @@ class ModelLibTest(tf.test.TestCase):
...
@@ -137,21 +138,21 @@ class ModelLibTest(tf.test.TestCase):
inputs
.
create_train_input_fn
(
configs
[
'train_config'
],
inputs
.
create_train_input_fn
(
configs
[
'train_config'
],
configs
[
'train_input_config'
],
configs
[
'train_input_config'
],
configs
[
'model'
])()).
get_next
()
configs
[
'model'
])()).
get_next
()
model_mode
=
tf
.
estimator
.
ModeKeys
.
TRAIN
model_mode
=
tf
_
estimator
.
ModeKeys
.
TRAIN
batch_size
=
train_config
.
batch_size
batch_size
=
train_config
.
batch_size
elif
mode
==
'eval'
:
elif
mode
==
'eval'
:
features
,
labels
=
_make_initializable_iterator
(
features
,
labels
=
_make_initializable_iterator
(
inputs
.
create_eval_input_fn
(
configs
[
'eval_config'
],
inputs
.
create_eval_input_fn
(
configs
[
'eval_config'
],
configs
[
'eval_input_config'
],
configs
[
'eval_input_config'
],
configs
[
'model'
])()).
get_next
()
configs
[
'model'
])()).
get_next
()
model_mode
=
tf
.
estimator
.
ModeKeys
.
EVAL
model_mode
=
tf
_
estimator
.
ModeKeys
.
EVAL
batch_size
=
1
batch_size
=
1
elif
mode
==
'eval_on_train'
:
elif
mode
==
'eval_on_train'
:
features
,
labels
=
_make_initializable_iterator
(
features
,
labels
=
_make_initializable_iterator
(
inputs
.
create_eval_input_fn
(
configs
[
'eval_config'
],
inputs
.
create_eval_input_fn
(
configs
[
'eval_config'
],
configs
[
'train_input_config'
],
configs
[
'train_input_config'
],
configs
[
'model'
])()).
get_next
()
configs
[
'model'
])()).
get_next
()
model_mode
=
tf
.
estimator
.
ModeKeys
.
EVAL
model_mode
=
tf
_
estimator
.
ModeKeys
.
EVAL
batch_size
=
1
batch_size
=
1
detection_model_fn
=
functools
.
partial
(
detection_model_fn
=
functools
.
partial
(
...
@@ -183,7 +184,7 @@ class ModelLibTest(tf.test.TestCase):
...
@@ -183,7 +184,7 @@ class ModelLibTest(tf.test.TestCase):
if
mode
==
'eval'
:
if
mode
==
'eval'
:
self
.
assertIn
(
'Detections_Left_Groundtruth_Right/0'
,
self
.
assertIn
(
'Detections_Left_Groundtruth_Right/0'
,
estimator_spec
.
eval_metric_ops
)
estimator_spec
.
eval_metric_ops
)
if
model_mode
==
tf
.
estimator
.
ModeKeys
.
TRAIN
:
if
model_mode
==
tf
_
estimator
.
ModeKeys
.
TRAIN
:
self
.
assertIsNotNone
(
estimator_spec
.
train_op
)
self
.
assertIsNotNone
(
estimator_spec
.
train_op
)
return
estimator_spec
return
estimator_spec
...
@@ -202,7 +203,7 @@ class ModelLibTest(tf.test.TestCase):
...
@@ -202,7 +203,7 @@ class ModelLibTest(tf.test.TestCase):
hparams_overrides
=
'load_pretrained=false'
)
hparams_overrides
=
'load_pretrained=false'
)
model_fn
=
model_lib
.
create_model_fn
(
detection_model_fn
,
configs
,
hparams
)
model_fn
=
model_lib
.
create_model_fn
(
detection_model_fn
,
configs
,
hparams
)
estimator_spec
=
model_fn
(
features
,
None
,
tf
.
estimator
.
ModeKeys
.
PREDICT
)
estimator_spec
=
model_fn
(
features
,
None
,
tf
_
estimator
.
ModeKeys
.
PREDICT
)
self
.
assertIsNone
(
estimator_spec
.
loss
)
self
.
assertIsNone
(
estimator_spec
.
loss
)
self
.
assertIsNone
(
estimator_spec
.
train_op
)
self
.
assertIsNone
(
estimator_spec
.
train_op
)
...
@@ -279,7 +280,7 @@ class ModelLibTest(tf.test.TestCase):
...
@@ -279,7 +280,7 @@ class ModelLibTest(tf.test.TestCase):
def
test_create_estimator_and_inputs
(
self
):
def
test_create_estimator_and_inputs
(
self
):
"""Tests that Estimator and input function are constructed correctly."""
"""Tests that Estimator and input function are constructed correctly."""
run_config
=
tf
.
estimator
.
RunConfig
()
run_config
=
tf
_
estimator
.
RunConfig
()
hparams
=
model_hparams
.
create_hparams
(
hparams
=
model_hparams
.
create_hparams
(
hparams_overrides
=
'load_pretrained=false'
)
hparams_overrides
=
'load_pretrained=false'
)
pipeline_config_path
=
get_pipeline_config_path
(
MODEL_NAME_FOR_TEST
)
pipeline_config_path
=
get_pipeline_config_path
(
MODEL_NAME_FOR_TEST
)
...
@@ -291,7 +292,7 @@ class ModelLibTest(tf.test.TestCase):
...
@@ -291,7 +292,7 @@ class ModelLibTest(tf.test.TestCase):
train_steps
=
train_steps
)
train_steps
=
train_steps
)
estimator
=
train_and_eval_dict
[
'estimator'
]
estimator
=
train_and_eval_dict
[
'estimator'
]
train_steps
=
train_and_eval_dict
[
'train_steps'
]
train_steps
=
train_and_eval_dict
[
'train_steps'
]
self
.
assertIsInstance
(
estimator
,
tf
.
estimator
.
Estimator
)
self
.
assertIsInstance
(
estimator
,
tf
_
estimator
.
Estimator
)
self
.
assertEqual
(
20
,
train_steps
)
self
.
assertEqual
(
20
,
train_steps
)
self
.
assertIn
(
'train_input_fn'
,
train_and_eval_dict
)
self
.
assertIn
(
'train_input_fn'
,
train_and_eval_dict
)
self
.
assertIn
(
'eval_input_fns'
,
train_and_eval_dict
)
self
.
assertIn
(
'eval_input_fns'
,
train_and_eval_dict
)
...
@@ -299,7 +300,7 @@ class ModelLibTest(tf.test.TestCase):
...
@@ -299,7 +300,7 @@ class ModelLibTest(tf.test.TestCase):
def
test_create_estimator_and_inputs_sequence_example
(
self
):
def
test_create_estimator_and_inputs_sequence_example
(
self
):
"""Tests that Estimator and input function are constructed correctly."""
"""Tests that Estimator and input function are constructed correctly."""
run_config
=
tf
.
estimator
.
RunConfig
()
run_config
=
tf
_
estimator
.
RunConfig
()
hparams
=
model_hparams
.
create_hparams
(
hparams
=
model_hparams
.
create_hparams
(
hparams_overrides
=
'load_pretrained=false'
)
hparams_overrides
=
'load_pretrained=false'
)
pipeline_config_path
=
get_pipeline_config_path
(
pipeline_config_path
=
get_pipeline_config_path
(
...
@@ -312,7 +313,7 @@ class ModelLibTest(tf.test.TestCase):
...
@@ -312,7 +313,7 @@ class ModelLibTest(tf.test.TestCase):
train_steps
=
train_steps
)
train_steps
=
train_steps
)
estimator
=
train_and_eval_dict
[
'estimator'
]
estimator
=
train_and_eval_dict
[
'estimator'
]
train_steps
=
train_and_eval_dict
[
'train_steps'
]
train_steps
=
train_and_eval_dict
[
'train_steps'
]
self
.
assertIsInstance
(
estimator
,
tf
.
estimator
.
Estimator
)
self
.
assertIsInstance
(
estimator
,
tf
_
estimator
.
Estimator
)
self
.
assertEqual
(
20
,
train_steps
)
self
.
assertEqual
(
20
,
train_steps
)
self
.
assertIn
(
'train_input_fn'
,
train_and_eval_dict
)
self
.
assertIn
(
'train_input_fn'
,
train_and_eval_dict
)
self
.
assertIn
(
'eval_input_fns'
,
train_and_eval_dict
)
self
.
assertIn
(
'eval_input_fns'
,
train_and_eval_dict
)
...
@@ -320,7 +321,7 @@ class ModelLibTest(tf.test.TestCase):
...
@@ -320,7 +321,7 @@ class ModelLibTest(tf.test.TestCase):
def
test_create_estimator_with_default_train_eval_steps
(
self
):
def
test_create_estimator_with_default_train_eval_steps
(
self
):
"""Tests that number of train/eval defaults to config values."""
"""Tests that number of train/eval defaults to config values."""
run_config
=
tf
.
estimator
.
RunConfig
()
run_config
=
tf
_
estimator
.
RunConfig
()
hparams
=
model_hparams
.
create_hparams
(
hparams
=
model_hparams
.
create_hparams
(
hparams_overrides
=
'load_pretrained=false'
)
hparams_overrides
=
'load_pretrained=false'
)
pipeline_config_path
=
get_pipeline_config_path
(
MODEL_NAME_FOR_TEST
)
pipeline_config_path
=
get_pipeline_config_path
(
MODEL_NAME_FOR_TEST
)
...
@@ -331,12 +332,12 @@ class ModelLibTest(tf.test.TestCase):
...
@@ -331,12 +332,12 @@ class ModelLibTest(tf.test.TestCase):
estimator
=
train_and_eval_dict
[
'estimator'
]
estimator
=
train_and_eval_dict
[
'estimator'
]
train_steps
=
train_and_eval_dict
[
'train_steps'
]
train_steps
=
train_and_eval_dict
[
'train_steps'
]
self
.
assertIsInstance
(
estimator
,
tf
.
estimator
.
Estimator
)
self
.
assertIsInstance
(
estimator
,
tf
_
estimator
.
Estimator
)
self
.
assertEqual
(
config_train_steps
,
train_steps
)
self
.
assertEqual
(
config_train_steps
,
train_steps
)
def
test_create_tpu_estimator_and_inputs
(
self
):
def
test_create_tpu_estimator_and_inputs
(
self
):
"""Tests that number of train/eval defaults to config values."""
"""Tests that number of train/eval defaults to config values."""
run_config
=
tf
.
estimator
.
tpu
.
RunConfig
()
run_config
=
tf
_
estimator
.
tpu
.
RunConfig
()
hparams
=
model_hparams
.
create_hparams
(
hparams
=
model_hparams
.
create_hparams
(
hparams_overrides
=
'load_pretrained=false'
)
hparams_overrides
=
'load_pretrained=false'
)
pipeline_config_path
=
get_pipeline_config_path
(
MODEL_NAME_FOR_TEST
)
pipeline_config_path
=
get_pipeline_config_path
(
MODEL_NAME_FOR_TEST
)
...
@@ -350,12 +351,12 @@ class ModelLibTest(tf.test.TestCase):
...
@@ -350,12 +351,12 @@ class ModelLibTest(tf.test.TestCase):
estimator
=
train_and_eval_dict
[
'estimator'
]
estimator
=
train_and_eval_dict
[
'estimator'
]
train_steps
=
train_and_eval_dict
[
'train_steps'
]
train_steps
=
train_and_eval_dict
[
'train_steps'
]
self
.
assertIsInstance
(
estimator
,
tf
.
estimator
.
tpu
.
TPUEstimator
)
self
.
assertIsInstance
(
estimator
,
tf
_
estimator
.
tpu
.
TPUEstimator
)
self
.
assertEqual
(
20
,
train_steps
)
self
.
assertEqual
(
20
,
train_steps
)
def
test_create_train_and_eval_specs
(
self
):
def
test_create_train_and_eval_specs
(
self
):
"""Tests that `TrainSpec` and `EvalSpec` is created correctly."""
"""Tests that `TrainSpec` and `EvalSpec` is created correctly."""
run_config
=
tf
.
estimator
.
RunConfig
()
run_config
=
tf
_
estimator
.
RunConfig
()
hparams
=
model_hparams
.
create_hparams
(
hparams
=
model_hparams
.
create_hparams
(
hparams_overrides
=
'load_pretrained=false'
)
hparams_overrides
=
'load_pretrained=false'
)
pipeline_config_path
=
get_pipeline_config_path
(
MODEL_NAME_FOR_TEST
)
pipeline_config_path
=
get_pipeline_config_path
(
MODEL_NAME_FOR_TEST
)
...
@@ -390,7 +391,7 @@ class ModelLibTest(tf.test.TestCase):
...
@@ -390,7 +391,7 @@ class ModelLibTest(tf.test.TestCase):
def
test_experiment
(
self
):
def
test_experiment
(
self
):
"""Tests that the `Experiment` object is constructed correctly."""
"""Tests that the `Experiment` object is constructed correctly."""
run_config
=
tf
.
estimator
.
RunConfig
()
run_config
=
tf
_
estimator
.
RunConfig
()
hparams
=
model_hparams
.
create_hparams
(
hparams
=
model_hparams
.
create_hparams
(
hparams_overrides
=
'load_pretrained=false'
)
hparams_overrides
=
'load_pretrained=false'
)
pipeline_config_path
=
get_pipeline_config_path
(
MODEL_NAME_FOR_TEST
)
pipeline_config_path
=
get_pipeline_config_path
(
MODEL_NAME_FOR_TEST
)
...
...
research/object_detection/model_main.py
View file @
cb7e2650
...
@@ -21,6 +21,7 @@ from __future__ import print_function
...
@@ -21,6 +21,7 @@ from __future__ import print_function
from
absl
import
flags
from
absl
import
flags
import
tensorflow.compat.v1
as
tf
import
tensorflow.compat.v1
as
tf
from
tensorflow.compat.v1
import
estimator
as
tf_estimator
from
object_detection
import
model_lib
from
object_detection
import
model_lib
...
@@ -59,7 +60,7 @@ FLAGS = flags.FLAGS
...
@@ -59,7 +60,7 @@ FLAGS = flags.FLAGS
def
main
(
unused_argv
):
def
main
(
unused_argv
):
flags
.
mark_flag_as_required
(
'model_dir'
)
flags
.
mark_flag_as_required
(
'model_dir'
)
flags
.
mark_flag_as_required
(
'pipeline_config_path'
)
flags
.
mark_flag_as_required
(
'pipeline_config_path'
)
config
=
tf
.
estimator
.
RunConfig
(
model_dir
=
FLAGS
.
model_dir
)
config
=
tf
_
estimator
.
RunConfig
(
model_dir
=
FLAGS
.
model_dir
)
train_and_eval_dict
=
model_lib
.
create_estimator_and_inputs
(
train_and_eval_dict
=
model_lib
.
create_estimator_and_inputs
(
run_config
=
config
,
run_config
=
config
,
...
@@ -101,7 +102,7 @@ def main(unused_argv):
...
@@ -101,7 +102,7 @@ def main(unused_argv):
eval_on_train_data
=
False
)
eval_on_train_data
=
False
)
# Currently only a single Eval Spec is allowed.
# Currently only a single Eval Spec is allowed.
tf
.
estimator
.
train_and_evaluate
(
estimator
,
train_spec
,
eval_specs
[
0
])
tf
_
estimator
.
train_and_evaluate
(
estimator
,
train_spec
,
eval_specs
[
0
])
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
research/object_detection/model_main_tf2.py
View file @
cb7e2650
# Lint as: python3
# Copyright 2020 The TensorFlow Authors. All Rights Reserved.
# Copyright 2020 The TensorFlow Authors. All Rights Reserved.
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# Licensed under the Apache License, Version 2.0 (the "License");
...
...
research/object_detection/model_tpu_main.py
View file @
cb7e2650
...
@@ -24,6 +24,7 @@ from __future__ import print_function
...
@@ -24,6 +24,7 @@ from __future__ import print_function
from
absl
import
flags
from
absl
import
flags
import
tensorflow.compat.v1
as
tf
import
tensorflow.compat.v1
as
tf
from
tensorflow.compat.v1
import
estimator
as
tf_estimator
from
object_detection
import
model_lib
from
object_detection
import
model_lib
...
@@ -89,11 +90,11 @@ def main(unused_argv):
...
@@ -89,11 +90,11 @@ def main(unused_argv):
tpu
=
[
FLAGS
.
tpu_name
],
zone
=
FLAGS
.
tpu_zone
,
project
=
FLAGS
.
gcp_project
))
tpu
=
[
FLAGS
.
tpu_name
],
zone
=
FLAGS
.
tpu_zone
,
project
=
FLAGS
.
gcp_project
))
tpu_grpc_url
=
tpu_cluster_resolver
.
get_master
()
tpu_grpc_url
=
tpu_cluster_resolver
.
get_master
()
config
=
tf
.
estimator
.
tpu
.
RunConfig
(
config
=
tf
_
estimator
.
tpu
.
RunConfig
(
master
=
tpu_grpc_url
,
master
=
tpu_grpc_url
,
evaluation_master
=
tpu_grpc_url
,
evaluation_master
=
tpu_grpc_url
,
model_dir
=
FLAGS
.
model_dir
,
model_dir
=
FLAGS
.
model_dir
,
tpu_config
=
tf
.
estimator
.
tpu
.
TPUConfig
(
tpu_config
=
tf
_
estimator
.
tpu
.
TPUConfig
(
iterations_per_loop
=
FLAGS
.
iterations_per_loop
,
iterations_per_loop
=
FLAGS
.
iterations_per_loop
,
num_shards
=
FLAGS
.
num_shards
))
num_shards
=
FLAGS
.
num_shards
))
...
...
research/object_detection/models/embedded_ssd_mobilenet_v1_feature_extractor.py
View file @
cb7e2650
# Lint as: python2, python3
# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# Licensed under the Apache License, Version 2.0 (the "License");
...
...
research/object_detection/models/faster_rcnn_nas_feature_extractor.py
View file @
cb7e2650
# Lint as: python2, python3
# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# Licensed under the Apache License, Version 2.0 (the "License");
...
...
research/object_detection/models/faster_rcnn_pnas_feature_extractor.py
View file @
cb7e2650
# Lint as: python2, python3
# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# Licensed under the Apache License, Version 2.0 (the "License");
...
...
research/object_detection/models/feature_map_generators.py
View file @
cb7e2650
# Lint as: python2, python3
# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# Licensed under the Apache License, Version 2.0 (the "License");
...
...
research/object_detection/models/keras_models/inception_resnet_v2_tf2_test.py
View file @
cb7e2650
# Lint as: python2, python3
# Copyright 2019 The TensorFlow Authors. All Rights Reserved.
# Copyright 2019 The TensorFlow Authors. All Rights Reserved.
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# Licensed under the Apache License, Version 2.0 (the "License");
...
...
research/object_detection/models/keras_models/mobilenet_v1_tf2_test.py
View file @
cb7e2650
# Lint as: python2, python3
# Copyright 2018 The TensorFlow Authors. All Rights Reserved.
# Copyright 2018 The TensorFlow Authors. All Rights Reserved.
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# Licensed under the Apache License, Version 2.0 (the "License");
...
...
research/object_detection/models/keras_models/mobilenet_v2_tf2_test.py
View file @
cb7e2650
# Lint as: python2, python3
# Copyright 2018 The TensorFlow Authors. All Rights Reserved.
# Copyright 2018 The TensorFlow Authors. All Rights Reserved.
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# Licensed under the Apache License, Version 2.0 (the "License");
...
...
research/object_detection/models/ssd_feature_extractor_test.py
View file @
cb7e2650
# Lint as: python2, python3
# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# Licensed under the Apache License, Version 2.0 (the "License");
...
...
research/object_detection/models/ssd_inception_v2_feature_extractor.py
View file @
cb7e2650
# Lint as: python2, python3
# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# Licensed under the Apache License, Version 2.0 (the "License");
...
...
research/object_detection/models/ssd_inception_v3_feature_extractor.py
View file @
cb7e2650
# Lint as: python2, python3
# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# Licensed under the Apache License, Version 2.0 (the "License");
...
...
research/object_detection/models/ssd_mobilenet_v1_feature_extractor.py
View file @
cb7e2650
# Lint as: python2, python3
# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# Licensed under the Apache License, Version 2.0 (the "License");
...
...
research/object_detection/models/ssd_mobilenet_v1_fpn_feature_extractor.py
View file @
cb7e2650
# Lint as: python2, python3
# Copyright 2018 The TensorFlow Authors. All Rights Reserved.
# Copyright 2018 The TensorFlow Authors. All Rights Reserved.
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# Licensed under the Apache License, Version 2.0 (the "License");
...
...
Prev
1
2
3
4
5
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment