从零开始构建:使用CNN和TensorFlow进行人脸特征检测.docx





《从零开始构建:使用CNN和TensorFlow进行人脸特征检测.docx》由会员分享,可在线阅读,更多相关《从零开始构建:使用CNN和TensorFlow进行人脸特征检测.docx(7页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、从零开始构建:使用CNN和TensorFlow进行人脸特征检测|ShubhamPanchal译者|孟翔杰来源|DeepHubIMBA出品|AI科技大本营rgznai100人脸检测系统在当今世界中具有宏大的用处这个系统要求平安性可访问性以及兴趣性今天我们将建立一个可以在脸上绘制15个关键点的模型。人脸特征检测模型形成了我们在社交媒体应用程序中看到的各种功能。您在Instagram上找到的面部过滤器是一个常见的用例。该算法将掩膜mask在图像上对齐并以脸部特征作为模型的基点。Instagram自拍过滤器需要知道您的眼睛嘴唇以及鼻子在图像上确实切位置让我们使用KerasTensorFlow作为底层开
2、发模型首先我们需要一些数据来训练我们的模型。数据我们使用OmriGoldsteinKaggle上的带有标记特征的人脸图像数据集。数据集包含大约7000张图像96*96这些图像带有可以在facial_keypoints.csv文件中找到的面部标志。但是在这里我们有一个问题。大多数图像没有15个完好的点集。因此我们只需要那些具有15个面部关键点的图像即可。可以使用此脚本我已经做了一些清理并将修改后的数据保存在DatasetArchivesGitHub中。Colabnotebook需要使用wget命令下载ZIP文件。importpandasaspdimportnumpyasnpfromsklearn
3、.model_selectionimporttrain_test_split#DownloadthedatasetfromKaggle.Unzipthearchive.Youllfindthefacial_keypoints.csvfilethere.facial_keypointspd.read_csv(files/face-images-with-marked-landmark-points/facial_keypoints.csv)num_missing_keypointsfacial_keypoints.isnull().sum(axis1)all_keypoints_present_
4、idsnp.nonzero(num_missing_keypoints0)0#face_images.npzispresentthesamearchive.dnp.load(files/face-images-with-marked-landmark-points/face_images.npz)datasetdface_images.Tdatasetnp.reshape(dataset,(-1,96,96,1)imagesdatasetall_keypoints_present_ids,:,:,:keypointsfacial_keypoints.ilocall_keypoints_pres
5、ent_ids,:.reset_index(dropTrue).valuesx_train,x_test,y_train,y_testtrain_test_split(images,keypoints,test_size0.3)#Savealltheprocesseddata.np.save(processed_data/x_train.npy,x_train)np.save(processed_data/y_train.npy,y_train)np.save(processed_data/x_test.npy,x_test)np.save(processed_data/y_test.npy,
6、y_test)我们还将图像和坐标关键点进展了标准化处理。我们对y_train以及y_test进展了重塑操作因为它们将成为卷积层Conv2D而不是全连接层Dense的输出。x_trainnp.load(face_landmarks_cleaned/x_train.npy)/255y_trainnp.load(face_landmarks_cleaned/y_train.npy)/96x_testnp.load(face_landmarks_cleaned/x_test.npy)/255y_testnp.load(face_landmarks_cleaned/y_test.npy)/96y_tra
7、innp.reshape(y_train,(-1,1,1,30)y_testnp.reshape(y_test,(-1,1,1,30)提示我们找到了另一个用于人脸特征检测的数据集称为UTKFace。它包含68个面部关键点和其他特征例如年度龄以及性别。可以尝试一下讨论模型下面让我们讨论该模型的构造。我对该模型做了一些实验。我们需要一个模型该模型采用尺寸为9696的图像作为输入并输出形状为30的数组15个关键点*2个坐标1.第一种模型读取一张图像并将其通过预先训练的VGG网络。接下来将VGG的输出展平并通太多个全连接层。问题在于即使损失很小模型可以以为每个图像预测一样的关键点。2.第二种模型是您可
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 从零开始 构建 使用 CNN TensorFlow 进行 特征 检测

限制150内