Giter Club home page Giter Club logo

tae898 / face-detection-recognition Goto Github PK

View Code? Open in Web Editor NEW

This project forked from deepinsight/insightface

10.0 4.0 10.0 21.55 MB

This repo is forked from https://github.com/deepinsight/insightface. I use their face detection (retinaface) and face recognition (arcface).

License: MIT License

Python 85.92% Shell 0.17% C++ 0.21% Makefile 0.01% Cuda 0.24% C 0.49% Dockerfile 0.02% Jupyter Notebook 12.12% Cython 0.83%
docker python flask mxnet

face-detection-recognition's Introduction

Face detection and recognition

DOI

This repo is forked from https://github.com/deepinsight/insightface. I use their face detection (retinaface) and face recognition (arcface).

I used to use their gender and age estimation as well, but the accuracy is very bad so I had to drop it.

I have a new age-gender estimation model. Check out the repo and the demo video.

Flask server.

I made a light-weight flask server that loads the modules and waits for the client calls.

You can either run the app.py directly in Python3 or in a docker container.

Pulling and running the docker containers is easier and recommended.

Run in a docker container (recommended)

  • Pull and run on CPU

    1. Pull the image from docker hub and run the container.

      docker run -it --rm -p 10002:10002 tae898/face-detection-recognition
    2. Build it (optional)

      If you want to build this container from scratch for whatever reason, you can do so.

      Make sure your current directory is the root directory of this repo.

      First download the models and unzip them.

      wget https://github.com/tae898/face-detection-recognition/releases/download/models/models.zip
      
      unzip models.zip

      And build it.

      docker build -t face-detection-recognition .  
  • Pull and run on GPU

    1. Pull the image from docker hub and run the container.

      docker run -it --rm -p 10002:10002 --gpus all tae898/face-detection-recognition-cuda
    2. Build it (optional)

      If you want to build this container from scratch for whatever reason, you can do so.

      Make sure your current directory is the root directory of this repo.

      First download the models and unzip them.

      wget https://github.com/tae898/face-detection-recognition/releases/download/models/models.zip
      
      unzip models.zip

      And build it.

      docker build -f Dockerfile-cuda -t face-detection-recognition-cuda .  

Run directly (CPU only)

First your current directory should be the root directory of this repo.

  1. Download the models and unzip them.

    wget https://github.com/tae898/face-detection-recognition/releases/download/models/models.zip
    
    unzip models.zip
    
    mkdir -p ~/.insightface/
    mv models ~/.insightface/
  2. Install the requirements.

    pip3 install -r requirements.txt
  3. Install the insightface python package.

    cd python-package && pip install . && cd ..
  4. Run both apps.

    python3 app.py --gpu-id -1

Making a REST POST request to the flask server.

You should send an image as json. I know this is not conventional but somehow this works really good. Below is an example code.

import jsonpickle
import requests
import pickle

with open('/path/to/image', 'rb') as stream:
    frame_bytestring = stream.read()
data = {'image': frame_bytestring}
data = jsonpickle.encode(data)
response = requests.post('http://127.0.0.1:10002/', json=data)
response = jsonpickle.decode(response.text)
face_detection_recognition = response['face_detection_recognition']

with open('/path/to/save/results', 'wb') as stream:
    pickle.dump(face_detection_recognition, stream)

face_detection_recognition is a list of dicts. The number of dicts correspond to the number of faces detected in the image. Every dict has four key-value pairs. They are:

bbox: bounding box (four floating point numbers).
det_score: detection confidence score (one floating point)
landmark: five facial landmarks (5 by 2 float array)
normed_embedding: face embedding (512-dimensional floating point vector)

Troubleshooting

The best way to find and solve your problems is to see in the github issue tab. If you can't find what you want, feel free to raise an issue. We are pretty responsive.

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Authors

face-detection-recognition's People

Contributors

anxiangsir avatar chenjoya avatar jiankangdeng avatar kilj4eden avatar leondgarse avatar nlqq avatar nttstar avatar ppwwyyxx avatar sagarbhathwar avatar shiquanyu avatar szad670401 avatar tae898 avatar tengerye avatar wang-xinyu avatar xiaoyang-coder avatar yingfeng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

face-detection-recognition's Issues

Inquiry about resizing the image size

I'm interested to understand the rationale behind resizing the image to (640, 640) before feeding it into the face detection model. I have a concern that altering the aspect ratio of the original image might negatively affect the model's output. Could you please explain the reason behind this resizing step?

Percentage GPU memory usage

Hello!

I noticed that when I use the CUDA version of the code, the memory usage destinated for the process is always the same (a small percentage of the GPU, between 25 - 30 %), is there a way to increase it?

Thanks!

Aniol

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.