Open ZZH2950228 opened 4 years ago
@garg-7 so how to create my own list.txt file like the 'lfw_test_pair.txt' , could you plz show the codes ,thx!
Sorry, I've been away for a while.
@barcahoo To create your own list file, you could write a script using the os
module in python to traverse the directories that contain the images and write to a list.txt file side-by-side. Ping me back if you face any issues there.
@garg-7 Hello, I want to know how to get the test results. For example, I input a face and how to get the recognition accuracy. I only saw the verification results in the lfw data set, but I don’t understand the recognition part. How to input part of face recognition data list?
Hi @Houmengjun, I'm not aware of how much you know about this project but it's working like this -
This comparison is being done using the cosine metric. This was the working of the recognition part.
I didn't get what you meant by the last line -
How to input part of face recognition data list?
@garg-7 I know what you mean, thank you very much! I really want to know where is the code of the recognition part you told me in the test phase of this project? The meaning of the last line is: For example, I mixed my frontal photo with many other people's face pictures and used a self-portrait as a test image. How do I enter data into this network? I know that the test done on the lfw dataset is called face verification, but I want to figure out how to get the recognition accuracy. Looking forward to your reply!
@Houmengjun Oh. I think I got what you're asking. For generalized testing, you'll need to make some changes to the test.py file.
What you could do is -
Use line 141 as present in test.py:
features, cnt = get_featurs(model, img_paths, batch_size=batch_size)
What's happening here is you simply pass a list of full file paths for the reference images as img_paths
and the model returns the features and the count in features, cnt
respectively.
Now you could save these features, say in some JSON or pickle file.
Then again at test time, you run the line in step 1 for the test images. This time you just load all the features you stored in step 2. Compare the test image(s)' features against each loaded feature, using line 99 of test.py:
def cosin_metric(x1, x2):
return np.dot(x1, x2) / (np.linalg.norm(x1) * np.linalg.norm(x2))
This function returns how good a match there is between two features x1 and x2. (cosine measure so inverted value in some sense.)
From this, you should be able to get an idea as to what is the degree of similarity, and then you could figure out if the scores come out as you had expected or not. With that information, you can calculate the accuracy of recognition.
Thank you very much for your reply! I will try my best to achieve it! Thank you, my friend, can you add an email address? @garg-7 @
@Houmengjun Glad I could help.
To test on your own dataset, you need to a 'list.txt' file (in addition to the dataset formatted in the correct form obviously). There is a text file called 'lfw_test_pair.txt' which specifies the hierarchy in which you need to arrange your dataset. Then from that, you have to create your own list.txt file which contains true (1) and false (0) pairs just like the 'lfw_test_pair.txt'. Finally, place the dataset and the text file, in the paths mentioned in the 'config\config.py' file (Lines 21 and 22 to be precise) and you should be good to go.