This post was last edited by swzswz on 2022-10-21 19:08
Face recognition model
Face recognition model steps
Face recognition is mainly divided into two models:
Model building process
[attach ]650136[/attach]
Video Recording Conversion
Modify the corresponding parameters according to the store_sample routine in the HiSilicon development document . Record the video or use a mobile phone to record the video.
After compiling, use NFS to copy the video on the board to the local computer.
Build the FFmpeg environment and crop the video into pictures.
Dataset creation and annotation
Use labelme tool to label the dataset.
Model Training
We use HiSilicon servers to perform cloud model training using CUDA.
Model Conversion
Generally, pytorch-caffe is used for conversion.
Model Quantization
Convert the caffe model into a wk model for board-side reasoning.
Model deployment and debugging
Video Demonstration
1
Code and other files
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;
}
|