from sklearn.datasets import fetch_lfw_people#导入数据集,第一次可能等待时间过长,因为要在网上下载数据集
import matplotlib.pyplot as plt
import numpy as np
from sklearn.model_selection import train_test_split
people = fetch_lfw_people(min_faces_per_person=2,resize = 0.7)
print(people.target_names)
print("图像个数以及像素:{}".format(people.images.shape))#(9164, 87, 65) 9164为图像个数,每张像素为87*65
print("这些图像来自于{}个人".format(len(people.target_names)))
imga_shape = people.images[0].shape
print("每张图像的像素:{}".format(imga_shape))
fix,axes = plt.subplots(2,5,figsize = (15,8),subplot_kw ={'xticks':(),'yticks':()}) #展示前10张人脸
for target,image , ax in zip(people.target, people.images, axes.ravel()):
ax.imshow(image)
ax.set_title(people.target_names[target])
counts = np.bincount(people.target)
#print(len(counts))#总共有多少个人
'''
for i,(count,name) in enumerate(zip(counts,people.target_names)):
print("
fetch_lfw_people相关
最新推荐文章于 2024-09-20 20:17:49 发布
本文详细介绍了fetch_lfw_people数据集的来源、结构和用途,探讨了如何在人脸识别任务中有效利用该数据集进行训练和验证,同时分享了加载和预处理数据的实用技巧。
摘要由CSDN通过智能技术生成