一个简单而轻量级的软件包,用于支持GPU的最先进的人脸检测。

face-detection的Python项目详细描述


基于DSFD和RetinaFace的Pytorch人脸检测技术

此存储库包括:

NOTE此实现只能用于模型选择的推理,并且所有的训练脚本都将被删除。如果您想微调任何模型,我们建议您使用原始源代码。在

安装

您可以使用pip安装这个存储库(需要python>;=3.6)

pip install git+https://github.com/hukkelas/DSFD-Pytorch-Inference.git

也可以使用setup.py安装

^{pr2}$

入门

python3 test.py

这将在images/文件夹中查找图像,并将结果保存在以_out.jpg结尾的同一文件夹中

简单API

要执行检测,可以简单地使用以下行:

importcv2importface_detectionprint(face_detection.available_detectors)detector=face_detection.build_detector("DSFDDetector",confidence_threshold=.5,nms_iou_threshold=.3)# BGR to RGBim=cv2.imread("path_to_im.jpg")[:,:,::-1]detections=detector.detect(im)

这将返回一个形状为[N, 5]的张量,其中N是面数,五个元素是[xmin, ymin, xmax, ymax, detection_confidence]

批处理推理

importnumpyasnpimportface_detectionprint(face_detection.available_detectors)detector=face_detection.build_detector("DSFDDetector",confidence_threshold=.5,nms_iou_threshold=.3)# [batch size, height, width, 3]images_dummy=np.zeros((2,512,512,3))detections=detector.batched_detect(im)

改进

与DSFD的差异

有关原始源代码,请参见here。在

  • 删除培训/加载VGG模型的所有不必要的文件。在
  • 使用time(在V100-32gbgpu上测量)粗略估计,将推理时间提高约30倍(从6s到0.2)。在

推理时间的主要改进来自:

  • 将非最大抑制替换为highly optimized torchvision version
  • 重构SSD model中的init_priors以缓存以前的大小(不需要每次向前传递生成此值)。在
  • 重构^{}中的Detect中的前向传递,以便在非最大值抑制之前执行置信阈值
  • 使用Pythorch1.0特性的前向过程中的细微变化

与视网膜表面的差异

有关原始源代码,请参见here。在

我们做了以下改进:

推理时间

这是在1024x687图像上粗略估计的。报告的时间是单个图像上平均超过1000次的正向传递。(无cudnn基准和fp16计算)。在

DSFDDetectorRetinaNetResNet50RetinaNetMobileNetV1
CPU (Intel 2.2GHz i7) *17,496 ms (0.06 FPS)2970ms (0.33 FPS)270ms (3.7 FPS)
NVIDIA V100-32GB76.41 (13.1 FPS)29.05ms (34.43 FPS)22.09ms (45.28 FPS)
NVIDIA GTX 1080 8GB197.3 (5.1 FPS)42.45ms (23.55 FPS)16.55ms (60.43 FPS)
NVIDIA T4 16 GB

*2014年年中,在MacOS上完成了100多次向前传球,15英寸。在

变更日志

  • 2020年9月1日:增加对fp16/混合精度推断的支持
  • 2020年9月2日:通过优化先验盒生成来减少推理时间

引文

如果您发现此代码有用,请记住引用原始作者:

@inproceedings{li2018dsfd,
  title={DSFD: Dual Shot Face Detector},
  author={Li, Jian and Wang, Yabiao and Wang, Changan and Tai, Ying and Qian, Jianjun and Yang, Jian and Wang, Chengjie and Li, Jilin and Huang, Feiyue},
  booktitle={Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition},
  year={2019}
}

@inproceedings{deng2019retinaface,
  title={RetinaFace: Single-stage Dense Face Localisation in the Wild},
  author={Deng, Jiankang and Guo, Jia and Yuxiang, Zhou and Jinke Yu and Irene Kotsia and Zafeiriou, Stefanos},
  booktitle={arxiv},
  year={2019}

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何从IBM MQ的JMSException检测可恢复错误   java Lucene6。4.2:找不到类,尝试添加查询。   Java Pdf差异库   在Java中多线程处理我的线程   java将字符串传递给Uri。下载中的parse()   java在列表中查找原语位置   java JPA条件从另一个查询中选择   java中的强制转换和转换   java如何在没有上下文的情况下获取SOAP Web服务(Apache Axis 1.4)的调用客户端的IP地址   java Android IllegalBlockSizeException:解密中最后一个块未完成   java Jersey是否要自定义无效资源路径的错误处理?   如何将JavaCVS web项目转换为基于maven的web项目?   java如何检查通用列表是否与jUnit相等?   arraylist java。util。尝试使用迭代器时发生ConcurrentModificationException错误   使用springsecurity,jsp上的java${u csrf.token}始终为空   sql使用java从临时表中选择数据   spring验证中的java@Notnull和@Pattern无效   java如何使用jQuery将包含对象数组的对象数组传递给Spring MVC控制器?