Skip to content
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

update data define #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ def set_up_init_ops(variables):
tf.GraphKeys.LOCAL_VARIABLES)))

coord = tf.train.Coordinator()
runners_to_remove = [q_runner for q_runner in sess.graph.get_collection_ref("queue_runners") if q_runner.name == "train_input/input_producer" or q_runner.name == "train_input/shuffle_batch_join/random_shuffle_queue"]
for runner in runners_to_remove:
sess.graph.get_collection_ref("queue_runners").remove(runner)
threads = tf.train.start_queue_runners(sess=sess, coord=coord)
num_examples_processed = 0
start_time = time.time()
Expand Down
17 changes: 8 additions & 9 deletions readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ class YT8MAggregatedFeatureReader(BaseReader):

def __init__(self,
num_classes=4716,
feature_sizes=[1024],
feature_names=["mean_inc3"]):
feature_sizes=[1024, 128],
feature_names=["mean_rgb", "mean_audio"]):
"""Construct a YT8MAggregatedFeatureReader.

Args:
Expand Down Expand Up @@ -114,20 +114,19 @@ def prepare_serialized_examples(self, serialized_examples):
"length of feature_names (={}) != length of feature_sizes (={})".format( \
len(self.feature_names), len(self.feature_sizes))

feature_map = {"video_id": tf.FixedLenFeature([], tf.string),
feature_map = {"id": tf.FixedLenFeature([], tf.string),
"labels": tf.VarLenFeature(tf.int64)}
for feature_index in range(num_features):
feature_map[self.feature_names[feature_index]] = tf.FixedLenFeature(
[self.feature_sizes[feature_index]], tf.float32)

features = tf.parse_example(serialized_examples, features=feature_map)

labels = tf.sparse_to_indicator(features["labels"], self.num_classes)
labels.set_shape([None, self.num_classes])
concatenated_features = tf.concat([
features[feature_name] for feature_name in self.feature_names], 1)

return features["video_id"], concatenated_features, labels, tf.ones([tf.shape(serialized_examples)[0]])
return features["id"], concatenated_features, labels, tf.ones([tf.shape(serialized_examples)[0]])

class YT8MFrameFeatureReader(BaseReader):
"""Reads TFRecords of SequenceExamples.
Expand All @@ -140,8 +139,8 @@ class YT8MFrameFeatureReader(BaseReader):

def __init__(self,
num_classes=4716,
feature_sizes=[1024],
feature_names=["inc3"],
feature_sizes=[1024, 128],
feature_names=["rgb", "audio"],
max_frames=300):
"""Construct a YT8MFrameFeatureReader.

Expand Down Expand Up @@ -216,7 +215,7 @@ def prepare_serialized_examples(self, serialized_example,

contexts, features = tf.parse_single_sequence_example(
serialized_example,
context_features={"video_id": tf.FixedLenFeature(
context_features={"id": tf.FixedLenFeature(
[], tf.string),
"labels": tf.VarLenFeature(tf.int64)},
sequence_features={
Expand Down Expand Up @@ -262,7 +261,7 @@ def prepare_serialized_examples(self, serialized_example,

# convert to batch format.
# TODO: Do proper batch reads to remove the IO bottleneck.
batch_video_ids = tf.expand_dims(contexts["video_id"], 0)
batch_video_ids = tf.expand_dims(contexts["id"], 0)
batch_video_matrix = tf.expand_dims(video_matrix, 0)
batch_labels = tf.expand_dims(labels, 0)
batch_frames = tf.expand_dims(num_frames, 0)
Expand Down