受欢迎的网站建设平台seo网站建设厦门

当前位置: 首页 > news >正文

受欢迎的网站建设平台,seo网站建设厦门,广州百度推广排名优化,搭建网站案例Azure AI 人脸服务提供了可检测、识别和分析图像中的人脸的 AI 算法。 人脸识别软件在许多不同情形中都十分重要#xff0c;例如识别、无接触访问控制和实现隐私的人脸模糊。你可以通过客户端库 SDK#xff0c;或者直接调用 REST API 使用人脸服务。 目录 一、人脸识别服务场… Azure AI 人脸服务提供了可检测、识别和分析图像中的人脸的 AI 算法。 人脸识别软件在许多不同情形中都十分重要例如识别、无接触访问控制和实现隐私的人脸模糊。你可以通过客户端库 SDK或者直接调用 REST API 使用人脸服务。 目录 一、人脸识别服务场景与任务概述使用场景人脸检测和分析任务活体检测任务人脸识别任务标识验证 查找相似人脸任务对人脸分组任务输入要求 二、人脸识别服务技术实战环境准备创建环境变量识别和验证人脸输出 一、人脸识别服务场景与任务概述 使用场景 验证用户标识根据受信任的人脸图像验证人员。 此验证可用于授予对数字或物理财产的访问权限如银行帐户、建筑物访问权限等。 在大多数情况下受信任的人脸图像可能来自政府颁发的身份证件如护照或驾照也可以来自亲自拍摄的注册照片。 在验证期间活体检测在验证图像是否来自真人而不是打印的照片或面具方面起着关键作用。 活体检测活体检测是一种反欺骗功能用于检查用户本人是否真实出现在相机前。 该功能用于防止使用打印的照片、视频或用户面部的 3D 面具进行欺骗攻击。 非接触式访问控制与如今的卡片或票证等方法相比选择性人脸识别能够增强访问控制体验同时降低因卡片共享、丢失或盗窃而带来的卫生和安全风险。 人脸识别可以帮助在机场、体育场馆、主题公园、建筑物或者办公室、医院、健身房、俱乐部或学校的接待亭进行人工值机。 人脸编修编辑或模糊视频中录制的检测到的人脸以保护其隐私。 人脸检测和分析任务 在所有其他情况下需要将人脸检测作为第一步。 检测 API 可以检测图像中的人脸并返回其位置的矩形坐标。 它还返回一个表示存储的人脸数据的唯一 ID。 该 ID 将在以后的操作中用于识别或验证人脸。 人脸检测还可提取一组人脸相关属性例如头部姿势、年龄、情绪、面部毛发和眼镜。 这些属性是一般预测而不是实际分类。 某些属性可用于确保在用户将自己添加到人脸服务时应用程序获得高质量的人脸数据。 例如如果用户戴着太阳镜应用程序可以建议用户取下太阳镜。 活体检测任务 人脸活体检测可用于确定输入视频流中的人脸是真实的活的还是虚假的欺骗性的。 这是生物特征身份验证系统中的一个重要组成部分可防止冒名顶替者试图使用照片、视频、面具或其他方式冒充他人来访问系统从而发动欺骗攻击。 活体检测的目标是确保系统在身份验证时与实际存在的活人进行交互。 随着数字金融、远程访问控制和在线身份验证流程的兴起此类系统变得越来越重要。 活体检测解决方案可以成功防御各种欺骗类型包括纸质打印输出、2D/3D 面具以及手机和笔记本电脑上的欺骗演示。 活体检测是一个活跃的研究领域随着时间的推移人们不断对其进行改进以应对日益复杂的欺骗攻击。 随着整体解决方案对新型攻击的防御变得越来越强大我们也会不断向客户端和服务组件推出持续改进。 人脸识别任务 现代企业和应用可以使用人脸识别技术包括人脸验证“一对一”匹配和人脸识别“一对多”匹配来确认用户身份。 标识 人脸识别可解决图像中一张人脸与安全存储库中一组人脸的“一对多”匹配问题。 根据其人脸数据与查询人脸的匹配程度返回匹配候选项。 此方案用于向对某组人员授予建筑物或机场进出权限或验证设备的用户。 下图显示名为 myfriends 的数据库的示例。 每个组最多可以包含 100 万个不同的 person 对象。 每个人员对象可以注册最多 248 张人脸。 创建并训练一个组后可以对组使用新检测到的人脸执行识别。 如果人脸被标识为组中的某一人员则返回该人员对象。 验证 验证操作会回答问题“这两个人脸是否属于同一人”。 验证也是将图像中的人脸与安全存储库或照片中的一张人脸进行“一对一”匹配以验证他们是否是同一个人。 验证可用于访问控制例如银行应用可让用户拍摄自己的新照片并将其与身份证件照片一起发送以远程开立信用帐户。 还可用作标识 API 调用结果的最终检查。 查找相似人脸任务 查找相似人脸操作会在目标人脸和一组候选人脸之间进行人脸匹配找出与目标人脸相似的一小组人脸。 这对于按图像进行人脸搜索很有用。 该服务支持两种工作模式matchPerson 和 matchFace 。 使用验证 API 针对同一人进行筛选后matchPerson 模式会返回相似人脸。 matchFace 模式会忽略同一人筛选器。 它返回相似候选人脸的列表这些人脸不一定属于同一人。 以下示例显示了目标人脸 这些图像是候选人脸 为了查找四张相似人脸matchPerson 模式会返回 A 和 B它们与目标人脸显示的是同一个人。 matchFace 模式返回 A、B、C、D恰好四个候选项即使某些选项与目标不是同一人或者相似度低也是如此。 对人脸分组任务 组操作会基于相似性将未知人脸的集合分为几个较小的组。 每个组是原始人脸集合的互不相交真子集。 它还返回单个“messyGroup”数组其中包含未找到相似性的人脸 ID。 返回的一个组中的所有人脸可能属于同一人但一个人可能有多个不同的组。 这些组按其他因素例如表情区分。 输入要求 常规图像输入要求 支持的输入图像格式为 JPEG、PNG、GIF第一帧和 BMP。图像文件不得大于 6 MB。 人脸检测输入要求 在不大于 1920 x 1080 像素的图像中最小可检测人脸大小是 36 x 36 像素。 在大于 1920 x 1080 像素的图像中最小人脸大小相应更大。 缩小人脸大小可能会导致无法检测到某些人脸即便它们大于可检测的人脸大小下限。最大可检测人脸大小为 4096 x 4096 像素。大小在 36 x 36 至 4096 x 4096 像素大小范围之外的人脸将不会被检测到。 人脸识别输入要求 由于照片合成某些人脸可能无法识别例如 具有极端照明例如严重的背光的图像。有障碍物挡住了一只或两只眼睛。发型或胡须的差异。年龄使面貌发生变化。极端的面部表情。
二、人脸识别服务技术实战 环境准备 Azure 订阅 - 免费创建订阅Visual Studio IDE 或最新版本的 .NET Core。你的 Azure 帐户必须分配有 Cognitive Services Contributor 角色这样你才能同意负责任 AI 条款并创建资源。拥有 Azure 订阅后请在 Azure 门户中创建人脸资源以获取密钥和终结点。 部署后选择”转到资源”。 需要从创建的资源获取密钥和终结点以便将应用程序连接到人脸 API。可以使用免费定价层 (F0) 试用该服务然后再升级到付费层进行生产。
创建环境变量 在此示例中将凭据写入运行应用程序的本地计算机上的环境变量。 转到 Azure 门户。 如果在“先决条件”部分创建的资源部署成功请选择“后续步骤”下的“转到资源”。 在“密钥和终结点”页的“资源管理”下可以找到密钥和终结点。 你的资源密钥与你的 Azure 订阅 ID 不同。 若要为密钥和终结点设置环境变量请打开控制台窗口并按照操作系统和开发环境的说明进行操作。 若要设置 VISION_KEY 环境变量请将 your-key 替换为资源的其中一个密钥。若要设置 VISION_ENDPOINT 环境变量请将 your-endpoint 替换为资源的终结点。 [Windows] setx VISION_KEY your-key[Linux] setx VISION_ENDPOINT your-endpoint添加环境变量后可能需要重启任何正在运行的、将读取环境变量的程序包括控制台窗口。 [Windows] export VISION_KEYyour-key[Linux] export VISION_ENDPOINTyour-endpoint添加环境变量后请从控制台窗口运行 source ~/.bashrc使更改生效。 识别和验证人脸 安装客户端库 在安装 Python 后可以通过以下命令安装客户端库 pip install –upgrade azure-cognitiveservices-vision-face创建新的 Python 应用程序 创建新的 Python 脚本例如 quickstart-file.py。 然后在偏好的编辑器或 IDE 中打开它并粘贴以下代码。 import asyncio import io import os import sys import time import uuid import requests from urllib.parse import urlparse from io import BytesIO

To install this module, run:

python -m pip install Pillow

from PIL import Image, ImageDraw from azure.cognitiveservices.vision.face import FaceClient from msrest.authentication import CognitiveServicesCredentials from azure.cognitiveservices.vision.face.models import TrainingStatusType, Person, QualityForRecognition# This key will serve all examples in this document. KEY os.environ[VISION_KEY]# This endpoint will be used in all examples in this quickstart. ENDPOINT os.environ[VISION_ENDPOINT]# Base url for the Verify and Facelist/Large Facelist operations IMAGE_BASE_URL https://raw.githubusercontent.com/Azure-Samples/cognitive-services-sample-data-files/master/Face/images/# Used in the Person Group Operations and Delete Person Group examples.

You can call list_person_groups to print a list of preexisting PersonGroups.

SOURCE_PERSON_GROUP_ID should be all lowercase and alphanumeric. For example, mygroupname (dashes are OK).

PERSON_GROUP_ID str(uuid.uuid4()) # assign a random ID (or name it anything)# Used for the Delete Person Group example. TARGET_PERSON_GROUP_ID str(uuid.uuid4()) # assign a random ID (or name it anything)# Create an authenticated FaceClient. face_client FaceClient(ENDPOINT, CognitiveServicesCredentials(KEY)) Create the PersonGroup# Create empty Person Group. Person Group ID must be lower case, alphanumeric, and/or with -, _. print(Person group:, PERSON_GROUP_ID) face_client.person_group.create(person_group_idPERSON_GROUP_ID, namePERSON_GROUP_ID, recognition_modelrecognition_04)# Define woman friend woman face_client.person_group_person.create(PERSON_GROUP_ID, nameWoman)

Define man friend

man face_client.person_group_person.create(PERSON_GROUP_ID, nameMan)

Define child friend

child face_client.person_group_person.create(PERSON_GROUP_ID, nameChild) Detect faces and register them to each person# Find all jpeg images of friends in working directory (TBD pull from web instead) woman_images [https://raw.githubusercontent.com/Azure-Samples/cognitive-services-sample-data-files/master/Face/images/Family1-Mom1.jpg, https://raw.githubusercontent.com/Azure-Samples/cognitive-services-sample-data-files/master/Face/images/Family1-Mom2.jpg] man_images [https://raw.githubusercontent.com/Azure-Samples/cognitive-services-sample-data-files/master/Face/images/Family1-Dad1.jpg, https://raw.githubusercontent.com/Azure-Samples/cognitive-services-sample-data-files/master/Face/images/Family1-Dad2.jpg] child_images [https://raw.githubusercontent.com/Azure-Samples/cognitive-services-sample-data-files/master/Face/images/Family1-Son1.jpg, https://raw.githubusercontent.com/Azure-Samples/cognitive-services-sample-data-files/master/Face/images/Family1-Son2.jpg]# Add to woman person for image in woman_images:# Check if the image is of sufficent quality for recognition.sufficientQuality Truedetected_faces face_client.face.detect_with_url(urlimage, detection_modeldetection_03, recognition_modelrecognition_04, return_face_attributes[qualityForRecognition])for face in detected_faces:if face.face_attributes.quality_for_recognition ! QualityForRecognition.high:sufficientQuality Falsebreakface_client.person_group_person.add_face_from_url(PERSON_GROUP_ID, woman.person_id, image)print(face {} added to person {}.format(face.face_id, woman.person_id))if not sufficientQuality: continue# Add to man person for image in man_images:# Check if the image is of sufficent quality for recognition.sufficientQuality Truedetected_faces face_client.face.detect_with_url(urlimage, detection_modeldetection_03, recognition_modelrecognition_04, return_face_attributes[qualityForRecognition])for face in detected_faces:if face.face_attributes.quality_for_recognition ! QualityForRecognition.high:sufficientQuality Falsebreakface_client.person_group_person.add_face_from_url(PERSON_GROUP_ID, man.person_id, image)print(face {} added to person {}.format(face.face_id, man.person_id))if not sufficientQuality: continue# Add to child person for image in child_images:# Check if the image is of sufficent quality for recognition.sufficientQuality Truedetected_faces face_client.face.detect_with_url(urlimage, detection_modeldetection_03, recognition_modelrecognition_04, return_face_attributes[qualityForRecognition])for face in detected_faces:if face.face_attributes.quality_for_recognition ! QualityForRecognition.high:sufficientQuality Falseprint({} has insufficient quality.format(face))breakface_client.person_group_person.add_face_from_url(PERSON_GROUP_ID, child.person_id, image)print(face {} added to person {}.format(face.face_id, child.person_id))if not sufficientQuality: continue Train PersonGroup# Train the person group print(pg resource is {}.format(PERSON_GROUP_ID)) rawresponse face_client.person_group.train(PERSON_GROUP_ID, raw True) print(rawresponse)while (True):training_status face_client.person_group.get_training_status(PERSON_GROUP_ID)print(Training status: {}..format(training_status.status))print()if (training_status.status is TrainingStatusType.succeeded):breakelif (training_status.status is TrainingStatusType.failed):face_client.person_group.delete(person_group_idPERSON_GROUP_ID)sys.exit(Training the person group has failed.)time.sleep(5) Identify a face against a defined PersonGroup# Group image for testing against test_image https://raw.githubusercontent.com/Azure-Samples/cognitive-services-sample-data-files/master/Face/images/identification1.jpgprint(Pausing for 10 seconds to avoid triggering rate limit on free account…) time.sleep (10)# Detect faces face_ids []

We use detection model 3 to get better performance, recognition model 4 to support quality for recognition attribute.

faces face_client.face.detect_with_url(test_image, detection_modeldetection_03, recognition_modelrecognition_04, return_face_attributes[qualityForRecognition]) for face in faces:# Only take the face if it is of sufficient quality.if face.face_attributes.quality_for_recognition QualityForRecognition.high or face.face_attributes.quality_for_recognition QualityForRecognition.medium:face_ids.append(face.face_id)# Identify faces results face_client.face.identify(face_ids, PERSON_GROUP_ID) print(Identifying faces in image) if not results:print(No person identified in the person group) for identifiedFace in results:if len(identifiedFace.candidates) 0:print(Person is identified for face ID {} in image, with a confidence of {}..format(identifiedFace.face_id, identifiedFace.candidates[0].confidence)) # Get topmost confidence score# Verify facesverify_result face_client.face.verify_face_to_person(identifiedFace.face_id, identifiedFace.candidates[0].person_id, PERSON_GROUP_ID)print(verification result: {}. confidence: {}.format(verify_result.is_identical, verify_result.confidence))else:print(No person identified for face ID {} in image..format(identifiedFace.face_id))print() print(End of quickstart.) 使用 python 命令从应用程序目录运行人脸识别应用。 python quickstart-file.py输出 Person group: c8e679eb-0b71-43b4-aa91-ab8200cae7df face 861d769b-d014-40e8-8b4a-7fd3bc9b425b added to person f80c1cfa-b8cb-46f8-9f7f-e72fbe402bc3 face e3c356a4-1ac3-4c97-9219-14648997f195 added to person f80c1cfa-b8cb-46f8-9f7f-e72fbe402bc3 face f9119820-c374-4c4d-b795-96ae2fec5069 added to person be4084a7-0c7b-4cf9-9463-3756d2e28e17 face 67d626df-3f75-4801-9364-601b63c8296a added to person be4084a7-0c7b-4cf9-9463-3756d2e28e17 face 19e2e8cc-5029-4087-bca0-9f94588fb850 added to person 3ff07c65-6193-4d3e-bf18-d7c106393cd5 face dcc61e80-16b1-4241-ae3f-9721597bae4c added to person 3ff07c65-6193-4d3e-bf18-d7c106393cd5 pg resource is c8e679eb-0b71-43b4-aa91-ab8200cae7df msrest.pipeline.ClientRawResponse object at 0x00000240DAD47310 Training status: running.Training status: succeeded.Pausing for 10 seconds to avoid triggering rate limit on free account… Identifying faces in image Person for face ID 40582995-d3a8-41c4-a9d1-d17ae6b46c5c is identified in image, with a confidence of 0.96725. Person for face ID 7a0368a2-332c-4e7a-81c4-2db3d74c78c5 is identified in image, with a confidence of 0.96921. No person identified for face ID c4a3dd28-ef2d-457e-81d1-a447344242c4 in image. Person for face ID 360edf1a-1e8f-402d-aa96-1734d0c21c1c is identified in image, with a confidence of 0.92886.