Giter VIP home page Giter VIP logo

insightface-lite-service's Introduction

insightface-lite-service

基于 fastapiinsightface 的轻量级人脸识别服务。

使用

首先 clone 本项目,并进入项目根目录。

docker

构建镜像

docker build -t <your-image-name> .

如果构建镜像存在困难,可以使用预构建的镜像。 提示,镜像大小为1.95GB。

docker pull wensun/insightface-lite-service:latest

启动容器

docker run -p <your-port>:80 -d <your-image-name>

本机

由于人脸识别的依赖限制,需要使用 Python 3.6 环境。

然后,按照 requirements.txt 安装依赖(该依赖是在 Ubuntu 环境下抽取的),并使用以下命令在本机 8000 端口启动开发服务:

uvicorn main:app --reload

如果按照 requirements.txt 安装后无法运行,也可以手动安装依赖:

pip install fastapi \
    uvicorn \
    python-multipart \
    numpy \
    scikit-image \
    scikit-learn \
    opencv-python \
    mxnet

现有接口

  1. 检查健康状态

    GET /health
    request: null
    response: {
      status: string
    }
  2. 比较两张图片中人脸的相似度(人脸比对)

    POST /compare
    request: {
      face1: multipart-formdata
      face2: multipart-formdata
    },
    response: {
      sim: number;    // similarity
      dist: number;   // distance
    }

常见问题

  1. 报错 ImportError: libGL.so.1: cannot open shared object file: No such file or directory

    原因是缺少 libgl1-mesa-glx。使用以下命令进行安装即可(Ubuntu):

    sudo apt-get update
    sudo apt-get install libgl1-mesa-glx
  2. 报错 RuntimeError: Click will abort further execution because Python 3 was configured to use ASCII as encoding for the environment.

    编码问题。按照指示设置环境变量即可:

    export LC_ALL=C.UTF-8
    export LANG=C.UTF-8
  3. 图片识别失败 / 明明有人脸却无法识别 / 相似度过低

    因为依赖的库似乎对背景噪声敏感,所以需要确保图片中的人脸占一定比例,这样才能正确识别。目前计划是对这种错误进行更友好的封装,如果有需要可以自行训练模型。

TODO

  • 增加CI / CD
  • 减小镜像大小
  • 提高接口健壮性
    • 更友好的错误处理
    • 并发处理
  • 增加识别功能
  • 增加跨域配置

insightface-lite-service's People

Contributors

hermitsun avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

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.