本帖最后由 swzswz 于 2022-10-21 19:08 编辑
人脸识别模型
人脸识别模型步骤
人脸识别主要分为两个模型:
模型建立过程
视频录制转换
按照海思开发文档的store_sample例程,修改对应参数。将视频录制出来,或者利用手机进行视频录制。
编译完后,利用NFS将板端的视频复制到电脑本地上。
搭建FFmpeg环境,将视频裁剪成图片。
数据集制作和标注
利用labelme工具,标注数据集。
模型训练
利用CUDA进行云端模型训练,我们用的海思服务器。
模型转换
一般是用pytorch-caffe转换。
模型量化
通过caffe模型转换成板端推理的wk模型。
模型部署板端和调试
视频演示
1
代码以及其他文件
static HI_S32 CnnTrashClassifyFlag(const RecogNumInfo items[], HI_S32 itemNum, HI_CHAR* buf, HI_S32 size)
{
HI_S32 offset = 0;
HI_CHAR *trashName = NULL;
offset += snprintf_s(buf + offset, size - offset, size - offset - 1, "face_classify: {");
for (HI_U32 i = 0; i < itemNum; i++) {
const RecogNumInfo *item = &items;
uint32_t score = item->score * HI_PER_BASE / SCORE_MAX;
if (score < THRESH_MIN) {
break;
}
SAMPLE_PRT("----trash item flag----num:%d, score:%d\n", item->num, score);
switch (item->num) {
case 0u:
trashName = "face";
UartSendRead(uartFd1,face);
SAMPLE_PRT("----trash name----:%s\n", trashName);
break;
case 1u:
trashName = "background";
UartSendRead(uartFd1,background);
SAMPLE_PRT("----trash name----:%s\n", trashName);
break;
default:
trashName = "unknown";
UartSendRead(uartFd1,unknown);
SAMPLE_PRT("----trash name----:%s\n", trashName);
break;
}
offset += snprintf_s(buf + offset, size - offset, size - offset - 1,
"%s%s %u:%u%%", (i == 0 ? " " : ", "), trashName, (int)item->num, (int)score);
HI_ASSERT(offset < size);
}
offset += snprintf_s(buf + offset, size - offset, size - offset - 1, " }");
HI_ASSERT(offset < size);
return HI_SUCCESS;
}
|