dlib 安裝和使用


dlib 安裝

使用 pip install dlibconda install dlib 安裝的 dlib,默認是 CPU 版本,無法使用 GPU。

dlib GPU 版本安裝:
1、去官網 http://dlib.net/ 下載 dlib 壓縮包,並解壓;
2、安裝 cmake,使用 pip install cmakeconda install cmake 安裝即可;
3、去 dlip 解壓目錄下,執行 python setup.py install,等待完成安裝。

判斷dlib是否可以使用GPU:

import dlib
dlib.DLIB_USE_CUDA   # True 表示可以使用 GPU

使用 dlib 進行人臉檢測

import dlib

face_detector = dlib.get_frontal_face_detector()      # 僅利用 CPU,即使 dlib.DLIB_USE_CUDA=True

cnn_face_detector = dlib.cnn_face_detection_model_v1(filename="mmod_human_face_detector.dat")    # CNN-based 方法,可以利用 GPU 加速

官方模型 mmod_human_face_detector.dat 下載鏈接:

http://dlib.net/files/mmod_human_face_detector.dat.bz2

get_frontal_face_detector() 示例:

https://github.com/davisking/dlib/blob/master/python_examples/face_detector.py

cnn_face_detection_model_v1() 示例:

https://github.com/davisking/dlib/blob/master/python_examples/cnn_face_detector.py

References

使用人臉識別完成單人視頻 cut -- 6enmel
dlib.DLIB_USE_CUDA=True and dlib.cuda.get_num_devices() = 6,but cannot see any process in nvidia-smi. #2302
Ubuntu環境下配置使用GPU加速的dlib庫 -- Ooo。
http://dlib.net/cnn_face_detector.py.html
https://github.com/ageitgey/face_recognition/blob/55b5c136292dcd4a1f5953f3eb3181235086efab/face_recognition/api.py#L92


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM