百度人脸识别 人脸识别模型

by Tirmidzi Faizal Aflahi

通过提尔米兹·法扎尔·阿弗拉希

当我说人脸识别很容易时,他们笑了。 但是可以。 (They laughed when I said Face Recognition was easy. But it can be.)

Maybe you have seen it before. Maybe some of you use a face unlock feature that some phones have. This technology called Face Recognition is simply amazing. But, do you think it is hard to make an application based on that technology? It is actually not that hard. You can even make it with less than 10 lines of codes! Seriously. Here is my Face Recognition Tensorflow tutorial, special for you.

也许您以前看过。 也许有些人使用某些手机具有的面部解锁功能。 这项称为人脸识别的技术简直是惊人的。 但是,您认为基于该技术创建应用程序很困难吗? 实际上并不难。 您甚至可以用少于10行的代码来制作它! 说真的 这是我的人脸识别Tensorflow教程,非常适合您。

TL; DR (TL;DR)

Here is the code, in case you don’t want to read the article. LOL.

如果您不想阅读本文,请使用以下代码。 大声笑。

from easyfacenet.simple import facenetimages = ['images/image1.jpg', 'images/image2.jpg', 'images/image3.jpg']
aligned = facenet.align_face(images)
comparisons = facenet.compare(aligned)print("Is image 1 and 2 similar? ", bool(comparisons[0][1]))
print("Is image 1 and 3 similar? ", bool(comparisons[0][2]))

And it will output the following:

它将输出以下内容:

Is image 1 and 2 similar?  True
Is image 1 and 3 similar?  False

Wait, wait. No tensorflow? There is tensorflow of course. For this tutorial, I use an algorithm called Facenet that was developed with tensorflow. And while it is easy enough for me to use Facenet out of the box while coding tensorflow syntax, I don’t think most of you would be comfortable with that.

等等。 没有张量流? 当然有张量流。 在本教程中,我使用由Tensorflow开发的称为Facenet的算法。 虽然我很容易在编码tensorflow语法时立即使用Facenet,但我认为大多数人都不愿意这样做。

So, I decided to create another interface on top of Facenet, which I called Easy Facenet. To install the library, you can just type

因此,我决定在Facenet之上创建另一个接口,称为Easy Facenet 。 要安装该库,您只需键入

pip install easyfacenet

And you are good to go!

而且你很好走!

The article should not end like this, should it? Of course not.

文章不应该这样结束吗? 当然不是

Let me explain to you, line by line, the tutorial. At the same time, we’ll cover how Face Recognition works in the first place.

让我逐行向您解释该教程。 同时,我们将首先介绍人脸识别的工作原理。

人脸识别 (Face Recognition)

So, how does Face Recognition work?

那么,人脸识别如何工作?

As you can see from the picture above, the steps are like this:

从上图可以看到,步骤是这样的:

  1. Get an input image which should contain a face(s)

    获取应包含面部输入图像

  2. You need to find where exactly the face is and put a bounding box around the face

    您需要找到面部的确切位置,并在面部周围放置一个边界框

  3. For consistency of the algorithm, you need to transform the picture, so that the position of mouth, nose, and eyes, are consistent for different pictures.

    为了确保算法的一致性,您需要对图片进行变换 ,以使嘴,鼻子和眼睛的位置对于不同的图片保持一致。

  4. Then crop it

    然后裁剪

  5. Input the cropped picture into the Facenet algorithm, which is a Deep Neural Network.

    将裁剪的图片输入到Facenet算法中,算法是一个深度神经网络。

  6. It will output a vector representation of that face. It was 128-dimensional vector back then, it is 512-dimensional right now.

    它将输出该脸部的矢量表示 。 当时是128维向量,现在是512维。

  7. Then you can do what you want with that representation. You can do classification, clustering, or just use a similarity computation between pictures.

    然后,您可以使用该表示形式执行所需的操作。 您可以进行分类聚类 ,或者仅使用图片之间的相似度 计算

Wow, that was a hell of a lot of stuff. Why is it so difficult? Well, basically you can group those 7 steps into 3 steps, which are,

哇,那真是太多了。 为什么这么难? 好吧,基本上,您可以将这7个步骤分为3个步骤,

  1. Alignment, input an image and output the aligned cropped face

    对齐 ,输入图像并输出对齐的裁切面

  2. Embedding, input the face and output the representation

    嵌入 ,输入面部并输出表示

  3. Comparison, compare those representations — are they similar or not?

    比较 ,比较这些表示形式-它们是否相似?

Because it’s only 3 simple steps, the code should be as simple as that, shouldn’t it?

因为只有3个简单的步骤,所以代码应该就这么简单,不是吗?

Yes, it can be, using easyfacenet.

是的,可以使用easyfacenet

最简单的人脸识别Tensorflow库 (The simplest Face Recognition Tensorflow library available)

Let’s break down the code bit by bit.

让我们逐一分解代码。

from easyfacenet.simple import facenet

Import the facenet file from a simple module. There are three methods you can use inside the file. They are, align_face, embedding, and compare.

从一个简单的模块导入facenet文件。 您可以在文件内部使用三种方法。 它们是align_faceembeddingcompare

Easily, you can tell that each of these methods represents each step for Face Recognition.

可以很容易地看出,这些方法中的每一个都代表面部识别的每个步骤。

images = ['images/image1.jpg', 'images/image2.jpg', 'images/image3.jpg']

Now we can define the images. What are those images? Well, this.

现在我们可以定义图像了。 这些图像是什么? 好吧,

And this.

还有这个

And also this.

还有这个

We got the images. Now the real deal.

我们得到了图像。 现在真正的交易。

步骤1.对齐 (Step 1. Alignment)

aligned = facenet.align_face(images)

The library will try to find the face inside the image and crop the face as well as pre-whiten the face. Prewhitening will make the training easier at training time, so in inference time, you will also need to prewhiten the image.

库将尝试在图像中查找人脸并裁剪人脸,并对人脸进行预增白 。 预加白会使训练时的训练变得容易,因此在推理时,您还需要将图像预加白。

The prewhitened aligned face will look like this.

经过预增白处理的对齐脸部将看起来像这样。

Now, you are ready for the next step. Take a breather and chew slowly!

现在,您已准备好进行下一步。 喘口气,慢慢咀嚼!

步骤2.嵌入 (Step 2. Embeddings)

Wait, wait. I don’t see embeddings in the example above? Well, that’s because the compare method already called embedding inside. If you want to use embedding somehow, use this.

等等。 我在上面的示例中看不到嵌入吗? 嗯,那是因为compare方法已经称为embed inside 。 如果您想以某种方式使用嵌入,请使用它。

embeddings = facenet.embedding(aligned)

The embeddings will look like this:

嵌入将如下所示:

步骤3.比较 (Step 3. Comparison)

comparisons = facenet.compare(aligned)

If you have 3 images, the comparisons variable will have 3 x 3 values. Which are permutations of each image compared to each other. In an example, if you want to get “is image 1 is similar to image 2?”, then

如果您有3张图片,则compares变量将具有3 x 3的值。 哪个是彼此比较的每个图像的排列 。 在示例中,如果要获取“ 图像1是否类似于图像2? “, 然后

print("Is image 1 and 2 similar? ", bool(comparisons[0][1]))

Is image 1 similar to image 3?

图片1与图片3类似吗?

print("Is image 1 and 3 similar? ", bool(comparisons[0][2]))

You didn’t forget already that the array is zero indexed, did you? Haha…

您还没有忘记数组是零索引的,是吗? 哈哈…

And, that’s it. You can get your comparison result just like that. The comparison technique I used is the cosine similarity. You can use any other similarity method you want. You can definitely use another method like clustering or classification. Something like the Siamese Network is the thing you need to look for.

就是这样 。 这样就可以得到比较结果。 我使用的比较技术是余弦相似度 。 您可以使用任何其他想要的相似性方法。 您绝对可以使用其他方法,例如聚类或分类。 您需要寻找像暹罗网络之类的东西。

接下来您该怎么办? (What can you do next?)

As I have said, this is the simplest Face Recognition Tensorflow library available. Therefore you can start to do your thing as quickly as possible.

正如我所说的,这是最简单的人脸识别Tensorflow库。 因此,您可以尽快开始做您的事情。

If you are the hacky one, you can explore the library and create the real Face Recognition Tensorflow code. Take a look at the code here because that is the cornerstone of the library. Furthermore, extend the code or you can create your own functionality.

如果您是位骇客,则可以浏览该库并创建真实的人脸识别Tensorflow代码。 在这里看看代码,因为那是库的基石。 此外,扩展代码或您可以创建自己的功能。

最后的想法 (Final Thoughts)

If you want to know about the paper behind this amazing technology, you can look here as well as here.

如果您想了解这项惊人技术背后的论文 ,可以在这里和这里查看 。

In conclusion, utilizing easyfacenet can help you tremendously in creating your face recognition project. Moreover, this Face Recognition library is maintained solely by me. It is easy for you if you want to ask for some kind of functionality.

总之,利用easyfacenet可以极大地帮助您创建人脸识别项目。 而且,这个人脸识别库完全由我自己 维护 如果您想要某种功能,这对您来说很容易。

As for the actual implementation for the other similarity method, I will bring you there in the next tutorial. Due to that reason, I will add the method exclusively inside the library.

至于其他相似性方法的实际实现,我将在下一个教程中带您到那里。 由于这个原因,我将在库中专门添加该方法。

Finally, if you want to read the original article, I originally published this on my blog post here at thedatamage. Of course, you can read many more posts from me there.

最后,如果您想阅读原始文章,我最初将此文章发布在我的博客文章中的datamage上 。 当然,您可以在这里阅读我的更多文章。

翻译自: https://www.freecodecamp.org/news/they-laughed-when-i-said-face-recognition-was-easy-but-it-can-be-6c1d5dd68099/

百度人脸识别 人脸识别模型

百度人脸识别 人脸识别模型_当我说人脸识别很容易时,他们笑了。 但是可以。...相关推荐

  1. 百度大脑FaceID人脸识别模型量化技术,确保算法精度无损加速一倍

    随着FaceID人脸识别技术在手机.IoT等设备的普及,受能耗和设备体积的限制,端上硬件的计算性能和存储能力相对较弱,这给端上人脸识别带来了新的挑战--需要更小更快更强的模型. 为了实现FaceID人 ...

  2. python人脸识别系统下载_简单的Python人脸识别系统

    案例一 导入图片 思路: 1.导入库 2.加载图片 3.创建窗口 4.显示图片 5.暂停窗口 6.关闭窗口 # 1.导入库 import cv2 # 2.加载图片 img = cv2.imread(' ...

  3. .net 识别一维码_天若OCR文字识别 v5.0 原创好用的OCR及翻译小工具

    一款非常好用的OCR及翻译小工具,集合百度.腾讯.有道.搜狗, 调用了各大网站的ocr接口,免费不限次数(有道免费接口有ip限制仅供娱乐). 1.对于搜狗的接口调用的还是http://ocr.shou ...

  4. 基于python的手写数字识别实验报告_联机手写数字识别实验报告

    1 联机手写数字识别设计 一.设计论述 模式识别是六十年代初迅速发展起来的一门学科. 由于它研究的是如何用机 器来实现人 ( 及某些动物 ) 对事物的学习. 识别和判断能力, 因而受到了很多科技 领域 ...

  5. 滴滴魅族手机人脸识别没有反应_滴滴顺风车人脸识别怎么破?滴滴人脸识别没反应解决方法...

    微信公众号--第一网约车: 是一个集网约车资讯.服务为一体的平台,关注微信公众号:第一网约车,就能掌握网约车最新.最全的资讯,赶紧加入,与2000万网约车车友交流吧! 5月19日零点,暂别市场一周的滴 ...

  6. python人脸识别门禁_用Python做人脸识别

    之前用facenet做了一个人脸识别的Demo,所以在此记录一下. 但因为我的水平十分有限,疏漏之处请多见谅. 1,这个流程大致是先用mtcnn检测人脸位置,得到一个人脸的bounding box. ...

  7. python人脸识别防小偷_基于python的人脸识别(检测人脸、眼睛、嘴巴、鼻子......)...

    本文链接:https://blog.csdn.net/James_Ray_Murphy/article/details/79209172 import numpy as np import cv2 # ...

  8. python验证码 识别代码不准_谈谈Python进行验证码识别的一些想法

    用python加"验证码"为关键词在baidu里搜一下,可以找到很多关于验证码识别的文章.我大体看了一下,主要方法有几类:一类是通过对图片进行处理,然后利用字库特征匹配的方法,一类 ...

  9. linux系统无法识别固态硬盘_重装Linux操作系统为什么识别不了硬盘

    近日朋友拿了台联想小新本子,靓丽的外观,轻薄的机体,价格也很有吸引力.无奈只有Win10系统,朋友欲采用普华Linux桌面系统来提供业务支撑,而因常规方法无法识别SSD固态硬盘,未能加载Linux系统 ...

最新文章

  1. python socket单线程通信
  2. 使用Apache Archiva搭建Maven Repository Server
  3. sublimeText3 工具
  4. CodeForces - 707C
  5. bat批处理删除指定N天前的文件
  6. ImportError: cannot import name ‘AliPay‘ from ‘alipay‘
  7. js 错误/异常处理
  8. 使用Sci-kit学习和XGBoost进行多类别分类:使用Brainwave数据的案例研究
  9. java中如何上送list集合_如何使用java中的list集合
  10. 孙鑫VC学习笔记:第十三讲 (二) 设置文档标题
  11. 电脑常用快捷键和操作你值得拥有!
  12. 计算机硬盘磁道损坏有什么症状,硬盘0磁道(0磁道)损坏的维修方法
  13. 做完一个网站重构项目的总结以及感想!
  14. MYSQL Day03~MySQL 常用命令汇总
  15. php课程设计感想,设计心得体会
  16. 计算机用户与权限如何设置密码,如何设置电脑用户权限_如何设置电脑使用时间...
  17. 漫画 | 中间件到底是什么东西?
  18. C# Monitor.TryEnter 源码跟踪
  19. streamsets自定义插件部署方案
  20. java实现第七届蓝桥杯搭积木

热门文章

  1. 嗖嗖移动 开发过程 9203 javaoop book2 Boss
  2. 序列化与反序列化注意事项 java
  3. 草稿 复选框绑定数据 1204
  4. 配置jdk1.7的环境变量
  5. 数据结构与算法-二叉树的名词概念与相关数据的计算
  6. javascript--DOM概念
  7. Tensorflow 相关概念
  8. Java CAS 和ABA问题
  9. 基于最大最小距离的分类数目上限K确定的聚类方法
  10. mongodb 总结