Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

newlandface

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

newlandface

A Lightweight Face Detection and Facial Attribute Analysis Framework (Age, Gender, Emotion) for Python

  • 1.0.3
  • PyPI
  • Socket score

Maintainers
1

typora-copy-images-to: upload

newlandface

[TOC]

newlandface 是一个轻量级的人脸检测和多属性分析(年龄、性别、标签)分析工具,使用python语言,集成了部分开源库Dlib、mtcnn等工具,该库主要是基于Keras和TensorFlow来进行开发的。

Installation 安装

The easiest way to install newlandface is to download it from PyPI.

pip install newlandface

文件结构

│ README.md │ requirements.txt │ setup.py │
├─newlandface │ │ nlface.py │ │ init.py │ │
│ ├─basemodels │ │ │ DeepID.py │ │ │ DlibResNet.py │ │ │ Facenet.py │ │ │ FbDeepFace.py │ │ │ OpenFace.py │ │ │ VGGFace.py │ │ │ init.py │ │
│ ├─commons │ │ │ distance.py │ │ │ functions.py │ │ │ realtime.py │ │ │ init.py │ │
│ ├─extendedmodels │ │ │ Age.py │ │ │ Emotion.py │ │ │ Gender.py │ │ │ Race.py │ │ │ init.py │ │
│ ├─models │ │ face-recognition-ensemble-model.txt │ │ init.py │
└─tests │ testFaceAttr_video.py │ testFaceDetect_img.py │ testFacePoints_img.py │
└─dataset img1.jpg img13.jpg img14.jpg ...

测试代码

1.1 人脸检测代码

from newlandface import nlface
import cv2
# 模型加载
nlface.load_model()
image = cv2.imread("./dataset/test1.jpg")
# 人脸检测
faceObjs = nlface.detect_face(image)
# 显示人脸框
if faceObjs is not 0:
    for idx, rect in enumerate(faceObjs):
        image = nlface.show_face(image,rect)
else:
    print("no face detect")
    os._exit(0)
cv2.imshow("test",image)
cv2.waitKey()

facedetect

1.2 人脸68点检测

1.2.1 直接调用show_face_points函数进行显示

核心函数:detect_face、show_face_points

from newlandface import nlface
import cv2
cv2.namedWindow("test",0)
# 模型加载
nlface.load_model()
image = cv2.imread("./dataset/test1.jpg")
# 人脸检测
faceObjs = nlface.detect_face(image)
# 显示人脸框
if faceObjs is not 0:
    for idx, rect in enumerate(faceObjs):
        image = nlface.show_face_points(image,rect)
else:
    print("no face detect")
    os._exit(0)
cv2.imshow("test",image)
cv2.waitKey()
1.2.2 调用点检测模块,自行画图

核心函数:detect_face、detect_points、show_face

from newlandface import nlface
import cv2
cv2.namedWindow("test",0)
# 模型加载
nlface.load_model()
image = cv2.imread("./dataset/test1.jpg")
# 人脸检测
faceObjs = nlface.detect_face(image)
if faceObjs is not 0:
    for idx, rect in enumerate(faceObjs):
        # 人脸68点检测
		points = nlface.detect_points(image,rect)
        # 显示人脸框、68点
		image = nlface.show_face(image,rect)
        for i,point in enumerate(points):
            cv2.circle(image,(point[0],point[1]),2,(0,0,255),-1)
            cv2.imshow("test",image)
        cv2.waitKey(1)    
else:
    print("no face detect")
    os._exit(0)
cv2.imshow("test",image)
cv2.waitKey()

facepoints_test

1.3 人脸属性分析

核心函数:detect_face、detect_points、show_face

属性开放:emotion(表情)、age(年龄)、gender(性别)

属性检测耗时标签类型
emotion表情30ms['angry', 'disgust', 'fear', 'happy', 'sad', 'surprise', 'neutral']
age年龄130ms1-100
gender性别170mswoman、man

注意:不同的模块耗时不一,所以如果调用摄像头的时候,要注意实时性上的要求。

from newlandface import nlface
import cv2
cv2.namedWindow("test",0)
# 模型加载
nlface.load_model()
image = cv2.imread("./dataset/test1.jpg")
# 人脸检测
faceObjs = nlface.detect_face(image)
if faceObjs is not 0:
    for idx, rect in enumerate(faceObjs):
        # 人脸属性分析
        actions = ['emotion', 'age', 'gender']
        attribute = nlface.analyze(image, faceObjs[idex],actions = actions)
        # 显示人脸框\属性
		image = nlface.show_face(image,rect)
        image = nlface.show_face_attr(image, faceObjs[idex], attribute, actions)
        cv2.imshow("test",image)
        cv2.waitKey(1)    
else:
    print("no face detect")
    os._exit(0)
cv2.imshow("test",image)
cv2.waitKey()

faceAttr

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc