Skip to content

Instantly share code, notes, and snippets.

@Anirudh257
Created September 28, 2017 06:35
Show Gist options
  • Save Anirudh257/382dd537c6c1293dc05dcefa3e6c6077 to your computer and use it in GitHub Desktop.
Save Anirudh257/382dd537c6c1293dc05dcefa3e6c6077 to your computer and use it in GitHub Desktop.
#Till now, I have used grep and stored the index of the Clapping feature in a class_label_index variable. Then,
#I have stored the Tensorflow IDs in an examples variable.
#Then, I will store the prefixes of the tfrecord separatley in a tf_record_prefixes variable
#Then, I create the tfrecord_filenames variable to store the tfrecord in a file format like '['bal_train/1I.tfrecord', 'bal_train/0F.tfrecord']'
#When I run this part of the code, I get NotFoundError: bal_train/1I.tfrecord
audio_embeddings_dict = {}
audio_labels_dict = {}
#Load embeddings
sess = tf.Session()
for tfrecord in tfrecord_filenames:
for example in tf.python_io.tf_record_iterator(tfrecord):
tf_example = tf.train.Example.FromString(example)
vid_id = tf_example.features.feature['video_id'].bytes_list.value[0].decode(encoding = 'UTF-8')
if vid_id in examples:
example_label = list(np.asarray(tf_example.features.feature['labels'].int64_list.value))
tf_seq_example = tf.train.SequenceExample.FromString(example)
n_frames = len(tf_seq_example.feature_lists.feature_list['audio_embedding'].feature)
audio_frame = []
for i in range(n_frames):
audio_frame.append(tf.cast(tf.decode_raw(tf_seq_example.feature_lists.feature_list['audio_embedding'].
feature[i].bytes_list.value[0],tf.unit8
),tf.float32),eval(session = sess))
audio_embeddings_dict[vid_id] = audio_frame
audio_labels_dict[vid_id] = example_label
#On investigating the trace of error, I find that the error lies in python_io.tf_record_iterator. I am unclear as to how I will resolve this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment