facenet
facenet copied to clipboard
"float division by zero" when I validate my own dataset
I'm trying to validate my own dataset with pairs.txt, but I met such a headache issue. Here is the src of my issue: I got my own dataset and pairs.txt, aligned them and now I run "validate_on_lfw.py". But after a long waiting, I get a Traceback
Traceback (most recent call last):
File "facenet/src/validate_on_pcs.py", line 117, in <module>
main(parse_arguments(sys.argv[1:]))
File "facenet/src/validate_on_pcs.py", line 85, in main
actual_issame, nrof_folds=args.lfw_nrof_folds)
File "/root/prj_facenet/facenet/src/pcs.py", line 43, in evaluate
np.asarray(actual_issame), 1e-3, nrof_folds=nrof_folds)
File "/root/prj_facenet/facenet/src/facenet.py", line 489, in calculate_val
val[fold_idx], far[fold_idx] = calculate_val_far(threshold, dist[test_set], actual_issame[test_set])
File "/root/prj_facenet/facenet/src/facenet.py", line 504, in calculate_val_far
far = float(false_accept) / float(n_diff)
ZeroDivisionError: float division by zero
By review the src, I found the zero is created here(in facenet.py: 501L):
def calculate_val_far(threshold, dist, actual_issame):
predict_issame = np.less(dist, threshold)
true_accept = np.sum(np.logical_and(predict_issame, actual_issame))
false_accept = np.sum(np.logical_and(predict_issame, np.logical_not(actual_issame)))
n_same = np.sum(actual_issame)
n_diff = np.sum(np.logical_not(actual_issame))
val = float(true_accept) / float(n_same)
far = float(false_accept) / float(n_diff)
return val, far
the n_diff is valued 0 as the actual_diff here is 'True'. So it seems like there is no logical error, but when validate lfw dataset, it runs very fluently with no barrier. PUZZLING......CRYING....... Thx for any help from any buddy.
change your pair.txt, maybe it is because there is no different people sample in your batch
same problem here with that pairs.txt Abel_Pacheco 1 4 Akhmed_Zakayev 1 3 Akhmed_Zakayev 2 3 Amber_Tamblyn 1 2 Robby_Ginepri 1 2 Robert_Witt 1 2 Rod_Blagojevich 1 2 Rolandas_Paksas 1 2 Russell_Coutts 1 2 Ruth_Dreifuss 1 2 Sally_Kirkland 1 4
@abrass how can i correct my file