我想实现戴眼镜检测,如何实现?

Viewed 186

板子是创乐博K230,刷了CanMV-K230_micropython_v1.0_sdcard_v1.6_nncase_v2.8.3.img
在模型库里我找到了两个相关模型

一个是https://developer.canaan-creative.com/modelDetail?id=119&title=face_glasses
这个是k230的,用到模型是face_glasses.kmodel,但是演示是C++的,不是Micropython的,
我想问这个face_glasses.kmodel在Micropython下可以使用吗?可以提供演示代码吗?

另外一个是https://developer.canaan-creative.com/modelDetail?id=7&title=%E4%BA%BA%E8%84%B8%E5%B1%9E%E6%80%A7%E5%88%86%E6%9E%90
这个是K210的,演示是Micropython程序,用的三个模型
我想问,K210的模型,K230可以用吗?能否提供演示代码?

我测试了一下人脸姿势模型,结果是这样的
模块名称:/sdcard/examples/18-NNCase/face_detection/face_pose.kmodel
输入信息:
{'tensor_size': 43200, 'tensor_datatype': 'dt_uint8', 'tensor_start': 0}

输出信息:
{'tensor_size': 48, 'tensor_datatype': 'dt_float32', 'tensor_start': 0}

获取输出:
0 array([85.19904, 0.5450416, -0.2133789, 0.7304688, -66.672], dtype=float32)
(1, 3, 4) 102

人脸检测模型
块名称:/sdcard/examples/18-NNCase/face_detection/face_detection_320.kmodel
输入信息:
{'tensor_size': 307200, 'tensor_datatype': 'dt_uint8', 'tensor_start': 0}

输出信息:
{'tensor_size': 51200, 'tensor_datatype': 'dt_float32', 'tensor_start': 0}
{'tensor_size': 12800, 'tensor_datatype': 'dt_float32', 'tensor_start': 51200}
{'tensor_size': 3200, 'tensor_datatype': 'dt_float32', 'tensor_start': 64000}
{'tensor_size': 25600, 'tensor_datatype': 'dt_float32', 'tensor_start': 67200}
{'tensor_size': 6400, 'tensor_datatype': 'dt_float32', 'tensor_start': 92800}
{'tensor_size': 1600, 'tensor_datatype': 'dt_float32', 'tensor_start': 99200}
{'tensor_size': 128000, 'tensor_datatype': 'dt_float32', 'tensor_start': 100800}
{'tensor_size': 32000, 'tensor_datatype': 'dt_float32', 'tensor_start': 228800}
{'tensor_size': 8000, 'tensor_datatype': 'dt_float32', 'tensor_start': 260800}

获取输出:
0 array([-1.381836, -1.269531, -1.163086, -0.9638672, -0.4829102], dtype=float32)
(1, 8, 40, 40) 102
1 array([-0.2524414, -0.2470703, -0.307373, -0.4387207, -0.3959961], dtype=float32)
(1, 8, 20, 20) 102
2 array([-1.074219, -1.057617, -1.05957, -1.020508, -1.121094], dtype=float32)
(1, 8, 10, 10) 102
3 array([-4.023438, -4.0625, -4.015625, -3.900391, -3.699219], dtype=float32)
(1, 4, 40, 40) 102
4 array([-3.962891, -3.984375, -4.140625, -3.945313, -3.501953], dtype=float32)
(1, 4, 20, 20) 102
5 array([-3.259766, -3.289063, -3.380859, -3.064453, -4.496094], dtype=float32)
(1, 4, 10, 10) 102
6 array([0.121582, 0.1583252, 0.1685791, 0.3500977, 0.84375], dtype=float32)
(1, 20, 40, 40) 102
7 array([0.9072266, 0.9287109, 0.9658203, 0.7695313, 1.052734], dtype=float32)
(1, 20, 20, 20) 102
8 array([0.2927246, 0.3242188, 0.3847656, 0.4943848, 1.158203], dtype=float32)
(1, 20, 10, 10) 102

cpp示例中的模型face_glasses 就直接死机了,说明输入数据不对,都是人脸检测,数据不一样吗? 我如果参照人脸姿势模型处理,估计要直接死机,前后处理实在是不知道如何写了,求帮忙

模块名称:/sdcard/examples/18-NNCase/face_detection/face_glasses.kmodel
输入信息:
{'tensor_size': 150528, 'tensor_datatype': 'dt_uint8', 'tensor_start': 0}

输出信息:
{'tensor_size': 12, 'tensor_datatype': 'dt_float32', 'tensor_start': 0}

2 Answers

micropython可以实现,需要使用cpp示例中的模型,可以自己写前后处理。

face_glasses.kmodel 模型我已经复制到kmodel里了,但是先要进行人脸检测,再在人脸检测结果里进行眼镜检测,结果是戴或不戴两种,C++代码看了,但是micropython里face_glasses.kmodel如何使用,不会写,玩micropython才几天,所有资料文档看了几遍,还上不手,有例程才会改

可参考AIDemo说明文档,看例程类似代码

我要开发产品,功能很是比较复杂的,先识别特定手势启动人脸识别,人脸识别身份通过,则检测人脸是否戴眼镜和左手或右手捂眼睛,同时含有识别手势的指向上下左右,还要有全程语音播报提示

另外一个是https://developer.canaan-creative.com/modelDetail?id=7&title=%E4%BA%BA%E8%84%B8%E5%B1%9E%E6%80%A7%E5%88%86%E6%9E%90
这个是K210的,演示是Micropython程序,用的三个模型
我想问,K210的模型,K230可以用吗?能否提供演示代码?