MaixPy run face detection (tiny yolo v2)


#1

MaixPy run face detect (tiny yolo v2)
Today we use MaixPy to run face detection, here is the frimware and model.
maixpy_yolo2.zip (1015.3 KB)

API

kpu.init_yolo2(task, 0.5, 0.3, 5, anchor)
input args:

  • kpu_net : kpu net obj
  • threshold : prop gate
  • nms_value : box_iou gate
  • anchor_num : anchor number
  • anchor : anchor args

code = kpu.run_yolo2(task, img)
input args:

  • kpu_net : kpu_net obj
  • image_t :image from sensor

return value:

  • {"x":140, "y":46, "w":82, "h":111, "value":3.169619, "classid":0, "index":0, "objnum":3} : all face windows coordinate and size

API details refer to: https://maixpy.sipeed.com/zh/libs/Maix/kpu.html

Test Code

import sensor,image,lcd
import KPU as kpu
lcd.init()
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.set_hmirror(0)
sensor.run(1)
task = kpu.load(0x300000) 
anchor = (1.889, 2.5245, 2.9465, 3.94056, 3.99987, 5.3658, 5.155437, 6.92275, 6.718375, 9.01025)
a = kpu.init_yolo2(task, 0.5, 0.3, 5, anchor)
img_lcd=image.Image()
while(True):
    img = sensor.snapshot()
    code = kpu.run_yolo2(task, img)
    if code:
        for i in code:
            a = img.draw_rectangle(i.rect())
    a = lcd.display(img)
a = kpu.deinit(task)

Result


#2

学习了!感谢大神


#4

I passed around a demo at an interest group meeting toinight.
2 demo modification: boot button starts 20 object recognition, camera detecting “Person” causes Face Detection demo to launch. Python code is on SD card, Face model in Flash, 20 objects model on SD card (The same binary works with both. demos)

Question: Is there code for Expression Recognition, shown in this photo?

https://bbs.sipeed.com/uploads/default/original/1X/7387c7312ad01db4e3ae4ffcfcf380f83c88f2d8.jpeg


#5

we will release it this month


#6

Could you do a writeup on how you trained and built this yolo2 model?