GithubHelp home page GithubHelp logo

seetaface6python's Introduction

seetaFace6 python api(10分钟搞定商业级别人脸识别应用)

1. 简介

项目基于SeetaFace6 封装的python接口,使用简便,性能与原始c++模块基本一致, 模块上SeetaFace6 相较于SeetaFace2 上训练样本更多,准确率更高,提供的功能和识别模型也更多 接口封装上,放弃了使用 pybind11 封装python 接口,接口函数完全纯 c 接口,使用 ctypes 调用,解除不同版本python使用上的限制 10分钟搞定是夸张说法,但本次项目基本涵盖了普通商用人脸识别所需的大部分功能,并且使用简单。

支持 windows/linux 下的所有python 版本

  python3.5及以下版本的python需要将seetaface/back_py目录下的 api.pyface_struct.py 两个文件放到setaface目录下,替换setaface目录下的api.pyface_struct.py 文件

2.下载模型(已下载则忽略)

百度网盘:https://pan.baidu.com/share/init?surl=LlXe2-YsUxQMe-MLzhQ2Aw 提取码:ngne
将下载的所有 *.csta 模型文件 放入 seetaFace6Python/seetaface/model 目录下

3. 运行示例

3.1 运行依赖

当前需要机器同时支持以下几个指令集 AVX | SSE | FMA ,请先确认机器是否同时支持它们

    示例依赖 opencv ,安装opencv(若已有cv2模块则忽略)

    pip install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-python

3.2 演示demo

  linux下则需要添加库路径

    临时:
        ubuntu:
            export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${seetaFace6Python目录路径}/seetaface/lib/ubuntu
        centos:
            export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${seetaFace6Python目录路径}/seetaface/lib/centos
    永久:
        ubuntu:
            sudo echo  ${seetaFace6Python目录路径}/seetaface/lib/ubuntu  > /etc/ld.so.conf.d/seetaface6.conf
        centos:
            sudo echo  ${seetaFace6Python目录路径}/seetaface/lib/centos  > /etc/ld.so.conf.d/seetaface6.conf
        
        sudo ldconfig
    
    进入 seetaFace6Python 目录下,有各种基本功能的使用demo

seetaface6python's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

seetaface6python's Issues

similarity calculation accuracy problem

i don't know how to transfer numpy (ndarray type) to c_float_Array_1024 structure, i read the seetaface python api, and see the compare_feature_np methods, so i use self.seetaFace.get_feature_numpy(feature2) to get numpy ndarray feature description, but the similarity down from 0.99 to 0.68? i don't know why? And i wonder if there is some solution, thanks a lot.
image

Floating point exception

在阿里云服务器运行python face_landmark_demo.py引发Floating point exception错误,是gcc版本不同造成的吗

怎么使用Seetaface6中一些数据结构

你好,在用你的封装,效果很好,就是活体检测假脸判断很多时候都是错的。
我现在主要的问题是:如何在python中使用Seetaface6中的一些数据结构:

例如下面一段代码(C++)

        double eyeSpan = sqrt(pow((points[1].x - points[0].x), 2) + pow((points[1].y - points[0].y), 2));
        //seeta::Size eyeSize(99, 99);

        seeta::Size eyeSize(102, 102);
        //·ÀÖ¹±ß½çÒç³ö
        int leftEyePointX = std::max(int(points[0].x - eyeSpan / 2), 0);
        int leftEyePointY = std::max(int(points[0].y - eyeSpan / 2), 0);
        leftEyePointX = std::min(int(image.width - eyeSpan / 2), leftEyePointX);
        leftEyePointY = std::min(int(image.height - eyeSpan / 2), leftEyePointY);

        double leftEyeSpanTemp = std::max(int(eyeSpan) , 1);
        int leftEyeSpanX = (leftEyePointX + leftEyeSpanTemp > image.width - 1) ? image.width - 1 - leftEyePointX: leftEyeSpanTemp;
        int leftEyeSpanY = (leftEyePointY + leftEyeSpanTemp > image.height - 1) ? image.height - 1 - leftEyePointY : leftEyeSpanTemp;
        leftEyeSpanTemp = std::min(int(leftEyeSpanX), int(leftEyeSpanY));
        

        int rightEyePointX = std::max(int(points[1].x - eyeSpan / 2), 0);
        int rightEyePointY = std::max(int(points[1].y - eyeSpan / 2), 0);
        rightEyePointX = std::min(int(image.width - eyeSpan / 2), rightEyePointX);
        rightEyePointY = std::min(int(image.height - eyeSpan / 2), rightEyePointY);


        double rightEyeSpanTemp = std::max(int(eyeSpan) , 1);
        int rightEyeSpanX = (rightEyePointX + rightEyeSpanTemp > image.width - 1) ? image.width - 1 - rightEyePointX: rightEyeSpanTemp;
        int rightEyeSpanY = (rightEyePointY + rightEyeSpanTemp > image.height - 1) ? image.height - 1 - rightEyePointY : rightEyeSpanTemp;
        rightEyeSpanTemp = std::min(int(rightEyeSpanX), int(rightEyeSpanY));

        //std::cout << "----x:" << leftEyePointX << ", y:" << leftEyePointY << ",width:" << leftEyeSpanTemp;
        //std::cout << "  x:" << rightEyePointX << ", y:" << rightEyePointY << ",width:" << rightEyeSpanTemp << std::endl << std::endl;

        seeta::Image leftEye = seeta::crop_resize(simage, seeta::Rect(leftEyePointX, leftEyePointY, leftEyeSpanTemp, leftEyeSpanTemp), eyeSize);

        seeta::Image rightEye = seeta::crop_resize(simage, seeta::Rect(rightEyePointX, rightEyePointY, rightEyeSpanTemp, rightEyeSpanTemp), eyeSize);

        leftstate = (EYE_STATE) m_impl->detect(leftEye);
        rightstate = (EYE_STATE) m_impl->detect(rightEye);

我在改写成python的时候,基本的数学计算还好改,但是涉及到数据结构的时候,一直没找到python下对应的
seeta::Image
seeta::crop_resize

可以给点建议吗?

[ERROR]: [src/runtime/instruction.cpp:65]

Check failed: (stack.size() >= static_cast<size_t>(return_size)).
terminate called after throwing an instance of 'ts::api::Exception'
what(): [src/runtime/instruction.cpp:65]: Check failed: (stack.size() >= static_cast<size_t>(return_size)).

windows10直接运行报错

windows10下直接运行demo会报错
报错行代码
dll = CDLL(os.path.join(LIB_PATH,"libFaceAPI.dll"))
报错内容:
osError: [Winerror 126] 找不到指定的模块
该怎么解决呢?急

ERROR: open the model file:seetaface/model/face_detector.csta failed!

ERROR: open the model file:seetaface/model/face_detector.csta failed!
ERROR: open the model file:seetaface/model/face_landmarker_pts5.csta failed!
FL5Init errorERROR: open the model file:seetaface/model/age_predictor.csta failed!
<seetaface.api.SeetaFace object at 0x7f8b3babecf8>

口罩人脸识别

您好,请问应该怎么把通用人脸识别改成带口罩的人脸识别呀

gpu设置

关于gpu setting模块在这个版本会实现嘛!期待你的恢复

感谢作者的开源

我有两个问题需要请教大神:
1、这个工程的前提是不是还要把seetaface6那一套编译安装给弄好
2、作者有没有尝试过戴口罩的情况,能识别么?(我看seetaface6是说可以识别口罩)

感谢感谢!

使用过程中遇到的BUG

  1. centos 和 ubuntu下的文件名错误(/seetaface/api.py )
    dll = CDLL(os.path.join(LIB_PATH, "libSeetaFaceAPI.so"))
    中 应该为 libSeetaFaceAPI.so 而不是 libFaceAPI.so, 文件名不对

  2. 如果起始路径不是源目录下,会导致调用dll时候出现引用model问题(相对路径问题):
    建议在初始化的时候套一层装饰器,修改相对路径。
    `def chcwd(origin_func):
    def wrapper(self, *args, **kwargs):
    cwd = os.getcwd()
    os.chdir(os.path.dirname(os.path.abspath(file)) + "/../")
    u = origin_func(self, *args, **kwargs)
    os.chdir(cwd)
    return u
    return wrapper

class SeetaFace(object):
@chcwd
def init(self, init_mask):
self._init_mask = init_mask
self._dll_func_def()
self._init_engine()`

core dumped

After the clone code runs the demo file, all appears this problem.The model and dependency files are loaded correctly.

log

--- SIGILL {si_signo=SIGILL, si_code=ILL_ILLOPN, si_addr=0x7effb2825d96} ---
+++ killed by SIGILL (core dumped) +++

version

Linux version 3.10.0-1127.el7.x86_64 ([email protected]) 
(gcc version 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) )

python3.6

ARM seetaface6 编译so 文件

您好,近期有在ARM上的人脸识别项目需要用到seetaface6,我们可以付费购买ARM64位上的相关编译,请问您可以抽空帮忙编译下的?有时间和意愿的请联系[email protected],一起商量下详细价格

几个并发请求就会报错,杀掉整个程序

使用fastapi部署成http接口,jmeter2个线程请求正常,5个线程就报错,整个程序被杀死

[ERROR]: [src/runtime/instruction.cpp:65]: Check failed: (stack.size() >= static_cast<size_t>(return_size)).
terminate called after throwing an instance of 'ts::api::Exception'
  what():  [src/runtime/instruction.cpp:65]: Check failed: (stack.size() >= static_cast<size_t>(return_size)).

请教大佬,如何打印抽取出来的特征向量呢?

face_recon_demo.py 文件中

21 #提取第一张图中的人脸特征
22 image = cv2.imread("asserts/1.jpg")
23 detect_result1 = seetaFace.Detect(image)
24 face1 = detect_result1.data[0].pos
25 points1 = seetaFace.mark5(image, face1)
26 feature1 = seetaFace.Extract(image, points1)
27 print(feature1)

这种打印方式只能打出来内存地址,无法把向量内容打印出来

gpu

作者你好,关于gpu的setting怎么设置啊 会提供python api吗

如何生成.so文件的?

请教作者,如何在ubuntu下生成.so文件?每次调用seetaface的模块就会出现这个错误 what(): std::bad_alloc
代码如下:
extern "C" {void test(int height, int width, int channel, uchar* frame_data) { std::cout << "kaishi c++" << std::endl; cv::Mat image(height, width, CV_8UC3); memcpy(image.data, frame_data, sizeof(uchar) * width * height * channel); seeta::FaceDetector FD(seeta::ModelSetting(ModelPath + "face_detector.csta")); seeta::FaceLandmarker PD(seeta::ModelSetting(ModelPath + "face_landmarker_pts5.csta")); return; }}

头文件

您好,有封装的纯c接口的.h文件吗,我正在用golang调用,需要参考.h文件,不知道是否方便提供,万分感谢!!

有人使用过docker部署吗?

我在centos中安装了docker,将seetaface6部署到里面,然后通过docker运行,但报错OSError: libSeetaFaceDetector600.so: cannot open shared object file: No such file or directory 我知道是动态库的问题,但主要我是小白一个,不知道怎么解决,求大神指导

如何只使用人脸识别模块?

作者你好,很感谢你做的项目。但是,我想使用自己的人脸检测与人脸对齐模块,而只使用SeetaFace的人脸识别模块,请问我该怎么做?我去看过源码了,但我太菜,Python与C++转化实在弄不懂...,尤其是类型c_float不知道是怎么来的..

如何增加眼睛状态的检测

你好,看代码发现在wins下加载的是libFaceAPI.dll。
请问如何增加检测人眼检测的API?
我自己尝试了下,没成功。

段错误 (核心已转储)

大佬您好,我在运行face_detect_demo的时候提示:段错误 (核心已转储),这是什么原因导致的呢

内存泄漏

作者,你好我这边用你的代码,出现了疑似内存泄漏的问题。分为两种情况:
声明一下,我是用你的代码做N对N的人脸识别(遍历1对N)
1.人脸检测部分使用的是mtcnn,因为发现你封装的人脸检测没有mtcnn的准。在多次debug之后,再debug会出现"Memory error ......"的错误,我的浏览器也会因为运行该程序而崩溃,但是重启计算机后就可以重新debug了,debug一段时间后又会出现该问题。
2.人脸的检测与识别都是用你的代码,遍历人脸库的证件照片与检测到的人脸进行形似度比对,会出现"libpng warning: iCCP: known incorrect sRGB profile"还没跑完然后断掉。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.