资源简介
python dlib库,训练人脸的68个特征点检测器。包含数据集,源码。详细可以参考我的博客:http://blog.csdn.net/hongbin_xu/article/details/78511923
代码片段和文件信息
# coding: utf-8
#
# This example program shows how to use dlib‘s implementation of the paper:
# One Millisecond Face Alignment with an Ensemble of Regression Trees by
# Vahid Kazemi and Josephine Sullivan CVPR 2014
import os
import cv2
import dlib
import glob
current_path = os.getcwd()
faces_path = current_path + ‘/examples/faces‘
# 训练部分
# 参数设置
options = dlib.shape_predictor_training_options()
options.oversampling_amount = 300
options.nu = 0.05
options.tree_depth = 2
options.be_verbose = True
# 导入打好了标签的xml文件
training_xml_path = os.path.join(faces_path “training_with_face_landmarks.xml“)
# 进行训练,训练好的模型将保存为predictor.dat
dlib.train_shape_predictor(training_xml_path “predictor.dat“ options)
# 打印在训练集中的准确率
print “\nTraining accuracy:{0}“.format(dlib.test_shape_predictor(training_xml_path “predictor.dat“))
# 导入测试集的xml文件
testing_xml_path = os.path.join(faces_path “testing_with_face_landmarks.xml“)
# 打印在测试集中的准确率
print “\Testing accuracy:{0}“.format(dlib.test_shape_predictor(testing_xml_path “predictor.dat“))
# 测试部分
predictor = dlib.shape_predictor(“predictor.dat“)
detector = dlib.get_frontal_face_detector()
print(“Showing detections and predictions on the images in the faces folder...“)
for f in glob.glob(os.path.join(faces_path “*.jpg“)):
print(“Processing file: {}“.format(f))
img = cv2.imread(f)
img2 = cv2.cvtColor(img cv2.COLOR_BGR2GRAY)
dets = detector(img2 1)
print(“Number of faces detected: {}“.format(len(dets)))
for index face in enumerate(dets):
print(‘face {}; left {}; top {}; right {}; bottom {}‘.format(index face.left() face.top() face.right() face.bottom()))
# left = face.left()
# top = face.top()
# right = face.right()
# bottom = face.bottom()
# cv2.rectangle(img (left top) (right bottom) (0 255 0) 3)
# cv2.namedWindow(f cv2.WINDOW_AUTOSIZE)
# cv2.imshow(f img)
shape = predictor(img face)
# print(shape)
# print(shape.num_parts)
for index pt in enumerate(shape.parts()):
print(‘Part {}: {}‘.format(index pt))
pt_pos = (pt.x pt.y)
cv2.circle(img pt_pos 2 (255 0 0) 1)
#print(type(pt))
#print(“Part 0: {} Part 1: {} ...“.format(shape.part(0) shape.part(1)))
cv2.namedWindow(f cv2.WINDOW_AUTOSIZE)
cv2.imshow(f img)
cv2.waitKey(0)
cv2.destroyAllWindows()
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-11-12 14:34 train_shpe_detector\
目录 0 2017-11-12 14:23 train_shpe_detector\examples\
目录 0 2017-11-02 21:02 train_shpe_detector\examples\faces\
文件 89619 2017-11-02 21:02 train_shpe_detector\examples\faces\2007_007763.jpg
文件 41770 2017-11-02 21:02 train_shpe_detector\examples\faces\2008_001009.jpg
文件 65344 2017-11-02 21:02 train_shpe_detector\examples\faces\2008_001322.jpg
文件 92641 2017-11-02 21:02 train_shpe_detector\examples\faces\2008_002079.jpg
文件 91349 2017-11-02 21:02 train_shpe_detector\examples\faces\2008_002470.jpg
文件 79316 2017-11-02 21:02 train_shpe_detector\examples\faces\2008_002506.jpg
文件 93821 2017-11-02 21:02 train_shpe_detector\examples\faces\2008_004176.jpg
文件 110034 2017-11-02 21:02 train_shpe_detector\examples\faces\2008_007676.jpg
文件 79462 2017-11-02 21:02 train_shpe_detector\examples\faces\2009_004587.jpg
文件 648373 2017-11-02 21:02 train_shpe_detector\examples\faces\bald_guys.jpg
文件 175216 2017-11-02 21:02 train_shpe_detector\examples\faces\dogs.jpg
文件 4166 2017-11-02 21:02 train_shpe_detector\examples\faces\image_me
文件 1879 2017-11-02 21:02 train_shpe_detector\examples\faces\testing.xm
文件 71586 2017-11-02 21:02 train_shpe_detector\examples\faces\testing_with_face_landmarks.xm
文件 1445 2017-11-02 21:02 train_shpe_detector\examples\faces\training.xm
文件 51828 2017-11-02 21:02 train_shpe_detector\examples\faces\training_with_face_landmarks.xm
文件 16601169 2017-11-12 15:23 train_shpe_detector\predictor.dat
文件 2425 2017-11-12 14:50 train_shpe_detector\train_shpe_detector.py
相关资源
- Python核心编程第3版PDF高清晰完整中文
- Python数据处理
- Python从入门到实践--完整版本(高清)
- python基础知识笔记总结
- Francois Chollet-Deep Learning with Python2528
- python实现CNN中文文本分类
- Deep learning with Python Francois Chollet
- Python程序设计第二版配套资源
- opencv_python-3.4.3+contrib-cp35-cp35m-win_amd
- Python数据挖掘实战.zip
- 基于python下的 车牌识别代码 的车牌数
- 基于python下的 车牌识别代码
- python ppt
- python数据分析参考案例
- (完整版)learn python 3 the Hard Way
- Python-智联51job招聘需求挖掘采集和分
- Python趣味编程.pdf
- python数据挖掘概念、方法与实践.pdf
- opencv_python-3.2.0-cp36-cp36m-win_amd64.whl25
- 量化投资以python为工具 数据及代码
- Python语言程序设计基础-嵩天第2版
- ABAQUS GUI程序开发指南 PYTHON语言
- 自编码推荐算法的实现
- 《Python编程从入门到实践》源代码文
- 小白入门宝典 python魔力手册 高清完
- wxPython2.8-win64-unicode-2.8.12.1-py27.exe
- 爱上PYTHON 一日精通PYTHON编程
- Python编程快速上手——让繁琐工作自
- python 运行文件及geckodriver
- Python Data Analytics
评论
共有 条评论