NCNN人脸检测和关键点检测

本文介绍了如何使用NCNN进行人脸识别和关键点检测,包括将原始的Retinaface模型从Caffe转换为NCNN格式,以及使用转换后的模型进行推理验证。同时,文章还探讨了自己转换YOLOV5S模型的过程,并对比了人脸检测与人形目标检测算法的差异。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

参考以下连接获取原始 retinaface模型:

mirrors / wzj5133329 / retinaface_caffe · GitCode

https://github.com/deepinsight/insightface/tree/master/RetinaFace

retinaface(mxnet)的CAFFE模型

https://github.com/Charrin/RetinaFace-Cpp/tree/master/convert_models/mnet

使用caffe2ncnn将模型转换为NCNN格式,需要注意的是,环境需要事先安装protobuf的开发环境,否则CMAKE阶段会警告无法生成caffe2ncnn和onnx2ncnn的问题,因为这两种格式用的都是protobuf来描述的。

sudo apt-get install libprotobuf-dev protobuf-compiler
sudo apt-get autoremove --purge protobuf-compiler
sudo apt-get autoremove --purge libprotobuf-dev

编译成功后,执行命令./caffe2ncnn mnet.prototxt mnet.caffemodel进行模型转换即可。

之后重命名ncnn.bin,ncnn.param为应用识别的文件名,即可以推理验证:

执行命令:./retinaface ./beauty.jpg

lena大妈

百度人脸的结果: 

对结果进行检测:

以上是用NCNN自带的模型测试的效果,下面用自己转的模型验证:

按照符合网络输入要求的图像尺寸做scale后输入:

效果很好!

下面是用NCNN YOLOV5用的模型文件,对比一下人脸检测和人形目标检测算法的区别:

小鲜肉和老腊肉:

网络分析:

一输入九输出

基于NCNN修改的后处理程序:

// Tencent is pleased to support the open source community by making ncnn available.
//
// Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
//
// Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
// in compliance with the License. You may obtain a copy of the License at
//
// https://opensource.org/licenses/BSD-3-Clause
//
// Unless required by applicable law or agreed to in writing, software distributed
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
// specific language governing permissions and limitations under the License.

#include "net.h"

#if defined(USE_NCNN_SIMPLEOCV)
#include "simpleocv.h"
#else
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#endif
#include <stdio.h>
#include <vector>
#include <vector>
#include <iostream>
using namespace std
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

papaofdoudou

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值