Mtcnn进行人脸剪裁和对齐B
Mtcnn进行人脸剪裁和对齐
from scipy import misc
import tensorflow as tf
import detect_face
import cv2
# import matplotlib.pyplot as plt
from PIL import Image
import os
# import scipy.misc
# %pylab inline
fin = 'D:\data\male'
fout = 'D:\data\\rain\male'
minsize = 20 # minimum size of face
threshold = [0.6, 0.7, 0.7] # three steps's threshold
factor = 0.709 # scale factor
margin = 44
frame_interval = 3
batch_size = 1000
image_size = 182
input_image_size = 160 print('Creating networks and loading parameters') with tf.Graph().as_default():
gpu_options = tf.GPUOptions(allow_growth=True)
sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options, log_device_placement=False))
with sess.as_default():
pnet, rnet, onet = detect_face.create_mtcnn(sess, 'D:\\code\\real-time-deep-face-recognition-master\\20170512-110547') i= 0 for file in os.listdir(fin):
try: file_fullname = fin + '/' + file
img = misc.imread(file_fullname)
# i+= 1
# img = misc.imread(image_path)
bounding_boxes, _ = detect_face.detect_face(img, minsize, pnet, rnet, onet, threshold, factor)
nrof_faces = bounding_boxes.shape[0] # 人脸数目
print(nrof_faces)
#print('找到人脸数目为:{}'.format(nrof_faces)) # print(bounding_boxes) crop_faces = []
if nrof_faces != 0 :
for face_position in bounding_boxes:
face_position = face_position.astype(int)
print(face_position[0:4])
cv2.rectangle(img, (face_position[0], face_position[1]), (face_position[2], face_position[3]), (0, 255, 0), 2)
crop = img[face_position[1]:face_position[3],
face_position[0]:face_position[2], ]
# print(crop)
# crop = cv2.resize(crop, (96, 96), interpolation=cv2.INTER_CUBIC)
crop_faces.append(crop)
img2 = Image.open(file_fullname)
a = face_position[0:4]
# print('crop_faces:',crop_faces)
# a = [face_position[0:4]]
box = (a)
roi = img2.crop(box)
i = roi.resize((224, 224)) out_path = fout + '/' + file i.save(out_path)
print('success')
else:
pass
except:
pass
Mtcnn进行人脸剪裁和对齐B的更多相关文章
- Mtcnn进行人脸剪裁和对齐
from scipy import misc import tensorflow as tf import detect_face import cv2 import matplotlib.pyplo ...
- 第三十七节、人脸检测MTCNN和人脸识别Facenet(附源码)
在说到人脸检测我们首先会想到利用Harr特征提取和Adaboost分类器进行人脸检测(有兴趣的可以去一看这篇博客第九节.人脸检测之Haar分类器),其检测效果也是不错的,但是目前人脸检测的应用场景逐渐 ...
- MTCNN 实现人脸识别
MTCNN(Multi-task CNN) MTCNN难点 WIDER FACE等数据集为我们提供的图片并不是MTCNN支持的训练样本, 需要通过几个脚本将其转为MTCNN可以接受的数据集, 这些脚本 ...
- facenet 人脸识别(二)——创建人脸库搭建人脸识别系统
搭建人脸库 选择的方式是从百度下载明星照片 照片下载,downloadImageByBaidu.py # coding=utf-8 """ 爬取百度图片的高清原图 &qu ...
- 算法---FaceNet理论学习篇
FaceNet算法-理论学习篇 @WP20190228 ==============目 录============ 一.LFW数据集简介 二.FaceNet算法简介 FaceNet算法=MTCNN模型 ...
- FaceNet pre-trained模型以及FaceNet源码使用方法和讲解
Pre-trained models Model name LFW accuracy Training dataset Architecture 20180408-102900 0.9905 CASI ...
- 使用TensorRT对人脸检测网络MTCNN进行加速
前言 最近在做人脸比对的工作,需要用到人脸关键点检测的算法,比较成熟和通用的一种算法是 MTCNN,可以同时进行人脸框选和关键点检测,对于每张脸输出 5 个关键点,可以用来进行人脸对齐. 问题 刚开始 ...
- 机器学习--详解人脸对齐算法SDM-LBF
引自:http://blog.csdn.net/taily_duan/article/details/54584040 人脸对齐之SDM(Supervised Descent Method) 人脸对齐 ...
- 机器学习----人脸对齐的算法-ASM.AAM..CLM.SDM
引自:http://blog.csdn.net/linolzhang/article/details/55271815 人脸检测 早已比较成熟,传统的基于HOG+线性分类器 的方案检测效果已经相当不错 ...
随机推荐
- virtualenv 中 install flask 的小问题
最经在学习Python flask 框架 ,用virtualenv建立好我的flask虚拟环境后,执行 sudo pip install flask 并没有报错 我以为已经装上了flask,但当我进入 ...
- springAOP之代理
AOP是指面向切面编程. 在学习AOP之前先来了解一下代理,因为传说中的AOP其实也对代理的一种应用. 首先来看这样一段代码: public interface Hello { void say(St ...
- FileReader读取本地文件
FileReader是一种异步读取文件机制,结合input:file可以很方便的读取本地文件. 一.input:type[file] file类型的input会渲染为一个按钮和一段文字.点击按钮可打开 ...
- Hystrix 熔断机制原理
相关配置 circuitBreaker.enabled 是否开启熔断 circuitBreaker.requestVolumeThreshold 熔断最低触发请求数阈值 circuitBreaker. ...
- 4sumii
problem description: there is four number list named A,B,C,D; now you should out put the num of tup ...
- 再次实践 MySQL chart - 每天5分钟玩转 Docker 容器技术(166)
学习了 chart 结构和模板的知识后,现在重新实践一次 MySQL chart,相信会有更多收获. chart 安装前的准备 作为准备工作,安装之前需要先清楚 chart 的使用方法.这些信息通常记 ...
- 老司机告诉你高质量的Java代码是怎么练成的?
一提起程序员,首先想到的一定是"码农",对,我们是高产量的优质"码农",我们拥有超跃常人的逻辑思维以及不走寻常路的分析.判别能力,当然,我们也有良好的编码规范, ...
- Nginx服务器导致CSS无法解析不起效果
最近部署一个项目html,js正常加载,css也没有报404,css能够正常获取,只是浏览器无法解析,研究了一下发现,原来是配置Nginx的时候将/etc/nginx/nginx.conf的一行inc ...
- AUTOSAR - 标准文档下载
官网 https://www.autosar.org/ 文档分类 按功能分 按类型分 CLASSIC PLATFORM The AUTOSAR Classic Platform architectur ...
- 实现MyArrayList类深入理解ArrayList
ArrayList简介 ArrayList是一个动态数组,Array的复杂版本,它提供了动态的增加和减少元素,实现了ICollection和IList接口,灵活的设置数组的大小等好处. MyArray ...