Shakerato

Install face_recognition and dlib on Windows 10 본문

Research

Install face_recognition and dlib on Windows 10

Shakeratto 2018. 7. 15. 23:56

1. Anaconda3 Install

2. Create a envorinment <env> with python3.6

3. Install Microsoft Visual Studio 2017 or Upgrade

   (C++ packages includes c++/CLI must be installed for CMake)

   (because CMake needs c++11 compiler)

4. Update Visual Sutudio 2017

5. Reboot the Computer

6. Download CMake (https://cmake.org/download/) and Install it

7. Activate specific <env> of Anaconda3 in the 'cmd'

8. pip3 install face_recognition

* face_recognition and dlib are not fully installed in specific <env>, but default anaconda env.

* so you should to copy from


c:\programdata\anaconda3\scripts\face_detection.exe

c:\programdata\anaconda3\scripts\face_recognition.exe


to <env>\scripts\


and 


c:\programdata\anaconda3\lib\site-packages\dlib-19.15.0.dist-info\*

c:\programdata\anaconda3\lib\site-packages\dlib.cp36-win_amd64.pyd


to <env>\Lib\site-package\


9. Finally, run the code below for test


/////////////////////////


How to use GPU (Cuda) for DLib


1. Download dlib-XX.XX.zip in the dlib site (http://dlib.net/)

2. Activate <env> in 'cmd' as administrator

3. python setup.py install --yes USE_AVX_INSTRUCTIONS --yes DLIB_USE_CUDA


   if not working, try below


    python setup.py install --yes USE_AVX_INSTRUCTIONS --clean



import cv2
import dlib
import face_recognition

detector = dlib.get_frontal_face_detector()
cap = cv2.VideoCapture(0)

while(True):
ret, frame = cap.read()
dets = face_recognition.face_locations(frame, model="cnn")
print("face_recognition:",dets)

gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
dets = detector(gray, 1)
for i, d in enumerate(dets):
print("dlib: Left: {} Top: {} Right: {} Bottom: {}".format(
d.left(), d.top(), d.right(), d.bottom()))

if cv2.waitKey(1) & 0xFF == ord('q'):
break






Comments