<commit_before>"""Validate a face recognizer on the "Labeled Faces in the Wild" dataset (http://vis-www.cs.umass.edu/lfw/).
Embeddings are calculated using the pairs from http://vis-www.cs.umass.edu/lfw/pairs.txt and the ROC curve
is calculated and plotted
"""
import tensorflow as tf
import numpy as np
import facenet
import os
import time

FLAGS = tf.app.flags.FLAGS

tf.app.flags.DEFINE_string('model_file', '~/models/facenet/20160514-234418/model.ckpt-500000',
                           """Directory containing the graph definition and checkpoint files.""")
tf.app.flags.DEFINE_string('lfw_pairs', '~/repo/facenet/data/lfw/pairs.txt',
                           """The file containing the pairs to use for validation.""")
tf.app.flags.DEFINE_string('file_ext', '.png',
                           """The file extension for the LFW dataset, typically .png or .jpg.""")
tf.app.flags.DEFINE_string('lfw_dir', '~/datasets/lfw/lfw_realigned/',
                           """Path to the data directory containing aligned face patches.""")
tf.app.flags.DEFINE_integer('batch_size', 60,
                            """Number of images to process in a batch.""")
tf.app.flags.DEFINE_integer('seed', 666,
                            """Random seed.""")

def main():
    
    pairs = read_pairs(os.path.expanduser(FLAGS.lfw_pairs))
    paths, actual_issame = get_paths(os.path.expanduser(FLAGS.lfw_dir), pairs)
    
    with tf.Graph().as_default():

        with tf.Session() as sess:
            
            print('Reading model "%s"' % FLAGS.model_file)
            new_saver = tf.train.import_meta_graph(os.path.expanduser(FLAGS.model_file+'.meta'))
            new_saver.restore(sess, os.path.expanduser(FLAGS.model_file))
            images_placeholder = tf.get_default_graph().get_tensor_by_name("input:0")
            phase_train_placeholder = tf.get_default_graph().get_tensor_by_name("phase_train:0")<commit_msg>Trying to restore ema-filtered parameters. Still not working.<commit_after>"""Validate a face recognizer on the "Labeled Faces in the Wild" dataset (http://vis-www.cs.umass.edu/lfw/).
Embeddings are calculated using the pairs from http://vis-www.cs.umass.edu/lfw/pairs.txt and the ROC curve
is calculated and plotted
"""
import tensorflow as tf
import numpy as np
import facenet
import os
import time

FLAGS = tf.app.flags.FLAGS

tf.app.flags.DEFINE_string('model_file', '~/models/facenet/20160514-234418/model.ckpt-500000',
                           """Directory containing the graph definition and checkpoint files.""")
tf.app.flags.DEFINE_string('lfw_pairs', '~/repo/facenet/data/lfw/pairs.txt',
                           """The file containing the pairs to use for validation.""")
tf.app.flags.DEFINE_string('file_ext', '.png',
                           """The file extension for the LFW dataset, typically .png or .jpg.""")
tf.app.flags.DEFINE_string('lfw_dir', '~/datasets/lfw/lfw_realigned/',
                           """Path to the data directory containing aligned face patches.""")
tf.app.flags.DEFINE_integer('batch_size', 60,
                            """Number of images to process in a batch.""")
tf.app.flags.DEFINE_integer('seed', 666,
                            """Random seed.""")

def main():
    
    pairs = read_pairs(os.path.expanduser(FLAGS.lfw_pairs))
    paths, actual_issame = get_paths(os.path.expanduser(FLAGS.lfw_dir), pairs)
    
    with tf.Graph().as_default():

        with tf.Session() as sess:
            
            print('Reading model "%s"' % FLAGS.model_file)
            new_saver = tf.train.import_meta_graph(os.path.expanduser(FLAGS.model_file+'.meta'))
            
            all_vars_dict = {var.name: var for var in tf.all_variables()}

            restore_vars = {}
            for var_name in all_vars_dict:
                if '/ExponentialMovingAverage' in var_name:
                    param_name = var_name.replace('/ExponentialMovingAverage', '')
                    if param_name in all_vars_dict:
                        param = all_vars_dict[param_name]
                        print('%s\t%s' % (var_name, param))
                        restore_vars[var_name] = param
            
            saver = tf.train.Saver(restore_vars, saver_def=new_saver.as_saver_def())
            saver.restore(sess, os.path.expanduser(FLAGS.model_file))
            
            images_placeholder = tf.get_default_graph().get_tensor_by_name("input:0")
            phase_train_placeholder = tf.get_default_graph().get_tensor_by_name("phase_train:0")
{'fraction_non_alphanumeric': 0.1228963684676705, 'fraction_numerical': 0.011957484499557131, 'mean_word_length': 2.5538945712037764, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5438478', 'n_tokens_mistral': 1429, 'n_tokens_neox': 1339, 'n_words': 298}