Skip to content
This repository has been archived by the owner on Apr 13, 2021. It is now read-only.

Details of code #2

Open
Aashima-Gupta opened this issue Oct 1, 2018 · 2 comments
Open

Details of code #2

Aashima-Gupta opened this issue Oct 1, 2018 · 2 comments

Comments

@Aashima-Gupta
Copy link

Aashima-Gupta commented Oct 1, 2018

Hi, Your code really helped me. However, I have a doubt
What does this part of the do in the Train_Images.py file?

with open(label_name_map_file, 'wb') as handle:
                pickle.dump(label_name_map, handle, protocol=pickle.HIGHEST_PROTOCOL) 
#Dump the label:name map

@Aashima-Gupta
Copy link
Author

Also tell what does this code do:

 person_name = os.path.split(i)[1].split(".")[0]
                        if name2label_map.has_key(person_name):
                                name = name2label_map[person_name]
                        else:
                                count += 1
                                name2label_map[person_name] = count
                                name = count
                                label2name_map[count] = person_name

@GokulNC
Copy link
Owner

GokulNC commented Oct 17, 2018

  1. It's used to dump the label to names map as a file.
    Essentially, this is loaded by the Recognizer.py, since OpenCV returns only returns labels for each face (for which we've to take responsibility of finding the right name)

  2. If you checked the images_db folder, the files will be in the format person_name.<anything>.png
    For each image in that folder, the Train_Images.py loads it and saves the name to label map.

For example, for a file named Aashima.1.png, it might stored the name Aashima to the label 1 and label 1 for Aashima. Say for another file Gupta.53.png it might store the name Gupta to the label 2 and so on.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants