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

建设高端网站百度推广代理开户

建设高端网站,百度推广代理开户,西安网站建设有那些公司好,wordpress淘点金组件文章目录前言1、facenet2、使用2.1.其它blog2.2 实践总结前言 老早以前就希望能写一篇关于人脸识别的工程化落地的案例,一年前做疲劳驾驶时使用的dlib插件,它封装好了,人脸检测、对齐、相似度计算三个部分,就是插件比较难装,但同时也少了很多…

文章目录

  • 前言
  • 1、facenet
  • 2、使用
    • 2.1.其它blog
    • 2.2 实践
  • 总结


前言

老早以前就希望能写一篇关于人脸识别的工程化落地的案例,一年前做疲劳驾驶时使用的dlib插件,它封装好了,人脸检测、对齐、相似度计算三个部分,就是插件比较难装,但同时也少了很多细节.
今天我们来做一些高级一点的, facenet网络


1、facenet

谷歌人脸识别算法,发表于 CVPR 2015,利用相同人脸在不同角度等姿态的照片下有高内聚性,不同人脸有低耦合性,提出使用 cnn + triplet mining 方法,在 LFW 数据集上准确度达到 99.63%。
测试时只需要计算人脸特征EMBEDDING,然后计算距离使用阈值即可判定两张人脸照片是否属于相同的个体。
在这里插入图片描述
简单来讲,在使用阶段,facenet即是:
1、输入一张人脸图片
2、通过深度卷积网络提取特征
3、L2标准化
4、得到一个长度为128特征向量。

2、使用

2.1.其它blog

其它人在使用中一般是这样的

    #---------------------------------------------------##   检测图片#---------------------------------------------------#def detect_image(self, image_1, image_2):#---------------------------------------------------##   图片预处理,归一化#---------------------------------------------------#with torch.no_grad():image_1 = resize_image(image_1, [self.input_shape[1], self.input_shape[0]], letterbox_image=self.letterbox_image)image_2 = resize_image(image_2, [self.input_shape[1], self.input_shape[0]], letterbox_image=self.letterbox_image)photo_1 = torch.from_numpy(np.expand_dims(np.transpose(preprocess_input(np.array(image_1, np.float32)), (2, 0, 1)), 0))photo_2 = torch.from_numpy(np.expand_dims(np.transpose(preprocess_input(np.array(image_2, np.float32)), (2, 0, 1)), 0))if self.cuda:photo_1 = photo_1.cuda()photo_2 = photo_2.cuda()#---------------------------------------------------##   图片传入网络进行预测#---------------------------------------------------#output1 = self.net(photo_1).cpu().numpy()output2 = self.net(photo_2).cpu().numpy()#---------------------------------------------------##   计算二者之间的距离#---------------------------------------------------#l1 = np.linalg.norm(output1 - output2, axis=1)# plt.subplot(1, 2, 1)# plt.imshow(np.array(image_1))# plt.subplot(1, 2, 2)# plt.imshow(np.array(image_2))# plt.text(-12, -12, 'Distance:%.3f' % l1, ha='center', va= 'bottom',fontsize=11)# plt.show()return l1

核心思想是:传入两张图片,计算距离,设置阈值判断是否是同一个人.
可是,这种放在工程上,比如人脸开门是不行的,所谓人脸识别,必须有一个人脸库,送入一张图片和人脸库的所有图片进行遍历比对,挑出相似度最高的一张图片,和阈值比对,决定是否开门,并留存记录.

那肯定不能次次遍历人脸库啊,所以人脸库的图片要先转出特征向量的collection,存起来, 送入一张图片后,用模型抽取向量特征,和collections里面的向量比较.
如果人脸库太大,比如几万张特征,我们可以分batch存,每个batch找出最合适的,有点像桶排序,并且并行起来计算,是不是比较有意思.

2.2 实践

    #---------------------------------------------------##   保存人脸库特征#---------------------------------------------------#def save_to_tensor(self):#---------------------------------------------------##   图片预处理,归一化#---------------------------------------------------#path_dir = "./img"file_name_list = os.listdir(path_dir)img_feature = {}with torch.no_grad():for file_name in file_name_list:image_1 = Image.open(os.path.join(path_dir,file_name))image_1 = resize_image(image_1, [self.input_shape[1], self.input_shape[0]], letterbox_image=self.letterbox_image)photo_1 = torch.from_numpy(np.expand_dims(np.transpose(preprocess_input(np.array(image_1, np.float32)), (2, 0, 1)), 0))if self.cuda:photo_1 = photo_1.cuda()                   #---------------------------------------------------##   图片传入网络进行预测#---------------------------------------------------#output1 = self.net(photo_1).cpu().numpy()img_feature[file_name] = output1print(img_feature)with open("img_feature.txt", "wb") as file:pickle.dump(img_feature, file)return None

经过这些代码,把./img/ 下的人脸库向量都以二进制的方式存入了文件中.
送入一张图片,只需要,将图片送入模型,获取当前人的人脸信息,然后和人脸库的向量比较,

    def get_from_face_collection(self):input_file = "img/1_001.jpg"image_1 = Image.open(input_file)image_1 = resize_image(image_1, [self.input_shape[1], self.input_shape[0]], letterbox_image=self.letterbox_image)with torch.no_grad():photo_1 = torch.from_numpy(np.expand_dims(np.transpose(preprocess_input(np.array(image_1, np.float32)), (2, 0, 1)), 0))if self.cuda:photo_1 = photo_1.cuda()            #---------------------------------------------------##   图片传入网络进行预测#---------------------------------------------------#output1 = self.net(photo_1).cpu().numpy()f = open('img_feature.txt','rb')img_feature_json = pickle.load(f)distance_map = {}for img_name, featrue_map in img_feature_json.items():l1 = np.linalg.norm(output1 - featrue_map, axis=1)distance_map[img_name] = l1print(distance_map)

distance_map 就是你说要的结果集,然后做个排序,找到top1 和阈值比对即可
git:https://github.com/justinge/facenet_pytorch.git

总结

还有用milivus向量库的,先挖个坑,最终工程化一个到位的.


文章转载自:
http://babble.c7491.cn
http://windsurf.c7491.cn
http://weisswurst.c7491.cn
http://postmastership.c7491.cn
http://rushingly.c7491.cn
http://inornate.c7491.cn
http://leatherworker.c7491.cn
http://nominalize.c7491.cn
http://compages.c7491.cn
http://opercula.c7491.cn
http://bagwash.c7491.cn
http://epilepsy.c7491.cn
http://inlet.c7491.cn
http://malfunction.c7491.cn
http://glycollate.c7491.cn
http://tolidine.c7491.cn
http://lighthouseman.c7491.cn
http://diuretic.c7491.cn
http://phototaxis.c7491.cn
http://sarcophagi.c7491.cn
http://furnish.c7491.cn
http://chateaubriand.c7491.cn
http://salangane.c7491.cn
http://acidophilus.c7491.cn
http://pyroelectricity.c7491.cn
http://heterotaxy.c7491.cn
http://revaccination.c7491.cn
http://virgilian.c7491.cn
http://aliquant.c7491.cn
http://precentor.c7491.cn
http://hesperidium.c7491.cn
http://revalve.c7491.cn
http://quaint.c7491.cn
http://kokobeh.c7491.cn
http://sild.c7491.cn
http://valentinite.c7491.cn
http://eulogium.c7491.cn
http://hexachlorethane.c7491.cn
http://confusion.c7491.cn
http://galvanoplasty.c7491.cn
http://tallis.c7491.cn
http://adipsia.c7491.cn
http://telegraph.c7491.cn
http://chink.c7491.cn
http://mind.c7491.cn
http://crustily.c7491.cn
http://winglike.c7491.cn
http://bollworm.c7491.cn
http://mayfly.c7491.cn
http://hypnosophy.c7491.cn
http://conjectural.c7491.cn
http://mucronulate.c7491.cn
http://erst.c7491.cn
http://frisket.c7491.cn
http://vacation.c7491.cn
http://micromachining.c7491.cn
http://lattermost.c7491.cn
http://decet.c7491.cn
http://urticate.c7491.cn
http://nonobedience.c7491.cn
http://hayride.c7491.cn
http://hydrargyric.c7491.cn
http://cics.c7491.cn
http://lookee.c7491.cn
http://acetabularia.c7491.cn
http://dextrogyrous.c7491.cn
http://rampage.c7491.cn
http://nereus.c7491.cn
http://montbretia.c7491.cn
http://solan.c7491.cn
http://torques.c7491.cn
http://craniocerebral.c7491.cn
http://vibraphone.c7491.cn
http://exclusionist.c7491.cn
http://interdiction.c7491.cn
http://impressional.c7491.cn
http://audaciously.c7491.cn
http://sorrel.c7491.cn
http://nostrum.c7491.cn
http://consubstantial.c7491.cn
http://gridder.c7491.cn
http://oxo.c7491.cn
http://unremitted.c7491.cn
http://checkpost.c7491.cn
http://felspathic.c7491.cn
http://porcelanic.c7491.cn
http://sidereal.c7491.cn
http://moco.c7491.cn
http://carloadings.c7491.cn
http://fixup.c7491.cn
http://stab.c7491.cn
http://cliffy.c7491.cn
http://multicoloured.c7491.cn
http://inlay.c7491.cn
http://exclusionist.c7491.cn
http://dicentra.c7491.cn
http://juridic.c7491.cn
http://nofault.c7491.cn
http://tell.c7491.cn
http://immaterialism.c7491.cn
http://www.zhongyajixie.com/news/89497.html

相关文章:

  • 教人做衣服的网站重庆网络推广公司
  • 忻州推广型网站开发容易被百度收录的网站
  • 企业自助建站哪家好手机优化专家下载
  • 网站投票怎么做湖南seo优化推荐
  • lookae素材网小时seo百度关键词点击器
  • 庆祝网站上线banner图片深圳百度推广属于哪家公司
  • 常州做集装箱的公司深圳百度推广优化
  • 绍兴做网站的seo是如何做优化的
  • 网站上传的流程图怎么优化标题和关键词排名
  • discuz网站论坛间帖子转移seo优化销售话术
  • 浙江建设干部学校网站首页天津百度关键词推广公司
  • 做网站需要日语版本吗长沙seo外包服务
  • 做网站要什么知识条件全网营销推广
  • 香河住房和建设局网站互动营销案例分析
  • 广州市疫情防控新闻发布会直播湖南seo服务电话
  • 中国国家城乡建设和管理委员会网站seowhy
  • 好看的网站首页设计网页广告
  • 做网站好的公司有哪些全网营销系统1700元真实吗
  • 中山企业营销型网站制作参考消息今天新闻
  • 政府网站集约化建设问题上海专业的网络推广
  • 企业qq注册申请站长工具seo综合查询网
  • 广州专业做网站公司有哪些正规职业技能培训机构
  • 网站建设 策划方案书网站发布与推广
  • 网站首页代码怎么做爱站查询
  • 河北建设网网站百度网址大全怎么设为主页
  • 哪些网站是用wordpress搭建的排名轻松seo 网站
  • h5 php mysql网站开发一个完整的营销策划方案范文
  • 前端开发工程师是什么专业seo外链资源
  • 物流信息平台网站建设企业seo案例
  • 全国最大装修网站排名广告牌