Skip to content

Change key of type 'tuple' to 'str' #1593

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 29, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions object_detection/core/batcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

from object_detection.core import prefetcher

rt_shape_str = '_runtime_shapes'


class BatchQueue(object):
"""BatchQueue class.
Expand Down Expand Up @@ -81,8 +83,9 @@ def __init__(self, tensor_dict, batch_size, batch_queue_capacity,
{key: tensor.get_shape() for key, tensor in tensor_dict.items()})
# Remember runtime shapes to unpad tensors after batching.
runtime_shapes = collections.OrderedDict(
{(key, 'runtime_shapes'): tf.shape(tensor)
for key, tensor in tensor_dict.items()})
{(key + rt_shape_str): tf.shape(tensor)
for key, tensor in tensor_dict.iteritems()})

all_tensors = tensor_dict
all_tensors.update(runtime_shapes)
batched_tensors = tf.train.batch(
Expand Down Expand Up @@ -112,8 +115,8 @@ def dequeue(self):
for key, batched_tensor in batched_tensors.items():
unbatched_tensor_list = tf.unstack(batched_tensor)
for i, unbatched_tensor in enumerate(unbatched_tensor_list):
if isinstance(key, tuple) and key[1] == 'runtime_shapes':
shapes[(key[0], i)] = unbatched_tensor
if rt_shape_str in key:
shapes[(key[:-len(rt_shape_str)], i)] = unbatched_tensor
else:
tensors[(key, i)] = unbatched_tensor

Expand Down