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

使用Python face_recognition 人脸识别 - 5 人脸比对并打分

比对两张人脸编码后的照片,打印出相似度。


 

import face_recognition

# Often instead of just checking if two faces match or not (True or False), it's helpful to see how similar they are.
# You can do that by using the face_distance function.

# The model was trained in a way that faces with a distance of 0.6 or less should be a match. But if you want to
# be more strict, you can look for a smaller face distance. For example, using a 0.55 cutoff would reduce false
# positive matches at the risk of more false negatives.

# Note: This isn't exactly the same as a "percent match". The scale isn't linear. But you can assume that images with a
# smaller distance are more similar to each other than ones with a larger distance.

# Load some images to compare against
known_obama_image = face_recognition.load_image_file("./images/obama.jpg")
known_biden_image = face_recognition.load_image_file("./images/biden.jpg")

# Get the face encodings for the known images
obama_face_encoding = face_recognition.face_encodings(known_obama_image)[0]
biden_face_encoding = face_recognition.face_encodings(known_biden_image)[0]

known_encodings = [
    obama_face_encoding,
    biden_face_encoding
]

# Load a test image and get encondings for it
image_to_test = face_recognition.load_image_file("./images/obama2.jpg")
image_to_test_encoding = face_recognition.face_encodings(image_to_test)[0]

# See how far apart the test image is from the known faces
face_distances = face_recognition.face_distance(known_encodings, image_to_test_encoding)

for i, face_distance in enumerate(face_distances):
    print("The test image has a distance of {:.2} from known image #{}".format(face_distance, i))
    print("- With a normal cutoff of 0.6, would the test image match the known image? {}".format(face_distance < 0.6))
    print("- With a very strict cutoff of 0.5, would the test image match the known image? {}".format(face_distance < 0.5))
    print()

 

相关文章:

  • 天翼3G终端四大思路存疑
  • 使用Python face_recognition 人脸识别 - 6 从webcam中获取人脸
  • 使用Python face_recognition 人脸识别 - 7 使用knn分类器
  • ubuntu 使用gspca安装摄像头
  • 使用Python face_recognition 人脸识别 - 8 判断一张照片中是否存在人脸
  • 嵌入式系统软件的全过程质量保证
  • pluto1.17的一个国际化方面的bug
  • 使用Python face_recognition 人脸识别 - 10 解析一个视频文件中的人脸
  • iPhone开发初探
  • 使用Python face_recognition 人脸识别 - 11 识别出人脸并以矩形标记
  • 蜂巢 - Thinking in Agile - 我们需要怎样的软件过程(1)
  • 使用Python face_recognition 人脸识别 - 12 人脸图片1-N比对
  • 登月骗局是否存在?
  • 使用Python face_recognition 人脸识别 - 13 创建一个web 服务识别上传的图片是否包含人脸
  • 《BREW进阶与精通——3G移动增值业务的运营、定制与开发》连载之14---BREW精要之事件驱动模型...
  • 《剑指offer》分解让复杂问题更简单
  • 【comparator, comparable】小总结
  • 【从零开始安装kubernetes-1.7.3】2.flannel、docker以及Harbor的配置以及作用
  • 〔开发系列〕一次关于小程序开发的深度总结
  • ES6, React, Redux, Webpack写的一个爬 GitHub 的网页
  • Flex布局到底解决了什么问题
  • Github访问慢解决办法
  • Redux系列x:源码分析
  • SAP云平台运行环境Cloud Foundry和Neo的区别
  • Sass Day-01
  • Spring技术内幕笔记(2):Spring MVC 与 Web
  • Storybook 5.0正式发布:有史以来变化最大的版本\n
  • vue数据传递--我有特殊的实现技巧
  • 大整数乘法-表格法
  • 如何设计一个比特币钱包服务
  • 如何胜任知名企业的商业数据分析师?
  • 如何使用 JavaScript 解析 URL
  • 用 vue 组件自定义 v-model, 实现一个 Tab 组件。
  • 智能合约Solidity教程-事件和日志(一)
  • ​ ​Redis(五)主从复制:主从模式介绍、配置、拓扑(一主一从结构、一主多从结构、树形主从结构)、原理(复制过程、​​​​​​​数据同步psync)、总结
  • ​3ds Max插件CG MAGIC图形板块为您提升线条效率!
  • ​Linux·i2c驱动架构​
  • ​软考-高级-系统架构设计师教程(清华第2版)【第9章 软件可靠性基础知识(P320~344)-思维导图】​
  • # Pytorch 中可以直接调用的Loss Functions总结:
  • #我与Java虚拟机的故事#连载19:等我技术变强了,我会去看你的 ​
  • (4)STL算法之比较
  • (vue)el-checkbox 实现展示区分 label 和 value(展示值与选中获取值需不同)
  • (八十八)VFL语言初步 - 实现布局
  • (办公)springboot配置aop处理请求.
  • (过滤器)Filter和(监听器)listener
  • (求助)用傲游上csdn博客时标签栏和网址栏一直显示袁萌 的头像
  • (三维重建学习)已有位姿放入colmap和3D Gaussian Splatting训练
  • (转)shell中括号的特殊用法 linux if多条件判断
  • **python多态
  • .NET Core 控制台程序读 appsettings.json 、注依赖、配日志、设 IOptions
  • .NET导入Excel数据
  • .NET企业级应用架构设计系列之技术选型
  • [20161214]如何确定dbid.txt
  • [AutoSar]BSW_Com07 CAN报文接收流程的函数调用
  • [BZOJ 4129]Haruna’s Breakfast(树上带修改莫队)