Skip to content

Commit

Permalink
Merge pull request davidsandberg#656 from cjekel/master
Browse files Browse the repository at this point in the history
Fix label_strings in export_embeddings.py
  • Loading branch information
davidsandberg authored Mar 5, 2018
2 parents 28d3bf2 + cebc255 commit fe78f66
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions contributed/export_embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,14 @@
def main(args):
train_set = facenet.get_dataset(args.data_dir)
image_list, label_list = facenet.get_image_paths_and_labels(train_set)
label_strings = [name for name in os.listdir(os.path.expanduser(args.data_dir)) if os.path.isdir(os.path.join(os.path.expanduser(args.data_dir), name))]
# fetch the classes (labels as strings) exactly as it's done in get_dataset
path_exp = os.path.expanduser(args.data_dir)
classes = [path for path in os.listdir(path_exp) \
if os.path.isdir(os.path.join(path_exp, path))]
classes.sort()
# get the label strings
label_strings = [name for name in classes if \
os.path.isdir(os.path.join(path_exp, name))]

with tf.Graph().as_default():

Expand Down Expand Up @@ -117,7 +124,8 @@ def main(args):

np.save(args.embeddings_name, emb_array)
np.save(args.labels_name, label_list)
np.save(args.labels_strings_name, label_strings)
label_strings = np.array(label_strings)
np.save(args.labels_strings_name, label_strings[label_list])


def load_and_align_data(image_paths, image_size, margin, gpu_memory_fraction):
Expand Down

0 comments on commit fe78f66

Please sign in to comment.