Skip to content

alvherrey/face_recognition

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Face Recognition

Reconocer y manipular caras desde Python o desde la línea de comandos con la biblioteca de reconocimiento facial más simple del mundo.

Requerimientos

Crear un entorno virtual con Miniconda

Creamos un entorno nuevo con python 3.8

conda create --name face_recognition python=3.8

Activamos el entorno

conda activate face_recognition

Instalar CMake

Para instalar la dependencia face_recognition es necesario tener instalado CMake En ubuntu:

sudo apt install -y build-essential
sudo apt install -y cmake

Instalar dlib

En ubuntu:

git clone https://github.com/davisking/dlib.git
cd dlib
mkdir build; cd build; cmake ..; cmake --build .
cd ..
python setup.py install

Instalar el requerimientos

Ejecutamos el pip install...

pip install -r requirements.txt

Ejecucion

Identificar los rostros en una imagen (test)

Necesitamos la estructura de "img/known/*.jpg" con las imagenes conocidas (etiquetadas por su nombre) Necesitamos la estructura de "out/" donde se guarda la imagen resultante Obtenemos los resultados en el diccionario faces imprimido al final

python test_api.py

Ejemplo del resultado faces:

[{'id': 0, 'name': 'Steve Jobs', 'known': True, 'bbox': [76, 135, 166, 46]}, {'id': 0, 'name': 'Desconocido', 'known': False, 'bbox': [60, 304, 103, 261]}]

Identificar los rostros en una imagen (api)

Levantar el api con uvicorn

uvicorn app.main:app --reload

Acceder al swagger para probar

http://127.0.0.1:8000/docs#/

Docker

sudo docker-compose build
sudo docker-compose up -d

If you want to create a soft link of img_known volume on working dir

sudo docker inspect face-recognition | grep img_known | grep Source
sudo ln -s /dockers_servicios/volumes/face_recognition_img_known/_data ./img_known

Important all requests must include {user_id} in the path request, and must exists a dir with {user_id} name under img_known volume, with the known faces images properly named with the person name and surname. Like: "img_known/-N0MJI_cWfK3EVTybR59/Alvaro Hernandez.jpg" Example of curl request:

curl -X 'POST' \
  'http://127.0.0.1:8000/face/identify/-N0MJI_cWfK3EVTybR59' \
  -H 'accept: application/json' \
  -H 'Content-Type: multipart/form-data' \
  -F '[email protected];type=image/jpeg'

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published