加载sklearn中的人脸数据集
from sklearn.datasets importfetch_lfw_people
faces= fetch_lfw_people()
执行上面的第二行程序,python会从网上下载labeled_face_wild people数据集,这个数据集大概200M,因为墙的原因下载很慢失败。
使用百度云下载该数据集,是个.tgz的压缩包
把下载好的压缩包放入C:\Users\Tim\scikit_learn_data\lfw_home,其中yyy是我的用户名,再次运行faces = fetch_lfw_people(),成功,jupyter notebook中的输出如下:
from sklearn.datasets importfetch_lfw_people
faces= fetch_lfw_people(min_faces_per_person=60)print(faces.target_names)print(faces.images.shape)
['Donald Rumsfeld' 'George W Bush' 'Gerhard Schroeder' 'Junichiro Koizumi'
'Tony Blair']
(964, 62, 47)
# 进行完上一步还可以看一下图片长什么样子
importmatplotlib.pyplot as plt%matplotlib inline
fig, ax= plt.subplots(3, 5)for i, axi inenumerate(ax.flat):
axi.imshow(faces.images[i], cm