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
b658b16d
Commit
b658b16d
authored
Jul 29, 2020
by
Vivek Rathod
Committed by
TF Object Detection Team
Jul 29, 2020
Browse files
Use BackupHandler from tf_slim instead of OD API's clone.
PiperOrigin-RevId: 323916181
parent
bda18166
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
36 deletions
+2
-36
research/object_detection/data_decoders/tf_example_decoder.py
...arch/object_detection/data_decoders/tf_example_decoder.py
+2
-36
No files found.
research/object_detection/data_decoders/tf_example_decoder.py
View file @
b658b16d
...
@@ -124,40 +124,6 @@ class _ClassTensorHandler(slim_example_decoder.Tensor):
...
@@ -124,40 +124,6 @@ class _ClassTensorHandler(slim_example_decoder.Tensor):
self
.
_display_name_to_id_table
.
lookup
(
unmapped_tensor
))
self
.
_display_name_to_id_table
.
lookup
(
unmapped_tensor
))
class
_BackupHandler
(
slim_example_decoder
.
ItemHandler
):
"""An ItemHandler that tries two ItemHandlers in order."""
def
__init__
(
self
,
handler
,
backup
):
"""Initializes the BackupHandler handler.
If the first Handler's tensors_to_item returns a Tensor with no elements,
the second Handler is used.
Args:
handler: The primary ItemHandler.
backup: The backup ItemHandler.
Raises:
ValueError: if either is not an ItemHandler.
"""
if
not
isinstance
(
handler
,
slim_example_decoder
.
ItemHandler
):
raise
ValueError
(
'Primary handler is of type %s instead of ItemHandler'
%
type
(
handler
))
if
not
isinstance
(
backup
,
slim_example_decoder
.
ItemHandler
):
raise
ValueError
(
'Backup handler is of type %s instead of ItemHandler'
%
type
(
backup
))
self
.
_handler
=
handler
self
.
_backup
=
backup
super
(
_BackupHandler
,
self
).
__init__
(
handler
.
keys
+
backup
.
keys
)
def
tensors_to_item
(
self
,
keys_to_tensors
):
item
=
self
.
_handler
.
tensors_to_item
(
keys_to_tensors
)
return
tf
.
cond
(
pred
=
tf
.
equal
(
tf
.
reduce_prod
(
tf
.
shape
(
item
)),
0
),
true_fn
=
lambda
:
self
.
_backup
.
tensors_to_item
(
keys_to_tensors
),
false_fn
=
lambda
:
item
)
class
TfExampleDecoder
(
data_decoder
.
DataDecoder
):
class
TfExampleDecoder
(
data_decoder
.
DataDecoder
):
"""Tensorflow Example proto decoder."""
"""Tensorflow Example proto decoder."""
...
@@ -405,12 +371,12 @@ class TfExampleDecoder(data_decoder.DataDecoder):
...
@@ -405,12 +371,12 @@ class TfExampleDecoder(data_decoder.DataDecoder):
if
label_map_proto_file
:
if
label_map_proto_file
:
# If the label_map_proto is provided, try to use it in conjunction with
# If the label_map_proto is provided, try to use it in conjunction with
# the class text, and fall back to a materialized ID.
# the class text, and fall back to a materialized ID.
label_handler
=
_
BackupHandler
(
label_handler
=
slim_example_decoder
.
BackupHandler
(
_ClassTensorHandler
(
_ClassTensorHandler
(
'image/object/class/text'
,
label_map_proto_file
,
'image/object/class/text'
,
label_map_proto_file
,
default_value
=
''
),
default_value
=
''
),
slim_example_decoder
.
Tensor
(
'image/object/class/label'
))
slim_example_decoder
.
Tensor
(
'image/object/class/label'
))
image_label_handler
=
_
BackupHandler
(
image_label_handler
=
slim_example_decoder
.
BackupHandler
(
_ClassTensorHandler
(
_ClassTensorHandler
(
fields
.
TfExampleFields
.
image_class_text
,
fields
.
TfExampleFields
.
image_class_text
,
label_map_proto_file
,
label_map_proto_file
,
...
...
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