The from sklearn. Datasets import fetch_lfw_people
People=fetch_lfw_people (min_faces_per_person=20, resize=0.7)
Image_shape=people. The images' [0]. Shape
FIG, axes=PLT. Subplots (2, 5, figsize=(15, 8),
Subplot_kw={' xticks: (), 'yticks: ()})
For target, image, ax in zip (people. The target, people. The images, axes, ravel ()) :
Ax. Imshow (image)
Ax. Set_title (people. Target_names [target])
The next piece of code
Print (" people images. Shape: {} ". The format (people) images) shape))
Print (" the Number of classes: {} ". The format (len (people. Target_names)))
The results for the
People. Images. Shape: (67, 87, 65)
Number of classes: 2
The last piece of code
# count how, each target appears
Counts=np. Bincount (people. Target)
# print counts next to target names:
For I, (the count, name) in enumerate (zip (counts, people. Target_names)) :
Print (" {0:25} {1:3} ". The format (name, count), end=' ')
If (I + 1) % 3==0:
Print ()
The results for the
Gloria Macapagal Arroyo has 44 Tiger Woods 23
Access by the program is the face of only 67 photo library, only two people,
Given the book run results as shown in the following two pictures:
Access face library folder, where you can see there are more than 200 M, there are a lot of pictures of the following:
Starting a reference books, step by step to do, to this kind of accident is a mystery, in the rescue greatly help all of you! Thank you!
CodePudding user response:
The building Lord, how are you, I put the people=fetch_lfw_people (min_faces_per_person=20, resize=0.7) this line of code to the people=fetch_lfw_people () output results for (2719, 62, 47), consultCodePudding user response:
You the picture is not complete, the program of min_faces_per_person=20, need at least 20 per person, so the shortage of people ignored,CodePudding user response:
Download the complete data packets, and then copy to: C: \ \ Users \ XXXX scikit_learn_data \ lfw_home \ lfw_funneled, then put the C: \ Users \ xxxi \ scikit_learn_data \ lfw_home \ joblib \ sklearn \ datasets \ _lfw \ _fetch_lfw_people directory of the temporary directory to delete, can be run again,