码云 Gitee IDE 全新上线——支持 Git 管理的轻量在线编码环境
0 Watch 218 Star 615 Fork 208

kkkim / DFacePythonApache-2.0

加入码云
与超过 300 万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
基于深度学习的人脸检测与识别系统,Pytorch实现。 http://dface.tech
一键复制 编辑 Web IDE 原始数据 按行查看 历史
test_image.py 820 Bytes
kkkim 提交于 2017-12-28 11:36 . set default cpu version
import cv2
from dface.core.detect import create_mtcnn_net, MtcnnDetector
from dface.core import vision
if __name__ == '__main__':
# refer to your local model path
p_model = "./model_store/pnet_epoch.pt"
r_model = "./model_store/rnet_epoch.pt"
o_model = "./model_store/onet_epoch.pt"
#use cpu version set use_cuda=False, if you want to use gpu version set use_cuda=True
pnet, rnet, onet = create_mtcnn_net(p_model_path=p_model, r_model_path=r_model, o_model_path=o_model, use_cuda=False)
mtcnn_detector = MtcnnDetector(pnet=pnet, rnet=rnet, onet=onet, min_face_size=24)
img = cv2.imread("./test.jpg")
b, g, r = cv2.split(img)
img2 = cv2.merge([r, g, b])
bboxs, landmarks = mtcnn_detector.detect_face(img)
# print box_align
vision.vis_face(img2,bboxs,landmarks)

评论 ( 0 )

你可以在登录后,发表评论

搜索帮助