bad result from lfw dataset
See original GitHub issue
hello @peteryuX i try to test accuracy on 2 images of 1 person in lfw dataset. The distance is big.
my test code:
from absl import app, flags, logging
from absl.flags import FLAGS
import cv2
import os
import numpy as np
import tensorflow as tf
from modules.evaluations import get_val_data, perform_val
from modules.models import ArcFaceModel
from modules.utils import set_memory_growth, load_yaml, l2_norm
from scipy.spatial.distance import cosine
flags.DEFINE_string('cfg_path', './configs/arc_res50.yaml', 'config file path')
flags.DEFINE_string('gpu', '0', 'which gpu to use')
flags.DEFINE_string('img_path', '', 'path to input image')
def main(_argv):
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
os.environ['CUDA_VISIBLE_DEVICES'] = FLAGS.gpu
logger = tf.get_logger()
logger.disabled = True
logger.setLevel(logging.FATAL)
set_memory_growth()
cfg = load_yaml(FLAGS.cfg_path)
model = ArcFaceModel(size=cfg['input_size'],
backbone_type=cfg['backbone_type'],
training=False)
ckpt_path = tf.train.latest_checkpoint('./checkpoints/')
if ckpt_path is not None:
print("[*] load ckpt from {}".format(ckpt_path))
model.load_weights(ckpt_path)
else:
print("[*] Cannot find ckpt from {}.".format(ckpt_path))
exit()
image_fol = "./tmp"
paths = os.listdir(image_fol)
embeds = []
images = []
flip_images = []
for path in paths:
print(path)
img = cv2.imread(os.path.join(image_fol, path))
img = cv2.resize(img, (cfg['input_size'], cfg['input_size']))
img = img.astype(np.float32) / 255.
# if len(img.shape) == 3:
# img = np.expand_dims(img, 0)
# embeds.append(l2_norm(model(img)))
images.append(img)
images = np.array(images)
def hflip_batch(imgs):
assert len(imgs.shape) == 4
return imgs[:, :, ::-1, :]
flip_images = hflip_batch(images)
embeds = model(images) + model(flip_images)
embeds = l2_norm(embeds)
dist = np.sum(np.square(embeds[0]-embeds[1]))
print("dist: ", dist)
# diff = np.subtract([embeds[0]], [embeds[1]])
# dist = np.sum(np.square(diff), 1)
# print("diff: ", diff)
acc = 1 - cosine(embeds[0], embeds[1])
print("acc: ", acc)
the result is:
dist: 1.1708782
acc: 0.4145609736442566
How can i achive 99.35% accuracy on lfw?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:10 (4 by maintainers)
Top Results From Across the Web
LFW : Results - Vision Lab - UMass Amherst
The use of training data outside of LFW can have a significant impact on recognition performance. For instance, it was shown in Wolf...
Read more >Fifteen Minutes with FiftyOne: Labeled Faces in the Wild
Through a quick inspection of the dataset in FiftyOne, the biases of LFW towards white male faces as well as a bias in...
Read more >Face detection using CNN with the LFW dataset | Kaggle
Accuracy is a useful indicator that our model performs well, but ignores the nuance that false positives and false negatives may have different...
Read more >Face Recognition with Labeled Faces in the Wild dataset
I've uploaded the data to GitHub (lfw-classification) with all the ... These are the best results after several hours of iterations using ...
Read more >arXiv:2108.10290v3 [cs.CV] 25 Nov 2022
We continue research on the LFW database and show that image ... result in a meaningless identity feature and thus reflect poor quality)....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
hello @FelixZhang7 It is exactly similarity, not acc.
@HoangTienDuc Hello,may i ask why acc = 1 - cosine(embeds[0], embeds[1])?