Joker316701882 / Additive-Margin-Softmax

This is the implementation of paper <Additive Margin Softmax for Face Verification>
492 stars 149 forks source link

Train lfw for bug #19

Open molyswu opened 5 years ago

molyswu commented 5 years ago

Additive-Margin-Softmax ,train lfw as following eorror: $python train.py --data_dir out_data1 --random_flip --learning_rate -1 --learning_rate_schedule_file ./data/learning_rate_AM_softmax.txt --lfw_dir data/lfw --keep_probability 0.8 --weight_decay 5e-4

1 2 3 Thanks for you ! molyswu

Joker316701882 commented 5 years ago

Have you aligned your test set?

molyswu commented 5 years ago

python align_lfw.py --input-dir data/lfw --output-dir out_data1

molyswu commented 5 years ago

--image_size 112,112

molyswu commented 5 years ago

Traceback (most recent call last): File "train.py", line 542, in main(parse_arguments(sys.argv[1:])) File "train.py", line 213, in main label_batch, lfw_paths, actual_issame, args.lfw_batch_size, args.lfw_nrof_folds, log_dir, step, summary_writer,best_accuracy,saver_save,modeldir,subdir) File "train.py", line 313, in evaluate , _, accuracy, val, val_std, far = lfw.evaluate(emb_array, actual_issame, nrof_folds=nrof_folds) File "/home/yjzx/Downloads/Additive-Margin-Softmax/lfw.py", line 43, in evaluate np.asarray(actual_issame), 1e-3, nrof_folds=nrof_folds) File "/home/yjzx/Downloads/Additive-Margin-Softmax/facenet.py", line 566, in calculate_val val[fold_idx], far[fold_idx] = calculate_val_far(threshold, dist[test_set], actual_issame[test_set]) File "/home/yjzx/Downloads/Additive-Margin-Softmax/facenet.py", line 580, in calculate_val_far val = float(true_accept) / float(n_same) far = float(false_accept) / float(n_diff) ZeroDivisionError: float division by zero

wanghongqu commented 5 years ago

解决了么兄弟,求指教?

Jakoffe commented 4 years ago

The problem is from the get_dataset_common function in face_image.py which is used when alligning your dataset. It only returns a list of paths to images if there is more then 10 images in that folder. And a lot of folders has less resulting in a smaller alligned data set. Because of this nearly all pairs that are not a match is invalidated as you lfw_alligned will no longer contain those images.

To fix this change this line: if len(os.listdir(os.path.join(input_dir, person_name)))>10: to -> if len(os.listdir(os.path.join(input_dir, person_name)))>0:

And change the following in the calculate_val_far in the facenet.py from: val = float(true_accept) / float(n_same) from: far = float(false_accept) / float(n_diff) to: val = float(true_accept) / float(n_same) if n_same != 0 else 0 to: far = float(false_accept) / float(n_diff) if n_diff != 0 else 0