[{"data":1,"prerenderedAt":391},["ShallowReactive",2],{"content-query-m5NjVnnlEv":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"cover":11,"type":12,"body":13,"_type":385,"_id":386,"_source":387,"_file":388,"_stem":389,"_extension":390},"/news/zh/2249","zh",false,"","不用摘口罩也知道你是谁，MindSpore训练口罩人脸识别模型","人脸识别的目标是确定人脸图像的身份。随着智慧城市的建设，人脸识别的应用场景越来越多样，比如嫌疑人追踪、定位走失的老人儿童等。","2021-04-20","https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2023/04/25/c4c37869e37043b79ca26f7b6891e0c9.png","news",{"type":14,"children":15,"toc":382},"root",[16,24,30,50,60,73,81,91,99,104,109,114,119,124,129,134,141,146,173,180,207,212,219,230,237,242,250,259,264,271,278,283,290,295,306,314,322,341,353,364],{"type":17,"tag":18,"props":19,"children":21},"element","h1",{"id":20},"不用摘口罩也知道你是谁mindspore训练口罩人脸识别模型",[22],{"type":23,"value":8},"text",{"type":17,"tag":25,"props":26,"children":27},"p",{},[28],{"type":23,"value":29},"人脸识别的目标是确定人脸图像的身份。随着智慧城市的建设，人脸识别的应用场景越来越多样，比如嫌疑人追踪、定位走失的老人儿童等。随着新型冠状病毒在全球范围内的爆发，为了公共卫生安全，越来越多的人在公共场所佩戴口罩以降低感染传染性疾病的风险。",{"type":17,"tag":25,"props":31,"children":32},{},[33,35,41,43,48],{"type":23,"value":34},"传统的人脸分析方法主要提取整张脸部的全局特征进行分析，口罩遮挡场景下，面部的部分重要部位（比如下颌等）被口罩覆盖住，提取整张脸的全局特征将会引入大量噪声。因此，口罩遮挡场景下的人脸分析任务亟需新的解决方案。我们基于MindSpore设计了一种人脸识别算法，以",{"type":17,"tag":36,"props":37,"children":38},"strong",{},[39],{"type":23,"value":40},"解决口罩遮挡场景下的人脸识别问题",{"type":23,"value":42},"。该算法的",{"type":17,"tag":36,"props":44,"children":45},{},[46],{"type":23,"value":47},"开源代码已经在MindSpore上首发",{"type":23,"value":49},"了。",{"type":17,"tag":51,"props":52,"children":53},"ul",{},[54],{"type":17,"tag":55,"props":56,"children":57},"li",{},[58],{"type":23,"value":59},"论文：",{"type":17,"tag":25,"props":61,"children":62},{},[63,65],{"type":23,"value":64},"Feifei Ding, Peixi Peng, Yangru Huang, Mengyue Geng and Yonghong Tian. Masked Face Recognition with Latent Part Detection. ACM Multimedia 2020. ",{"type":17,"tag":66,"props":67,"children":71},"a",{"href":68,"rel":69},"https://dl.acm.org/doi/pdf/10.1145/3394171.3413731",[70],"nofollow",[72],{"type":23,"value":68},{"type":17,"tag":51,"props":74,"children":75},{},[76],{"type":17,"tag":55,"props":77,"children":78},{},[79],{"type":23,"value":80},"开源地址：",{"type":17,"tag":25,"props":82,"children":83},{},[84],{"type":17,"tag":66,"props":85,"children":88},{"href":86,"rel":87},"https://gitee.com/mindspore/mindspore/tree/master/model%5C_zoo/research/cv/MaskedFaceRecognition",[70],[89],{"type":23,"value":90},"https://gitee.com/mindspore/mindspore/tree/master/model\\_zoo/research/cv/MaskedFaceRecognition",{"type":17,"tag":25,"props":92,"children":93},{},[94],{"type":17,"tag":95,"props":96,"children":98},"img",{"alt":7,"src":97},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202104/20/150459crv3lyuul6qujmcj.png",[],{"type":17,"tag":25,"props":100,"children":101},{},[102],{"type":23,"value":103},"目前还没有针对口罩人脸的大规模的训练数据集，为解决训练数据不足的问题，我们基于已有的公开人脸数据集生成口罩人脸数据作为训练数据。流程如下：",{"type":17,"tag":25,"props":105,"children":106},{},[107],{"type":23,"value":108},"（1）采用已有的人脸关键点检测算法（比如Dlib）检测出无遮挡人脸图片上的多个关键点位置；",{"type":17,"tag":25,"props":110,"children":111},{},[112],{"type":23,"value":113},"（2）标注出口罩佩戴区域（鼻尖以下区域）的关键点位置；",{"type":17,"tag":25,"props":115,"children":116},{},[117],{"type":23,"value":118},"（3）在口罩示例图片（比如N95口罩）上手动标注关键点，并和人脸口罩佩戴区域的关键点一一对应；",{"type":17,"tag":25,"props":120,"children":121},{},[122],{"type":23,"value":123},"（4）根据口罩示例图片的关键点位置，对其做三角剖分，将口罩示例图片划分为多个小三角形；",{"type":17,"tag":25,"props":125,"children":126},{},[127],{"type":23,"value":128},"（5）根据口罩示例图片和人脸图片的关键点对应关系，将口罩示例图片上的每个小三角形区域仿射变换到人脸图片上，并进行平滑操作，生成口罩人脸图片。",{"type":17,"tag":25,"props":130,"children":131},{},[132],{"type":23,"value":133},"我们在人脸公开数据集WebFace上生成了8种不同风格的口罩人脸，将其与原始未佩戴口罩的人脸图片混合，作为训练数据。",{"type":17,"tag":25,"props":135,"children":136},{},[137],{"type":17,"tag":95,"props":138,"children":140},{"alt":7,"src":139},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202104/20/150534e7usifmzrtz38ux6.png",[],{"type":17,"tag":25,"props":142,"children":143},{},[144],{"type":23,"value":145},"算法框架如图所示，考虑到口罩人脸中的许多重要信息被口罩遮挡，我们提出了基于潜在区域检测的二分支网络模型以提取更具判别力的特征。其中，局部分支对潜在区域提取局部特征，全局分支对原图提取全局特征。",{"type":17,"tag":25,"props":147,"children":148},{},[149,151,155,157,161,165,167,171],{"type":23,"value":150},"我们将潜在区域定义为未被口罩遮挡的人脸区域，用",{"type":17,"tag":95,"props":152,"children":154},{"alt":7,"src":153},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202104/20/150659bigfh7vezxuiyycu.png",[],{"type":23,"value":156},"表示，其中",{"type":17,"tag":95,"props":158,"children":160},{"alt":7,"src":159},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202104/20/150738dxdpyp4vr7yo8zq0.png",[],{"type":17,"tag":95,"props":162,"children":164},{"alt":7,"src":163},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202104/20/150757hvkjqk7iorlnznpw.png",[],{"type":23,"value":166},"为待学习的参数。受空间转换网络（STN）的启发，我们对",{"type":17,"tag":95,"props":168,"children":170},{"alt":7,"src":169},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202104/20/150830y68uulnfaqtl04po.png",[],{"type":23,"value":172},"区域内的特征进行有限制的仿射变换，使其转变为原图大小，公式如下：",{"type":17,"tag":25,"props":174,"children":175},{},[176],{"type":17,"tag":95,"props":177,"children":179},{"alt":7,"src":178},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202104/20/150921ik6syf05xacith0p.png",[],{"type":17,"tag":25,"props":181,"children":182},{},[183,185,189,191,195,197,201,205],{"type":23,"value":184},"其中，目标框定义为",{"type":17,"tag":95,"props":186,"children":188},{"alt":7,"src":187},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202104/20/150955zs87ntpjajqt8tbb.png",[],{"type":23,"value":190},"H和W分别为原图的长和宽。通过该公式可以得到",{"type":17,"tag":95,"props":192,"children":194},{"alt":7,"src":193},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202104/20/1510313ojlzhmfvl33tgjm.png",[],{"type":23,"value":196},"可以通过STN的仿射变换矩阵的参数",{"type":17,"tag":95,"props":198,"children":200},{"alt":7,"src":199},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202104/20/151103kbgb3ljratifjmvz.png",[],{"type":17,"tag":95,"props":202,"children":204},{"alt":7,"src":203},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202104/20/151119vyfddrltcttnjtjs.png",[],{"type":23,"value":206},"转化得到，由此可以检测出潜在区域。根据潜在区域和原图坐标的对应关系，采用双线性插值将其扩充为和原图一样的大小。",{"type":17,"tag":25,"props":208,"children":209},{},[210],{"type":23,"value":211},"网络模型为二分支网络，一分支对潜在区域提取局部特征，另一分支对原图提取全局特征，两分支共享网络参数。各分支采用分类损失函数进行优化，对于局部分支，额外引入LPD损失函数：",{"type":17,"tag":25,"props":213,"children":214},{},[215],{"type":17,"tag":95,"props":216,"children":218},{"alt":7,"src":217},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202104/20/151207xqhgzg8uj8v0ydp6.png",[],{"type":17,"tag":25,"props":220,"children":221},{},[222,224,228],{"type":23,"value":223},"其中,",{"type":17,"tag":95,"props":225,"children":227},{"alt":7,"src":226},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202104/20/151243gfv3wjjkro6h7off.png",[],{"type":23,"value":229},"为鼻尖关键点的纵坐标。引入该损失函数的目的是规范网络对潜在区域的定位，使其尽可能在人脸鼻尖以上的区域，因为根据先验知识，口罩往往会遮挡鼻尖以下的脸部区域。在测试阶段，将全局特征与局部特征结合作为最终的特征表达。",{"type":17,"tag":25,"props":231,"children":232},{},[233],{"type":17,"tag":95,"props":234,"children":236},{"alt":7,"src":235},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202104/20/151324nfrt34rcbaliqwe2.png",[],{"type":17,"tag":25,"props":238,"children":239},{},[240],{"type":23,"value":241},"我们搜集了实际的口罩人脸数据集PKU-Masked-Face Dataset作为测试集，该测试集共有10301张属于1018个不同身份的人脸图片。大多数身份有至少5张佩戴口罩和5张不佩戴口罩的共计5个视角的人脸图片，5个视角分别为：正面、左面、右面、俯视、仰视。口罩人脸图片作为查询图像库，正常人脸图片作为待匹配图像库。",{"type":17,"tag":51,"props":243,"children":244},{},[245],{"type":17,"tag":55,"props":246,"children":247},{},[248],{"type":23,"value":249},"测试集链接：",{"type":17,"tag":25,"props":251,"children":252},{},[253],{"type":17,"tag":66,"props":254,"children":257},{"href":255,"rel":256},"https://pkuml.org/resources/pku-masked-face-dataset.html",[70],[258],{"type":23,"value":255},{"type":17,"tag":25,"props":260,"children":261},{},[262],{"type":23,"value":263},"基于MindSpore实现的算法模型实验结果如下表所示，其中Baseline为采用WebFace原始数据训练的ResNet50基准模型，MG是采用WebFace增强数据训练的ResNet50模型，LPD为我们提出的潜在区域检测模型。",{"type":17,"tag":25,"props":265,"children":266},{},[267],{"type":17,"tag":95,"props":268,"children":270},{"alt":7,"src":269},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202104/20/1514069oucfqkhrcyet71l.png",[],{"type":17,"tag":25,"props":272,"children":273},{},[274],{"type":17,"tag":95,"props":275,"children":277},{"alt":7,"src":276},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202104/20/1514291xswnjhkwdvodygz.png",[],{"type":17,"tag":25,"props":279,"children":280},{},[281],{"type":23,"value":282},"二分支网络结构代码：",{"type":17,"tag":25,"props":284,"children":285},{},[286],{"type":17,"tag":95,"props":287,"children":289},{"alt":7,"src":288},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202104/20/151512aoqc5xd1viy3oebs.png",[],{"type":17,"tag":25,"props":291,"children":292},{},[293],{"type":23,"value":294},"其中global_out和partial_out分别对应对原图提取的全局特征和潜在区域提取的局部特征，两部分共用特征提取主干层。",{"type":17,"tag":25,"props":296,"children":297},{},[298,300,304],{"type":23,"value":299},"潜在区域检测LPD模块的具体实现：",{"type":17,"tag":95,"props":301,"children":303},{"alt":7,"src":302},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202104/20/151546naqlq7anghcrnygb.png",[],{"type":23,"value":305},"其中输入为原始图片，输出为未被遮挡人脸区域边界坐标。",{"type":17,"tag":51,"props":307,"children":308},{},[309],{"type":17,"tag":55,"props":310,"children":311},{},[312],{"type":23,"value":313},"相关训练与推理代码：",{"type":17,"tag":25,"props":315,"children":316},{},[317],{"type":17,"tag":66,"props":318,"children":320},{"href":86,"rel":319},[70],[321],{"type":23,"value":90},{"type":17,"tag":25,"props":323,"children":324},{},[325,327,332,334,339],{"type":23,"value":326},"该代码基于MindSpore框架实现，运行的硬件环境为Ascend910。算法解决了口罩遮挡场景下的人脸识别问题，",{"type":17,"tag":36,"props":328,"children":329},{},[330],{"type":23,"value":331},"对基准模型性能提升明显",{"type":23,"value":333},"，实验结果如上表达到",{"type":17,"tag":36,"props":335,"children":336},{},[337],{"type":23,"value":338},"业界领先水平",{"type":23,"value":340},"。",{"type":17,"tag":25,"props":342,"children":343},{},[344],{"type":17,"tag":66,"props":345,"children":348},{"href":346,"rel":347},"http://mp.weixin.qq.com/s?__biz=MzAxMDA1MDM0NQ==&mid=2247529668&idx=1&sn=cfdaff21a322d079f07b613d3bf1ad5f&chksm=9b547a82ac23f3946eed894eb26ef9a1ae6da998b819c80d0a1265be6b0b4904030f5081e5c5&scene=21#wechat_redirect",[70],[349],{"type":17,"tag":95,"props":350,"children":352},{"alt":7,"src":351},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202104/20/151622ehzq5wdbfmebs8xm.png",[],{"type":17,"tag":25,"props":354,"children":355},{},[356,358],{"type":23,"value":357},"MindSpore官方资料GitHub : ",{"type":17,"tag":66,"props":359,"children":362},{"href":360,"rel":361},"https://github.com/mindspore-ai/mindspore",[70],[363],{"type":23,"value":360},{"type":17,"tag":25,"props":365,"children":366},{},[367,369,376,378],{"type":23,"value":368},"Gitee：",{"type":17,"tag":66,"props":370,"children":373},{"href":371,"rel":372},"https://gitee.com/mindspore/mindspore%E5%AE%98%E6%96%B9QQ%E7%BE%A4",[70],[374],{"type":23,"value":375},"https://gitee.com/mindspore/mindspore官方QQ群",{"type":23,"value":377}," : 871543426长按下方二维码加入MindSpore项目↓",{"type":17,"tag":95,"props":379,"children":381},{"alt":7,"src":380},"https://bbs-img.huaweicloud.com/data/forums/attachment/forum/202104/20/15171990qmiek1xfrlm6c5.png",[],{"title":7,"searchDepth":383,"depth":383,"links":384},4,[],"markdown","content:news:zh:2249.md","content","news/zh/2249.md","news/zh/2249","md",1776506064793]