facenet代码实现之人脸聚类

本文介绍了如何使用Facenet进行人脸聚类,包括数据清洗、安装环境、解决运行错误,以及调整阈值得到满意结果的过程。通过调整阈值,作者发现Facenet能有效地对人脸进行聚类,但对某些特定情况可能需要进一步优化。
摘要由CSDN通过智能技术生成

人脸聚类_facenet代码实现

网上我能查到的大多是实现图片预处理——运行人脸对齐程序align_dataset_mtcnn.py,还有测试模型精度的validate_on_lfw.py,但是这次领导让我和同事玩玩人脸聚类,因为新到了一批人脸数据(就是上个shell脚本每天传回来的),领导当时让我们试试无监督分类。任务要求是首先清洗数据,将识别不到人脸的图片删除(模糊、黑夜、遮挡这类),然后对剩下图片进行无监督分类。不过我这里用的不是公司数据啦。

然后我上周因为一直在测shell脚本,所以数据清洗是由我同事完成的。她写了一个判断图片黑像素占比的脚本,将黑色图片先挑出作为初步数据清洗。这个效果其实还可以,只是会将穿黑色衣服的人也挑出来。然后第二部数据清洗她找到了mtcnn算法,检测人脸区域检测与人脸关键点,检测不到人像的图片删除。

后来我们找聚类算法的时候找到了facenet里面的contributed里的cluster,实现了人脸聚类的功能,并且它第一步也是创立mtcnn网络,检测人脸和关键点,所以我们就把数据清洗只留下了删除黑色图片的预处理,剩下的都是用cluster完成。

代码下载地址:https://github.com/davidsandberg/facenet
当然还需要下载模型,网上其实也有,如果有人需要也可以跟我要,不过也没人看我的文章,算了算了。

这个代码我新建了虚拟环境,安装了tensorflow-gpu=1.7 和python=3.6,我的电脑本身有cuda9.0,所以可以运行gpu版本的tensorflow,如果不是的话,也可以用cpu跑啦,就是慢一点。

我看了网上有很多对facenet源码进行解读的文章,有几篇我觉得很好
https://www

  • 3
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
Abstract—Clustering face images according to their latent identity has two important applications: (i) grouping a collection of face images when no external labels are associated with images, and (ii) indexing for efficient large scale face retrieval. The clustering problem is composed of two key parts: representation and similarity metric for face images, and choice of the partition algorithm. We first propose a representation based on ResNet, which has been shown to perform very well in image classification problems. Given this representation, we design a clustering algorithm, Conditional Pairwise Clustering (ConPaC), which directly estimates the adjacency matrix only based on the similarities between face images. This allows a dynamic selection of number of clusters and retains pairwise similarities between faces. ConPaC formulates the clustering problem as a Conditional Random Field (CRF) model and uses Loopy Belief Propagation to find an approximate solution for maximizing the posterior probability of the adjacency matrix. Experimental results on two benchmark face datasets (LFW and IJB-B) show that ConPaC outperforms well known clustering algorithms such as k-means, spectral clustering and approximate Rank-order. Additionally, our algorithm can naturally incorporate pairwise constraints to work in a semi-supervised way that leads to improved clustering performance. We also propose an k-NN variant of ConPaC, which has a linear time complexity given a k-NN graph, suitable for large datasets. Index Terms—face clustering, face representation, Conditional Random Fields, pairwise constraints, semi-supervised clustering.
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值