dlib 安装和使用
dlib 安装
使用 pip install dlib
或 conda install dlib
安装的 dlib,默认是 CPU 版本,无法使用 GPU。
dlib GPU 版本安装:
1、去官网 http://dlib.net/ 下载 dlib 压缩包,并解压;
2、安装 cmake,使用 pip install cmake
或 conda 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
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列1:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
· 【杂谈】分布式事务——高大上的无用知识?