简介

关于人脸检测算法python库的初步认识2

使用CNN的实现人脸检测

简单说明

The example loads a pretrained model and uses it to find faces in images. 这个是使用已经训练好的模型

CNN model is much more accurate than the HOG based model shown in the face_detector.py CNN训练的模型相对于HOG有更好的精准性。 放在GPU上才能达到更好的速度。

code

#!/usr/bin/python
# The contents of this file are in the public domain. See LICENSE_FOR_EXAMPLE_PROGRAMS.txt
#
# This example shows how to run a CNN based face detector using dlib. The
# example loads a pretrained model and uses it to find faces in images. The
# CNN model is much more accurate than the HOG based model shown in the
# face_detector.py example, but takes much more computational power to
# run, and is meant to be executed on a GPU to attain reasonable speed.
#
# You can download the pre-trained model from:
# http://dlib.net/files/mmod_human_face_detector.dat.bz2
#
# The examples/faces folder contains some jpg images of people. You can run
# this program on them and see the detections by executing the
# following command:
# ./cnn_face_detector.py mmod_human_face_detector.dat ../examples/faces/*.jpg
#
#
# COMPILING/INSTALLING THE DLIB PYTHON INTERFACE
# You can install dlib using the command:
# pip install dlib
#
# Alternatively, if you want to compile dlib yourself then go into the dlib
# root folder and run:
# python setup.py install
#
# Compiling dlib should work on any operating system so long as you have
# CMake installed. On Ubuntu, this can be done easily by running the
# command:
# sudo apt-get install cmake
#
# Also note that this example requires Numpy which can be installed
# via the command:
# pip install numpy import glob
from imageio import imread
import dlib paths=glob.glob('faces/*.jpg')
cnn_face_detector = dlib.cnn_face_detection_model_v1('mmod_human_face_detector.dat')
win = dlib.image_window()
for path in paths:
img = imread(path)
dets = cnn_face_detector(img, 1)
for i,d in enumerate(dets):
print("Detection {}: Left: {} Top: {} Right: {} Bottom: {} Confidence: {}".format(
i, d.rect.left(), d.rect.top(), d.rect.right(), d.rect.bottom(), d.confidence))
rects = dlib.rectangles()
rects.extend([d.rect for d in dets])
win.clear_overlay()
win.set_image(img)
win.add_overlay(rects)
dlib.hit_enter_to_continue()

训练好的CNN模型

mmod_human_face_detector.dat

下载地址 http://dlib.net/files/mmod_human_face_detector.dat.bz2

关于 python 人脸检测库 dlib 的 初识 2的更多相关文章

  1. [深度学习] Python人脸识别库Deepface使用教程

    deepface是一个Python轻量级人脸识别和人脸属性分析(年龄.性别.情感和种族)框架,提供非常简单的接口就可以实现各种人脸识别算法的应用.deepface官方仓库为deepface.deepf ...

  2. [深度学习] Python人脸识别库face_recognition使用教程

    Python人脸识别库face_recognition使用教程 face_recognition号称是世界上最简单的开源人脸识别库,可以通过Python或命令行识别和操作人脸.face_recogni ...

  3. 【计算机视觉】如何使用于仕琪老师的libfacedetect人脸检测库

    前言 最近又开始进行人脸检测方向的内容,看到于仕琪老师的多角度检测想试一下,还不清楚原理,先测试效果如何. libfacedetect人脸检测库是深圳大学于仕琪老师发布的开源库,与opencv自带的人 ...

  4. 基于Android平台的简易人脸检测库

    代码地址如下:http://www.demodashi.com/demo/12135.html ViseFace 简易人脸检测库,不依赖三方库,可快速接入人脸检测功能. 项目依赖:compile 'c ...

  5. 如何快糙好猛的使用Shiqi.Yu老师的公开人脸检测库(附源码)

    前言 本次编写所用的库为于仕祺老师免费提供的人脸检测库.真心好用,识别率和识别速度完全不是Opencv自带的程序能够比拟的.将其配合Opencv的EigenFace算法,基本上可以形成一个小型的毕业设 ...

  6. dlib python 人脸检测与关键点标记

    http://blog.csdn.net/sunmc1204953974/article/details/49976045 人脸检测 #coding=utf-8 # -*- coding: utf-8 ...

  7. 人脸检测学习笔记(数据集-DLIB人脸检测原理-DLIB&OpenCV人脸检测方法及对比)

    1.Easily Create High Quality Object Detectors with Deep Learning 2016/10/11 http://blog.dlib.net/201 ...

  8. OpenCV + Python 人脸检测

    必备知识 Haar-like opencv api 读取图片 灰度转换 画图 显示图像 获取人脸识别训练数据 探测人脸 处理人脸探测的结果 实例 图片素材 人脸检测代码 人脸检测结果 总结 下午的时候 ...

  9. 人脸检测库libfacedetection介绍

    libfacedetection是于仕琪老师放到GitHub上的二进制库,没有源码,它的License是MIT,可以商用.目前只提供了windows 32和64位的release动态库,主页为http ...

  10. [深度学习工具]·极简安装Dlib人脸识别库

    [深度学习工具]·极简安装Dlib人脸识别库 Dlib介绍 Dlib是一个现代化的C ++工具箱,其中包含用于在C ++中创建复杂软件以解决实际问题的机器学习算法和工具.它广泛应用于工业界和学术界,包 ...

随机推荐

  1. 华为od机考2025A卷真题 -寻找重复代码

    题目描述与示例 题目 小明负责维护项目下的代码,需要查找出重复代码,用以支撑后续的代码优化,请你帮助小明找出重复的代码. 重复代码查找方法:以字符串形式给出两行代码text1,text2(字符串长度1 ...

  2. OAuth2.0 学习

  3. 关于全球化大规模混合云 Kubernetes Prometheus 监控体系标准化及 GitOps 自动化改进方案

    背景 现状 某司概况: PaaS/SaaS 公司,业务面向全球,包括 东南亚/南亚/中东/欧洲/非洲/美洲/东亚... 生产 k8s 集群数十套,生产非生产 >100 套(多种集群类型,各种公有 ...

  4. Stream流式编程工具类,开发必备

    把自己写的流式编程工具分享出来,不涉及公司业务,非常便捷,不用在业务层看到一条龙式的Stream代码了: 大家用的最多的应该是转list,转set,以及setVFromE: 觉得好用点个赞就行 imp ...

  5. 精选 14 款 .NET 开源、功能强大的快速开发框架,提高开发生产效率、避免工作996!

    前言 最近发现DotNetGuide技术社区微信交流群有不少小伙伴在问:.NET有哪些不错的快速开发框架推荐的? 选择一款全面且功能强大的快速开发框架能够帮助我们解决C#..NET项目中的很多重复工作 ...

  6. Linux 给用户 赋某个文件夹操作的权限(实现三权分立)

    Linux 给用户 赋某个文件夹操作的权限 这里用的ubuntu16.04 一.配置网站管理员 linux文件或目录的权限分为,读.写.可执行三种权限.文件访问的用户类别分为,文件创建者.与文件创建者 ...

  7. sql注入与防止sql注入

    数据库中的数据 sql代码 package com.zjw.jdbc2; import java.sql.Connection; import java.sql.DriverManager; impo ...

  8. 【SpringBoot异步导入Excel实战】从设计到优化的完整解决方案

    SpringBoot异步导入Excel实战:从设计到优化的完整解决方案 一.背景与需求 在企业级应用中,Excel导入是常见需求.当导入数据量较大时,同步处理可能导致接口阻塞,影响用户体验.本文结合S ...

  9. 数据库迁移的艺术:FastAPI生产环境中的灰度发布与回滚策略

    title: 数据库迁移的艺术:FastAPI生产环境中的灰度发布与回滚策略 date: 2025/05/17 21:06:56 updated: 2025/05/17 21:06:56 author ...

  10. Python单元测试标准库unittest简单学习

    1.背景 当需要测试较为复杂的module,class或者系统的功能时,如果一个一个的去测试就会显得很麻烦,如果每项测试又有一定的配置或者设置的话,比如每个测试都要新建一个对象之类的,那就更麻烦了.单 ...