Run face_detection_640.kmodel in canmv IDE (micropython)

Viewed 238

Canmv example code for face detection uses face_detection_320.kmodel, but for detail understanding of running kmodel in canmv ide i want to use given face_detection_640.kmodel model to detect face.

But as per now i am not aware which changes should i made to run this code in example code can you give me more detail on that please?

I have also refer AI Development Tutorial document but it does not describe that how to run kmodel in micropython and also in CanMV K230 document it also describe face detection using face_detection_320.kmodel only.

So it will be very helpful if you give me details on how can i run face_detection_640.kmodel or any custom kmodel in canmv ide using micropython.

1 Answers

You can download the kmodel file and bin file from the following link for implementing the face_detection_640 demo. The link is: https://c.wss.cc/f/fufgjgcz85n. Please download it within 24 hours, otherwise the files will expire. Use the CanMV IDE to connect to the development board, and copy these two files to the directories of'sdcard/examples/kmodel' and'sdcard/examples/utils' on the development board. Make the following modifications in the code to meet your requirements:

  1. from kmodel_path = "/sdcard/examples/kmodel/face_detection_320.kmodel" to kmodel_path = "/sdcard/examples/kmodel/face_detection_640.kmodel";
  2. from anchor_len = 4200 to anchor_len = 16800
  3. from anchors_path = "/sdcard/examples/utils/prior_data_320.bin" to anchors_path = "/sdcard/examples/utils/prior_data_640.bin";
  4. from model_input_size=[320, 320] to model_input_size=[640, 640];

Thank you for your attention to K230. Wish you a pleasant life!@Urvi_Zala

Thank you so much for your very helpful response..

So, If i want to implement any custom kmodel i just need to change above listed parameters right?

And how can i get anchors bin file, in this you have already given it but what if i have taken any onnx model from online how can i get anchors file and it's length?

Face detection is just an application in a fixed scene, and it has particularities. Not all detection models require an anchors file. The latest YOLO model does not need this file. You can refer to the development method provided in the document to train a custom detection model using YOLO and convert it to the kmodel format. The document link is: https://developer.canaan-creative.com/k230_canmv/zh/main/zh/example/ai/YOLO%E5%A4%A7%E4%BD%9C%E6%88%98.html. But I'm very sorry that it may not have an English version yet.