Exemple #1
0
def evaluate(embeddings,
             actual_issame,
             nrof_folds=10,
             distance_metric=0,
             subtract_mean=False):
    # Calculate evaluation metrics
    thresholds = np.arange(0, 4, 0.01)
    embeddings1 = embeddings[0::2]
    embeddings2 = embeddings[1::2]
    tpr, fpr, accuracy = facenet.calculate_roc(thresholds,
                                               embeddings1,
                                               embeddings2,
                                               np.asarray(actual_issame),
                                               nrof_folds=nrof_folds,
                                               distance_metric=distance_metric,
                                               subtract_mean=subtract_mean)
    thresholds = np.arange(0, 4, 0.001)
    val, val_std, far = facenet.calculate_val(thresholds,
                                              embeddings1,
                                              embeddings2,
                                              np.asarray(actual_issame),
                                              1e-3,
                                              nrof_folds=nrof_folds,
                                              distance_metric=distance_metric,
                                              subtract_mean=subtract_mean)
    return tpr, fpr, accuracy, val, val_std, far
def evaluate_accuracy(sess, images_placeholder, phase_train_placeholder,
                      image_size, embeddings, paths, actual_issame,
                      augment_images, aug_value, batch_size, orig_image_size,
                      seed):
    nrof_images = len(paths)
    nrof_batches = int(math.ceil(1.0 * nrof_images / batch_size))
    emb_list = []
    for i in range(nrof_batches):
        start_index = i * batch_size
        end_index = min((i + 1) * batch_size, nrof_images)
        paths_batch = paths[start_index:end_index]
        images = facenet.load_data(paths_batch, False, False, orig_image_size)
        images_aug = augment_images(images, aug_value, image_size)
        feed_dict = {
            images_placeholder: images_aug,
            phase_train_placeholder: False
        }
        emb_list += sess.run([embeddings], feed_dict=feed_dict)
    emb_array = np.vstack(
        emb_list
    )  # Stack the embeddings to a nrof_examples_per_epoch x 128 matrix

    thresholds = np.arange(0, 4, 0.01)
    embeddings1 = emb_array[0::2]
    embeddings2 = emb_array[1::2]
    _, _, accuracy = facenet.calculate_roc(thresholds, embeddings1,
                                           embeddings2,
                                           np.asarray(actual_issame), seed)
    return accuracy
def _evaluate(embeddings, actual_issame, nrof_folds=10):
    # Calculate evaluation metrics
    thresholds = np.arange(0, 4, 0.01)
    embeddings1 = embeddings[0::2]
    embeddings2 = embeddings[1::2]
    tpr, fpr, accuracy = facenet.calculate_roc(thresholds, embeddings1, embeddings2,
                                               np.asarray(actual_issame), nrof_folds=nrof_folds)
    thresholds = np.arange(0, 4, 0.001)
    val, val_std, far = facenet.calculate_val(thresholds, embeddings1, embeddings2,
                                              np.asarray(actual_issame), 1e-3, nrof_folds=nrof_folds)
    return tpr, fpr, accuracy, val, val_std, far
Exemple #4
0
def evaluate(embeddings, actual_issame, nrof_folds=10):
    # Calculate evaluation metrics
    thresholds = np.arange(0, 4, 0.01)
    embeddings1 = embeddings[0::2]  # 6000张图片 是每一个Paris中的第一张
    embeddings2 = embeddings[1::2]  # 6000张图片 是每一个Paris中的第2张
    # 计算roc曲线需要的数据和在测试数据上的每一折的测试精度
    tpr, fpr, accuracy = facenet.calculate_roc(thresholds,
                                               embeddings1,
                                               embeddings2,
                                               np.asarray(actual_issame),
                                               nrof_folds=nrof_folds)
    thresholds = np.arange(0, 4, 0.001)
    # 计算验证率
    val, val_std, far = facenet.calculate_val(thresholds,
                                              embeddings1,
                                              embeddings2,
                                              np.asarray(actual_issame),
                                              1e-3,
                                              nrof_folds=nrof_folds)
    return tpr, fpr, accuracy, val, val_std, far