yahboom
HomeLearn
Solution
Blog
Online Store
About Us
EN/中文
K210 Module📖
0.Camera changes
  • Precautions for camera changes
1.K210-AI-Camera introduction
  • 1.K210 main chip introduction
  • 2.K210 visual recognition module introduction
  • 3.Module pin assignments
  • 4.MicroPython Introduction
  • 5. FAQ analysis
  • 6.Bracket installation
2.Development Environment Setup
  • 1.To install the serial port assistant
  • 2.Install CanMV IDE development software
  • 3.Flashcard factory firmware
  • 4.IDE import routine
  • 5.Call custom py library
  • 6.MicroPython API documentation
3.Basic experimental routines
  • 1.Lighting the RGB light experiment
  • 2.Key features of the experiment
  • 3.Timer experiment
  • 4.PWM breathing light experiment
  • 5.LCD display experiment
  • 6.The touchpad read the coordinates of the experiment
  • 7.The camera shows the experimental
  • 8.Memory card read and write files of the experiment
  • 9.External interface experimental
4.Graphical manipulation routines
  • 1.Draw graphics
  • 2.Button and the click event
  • 3.Slider
  • 4.Chart animation
  • 5.Multi-label layout
5.AI visual experiments routines
  • How to import the model file into memory cardnew
  • 1.Color recognition
  • 2.Barcode recognition
  • 3.QR code recognition
  • 4.Apriltags recognition
  • 5.Face detection
  • 6.Face feature detection
  • 7.Mask detection
  • 8.Face recognition
  • 9.Object detection
  • 10.Self-learning classification
  • 11.Handwritten digit recognition
  • 12. Multiple color recognition
  • 13. Human body detectionnew
  • 14. Yolo hand detectionnew
  • 15. License Plate Recognitionnew
  • 16. Autonomous training modelnew
6.Extended routines (sold separately)
6.1.For STM32 Car
  • 10. stm_ K210 Autonomous Learning Classification
  • 1.automatic driving
  • 2.color follow
  • 3.Handwriting digital operation
  • 4.Color reaction
  • 5.Road sign indicating the operation
  • 6.Following the apriltag
  • 7.QR code instruction
  • 8.PTZ tracking color
  • 9.PTZ tracking face
6.2.1 arduino_k210
  • 1.ard_k210-Color recognition
  • 2.ard_k210-Bar code identification
  • 3.ard_k210-QR code identification
  • 4.ard_ K210-mechanical code identification
  • 5.ard_ K210-Face Detection
  • 6. ard_ K210-facial feature detection
  • 7. ard_ K210-mask detection
  • 8. ard_ K210-facial recognition
  • 9. ard_ K210-object detection
  • 10. ard_ K210 Autonomous Learning Classification
  • 11. ard_ K210 Handwritten Digit Recognition
6.2 K210 as a coprocessor
  • ReadMe
6.2.2 stm32_k210
  • 1.stm_ K210 color recognition
  • 2. stm_ K210 barcode recognition
  • 3. stm_ K210 QR code recognition
  • 4. stm_ K210 mechanical code identification
  • 5. stm_ K210 Face Detection
  • 6.stm_ K210 facial feature detection
  • 7. stm_ K210 mask detection
  • 8. stm_ K210 facial recognition
  • 9. stm_ K210 object detection
  • 11. stm_ K210 Handwritten Digit Recognition
6.2.3 microbit_k210
  • 1.microbit_ K210 color recognition
  • 2.microbit_ K210 barcode recognition
  • 3.microbit_ K210 QR code recognition
  • 4.microbit_ K210 mechanical code identification
  • 5. microbit_ K210 Face Detection
  • 6. microbit_ K210 facial feature detection
  • 7. microbit_ K210 mask detection
  • 8. microbit_ K210 facial recognition
  • 9. microbit_ K210 object detection
  • 10. microbit_ K210 autonomous classification learning
  • 11. microbit_ K210 Handwritten Digit Recognition
6.2.4 pico_k210
  • 1. pico_ K210 color recognition
  • 2. Pico_ K210 barcode recognition
  • 3. Pico_ K210 QR code recognition
  • 4. pico_ K210 machine code recognition
  • 5. pico_ K210 Face Detection
  • 6. pico_ K210 facial feature detection
  • 7. pico_ K210 mask recognition
  • 8. pico_ K210 facial recognition
  • 9. pico_ K210 object detection
  • 10. pico_ K210 Autonomous Learning Classification
  • 11. pico_ K210 Handwritten Digit Recognition
6.2.5 MSPM0G3507_k210
  • 1.MSPM0_K210 color recognition
  • 2.MSPM0_K210 barcode recognition
  • 3.MSPM0_K210 QR code recognition
  • 4.MSPM0_K210 mechanical code recognition
  • 5.MSPM0_K210 face detection
  • 6.MSPM0_K210 facial feature detection
  • 7.MSPM0_K210 mask detection
  • 8.MSPM0_K210 face recognition
  • 9.MSPM0_K210 Object Detection
  • 10.MSPM0_K210 Self-study classification
  • 11.MSPM0_K210 handwritten digit recognition
6.2.6 MSPM0G3519_k210
  • 1. MSPM0_K210 Color Recognitionnew
  • 2. MSPM0_K210 Barcode Recognitionnew
  • 3. MSPM0_K210 QR Code Recognitionnew
  • 4. MSPM0_K210 Mechanical Code Recognitionnew
  • 5. MSPM0_K210 Face Detectionnew
  • 6. MSPM0_K210 Facial Feature Detectionnew
  • 7. MSPM0_K210 Mask Detectionnew
  • 8. MSPM0_K210 Face Recognitionnew
  • 9. MSPM0_K210 Object Detectionnew
  • 10. MSPM0_K210 Self-study Classificationnew
  • 11. MSPM0_K210 Handwritten Digit Recognitionnew
6.3 For 24 channel servo drive board
  • 1. 2DOF PTZ Color Tracking
  • 2. 2DOF Face Tracking
  • 3. 2DOF Fruit sorting
6.4 For autopilot map
  • 1.k210 model training
  • 2.Assembly and wiring of stm32 car
  • 3.Recognize left and right sign
  • 4.Identify and remove speed limit
  • 5.Identify parking spaces and park
  • 6.STM32 car autopilot
6.5.1 For MSPM0G3507_Wheeled Chassis Kit
  • 1.MSPM0-Automatic Driving
  • 2.MSPM0-Color follow
  • 3.MSPM0-Number recognition
  • 4.MSPM0-Color reaction
  • 5.MSPM0-Road signs
  • 6.MSPM0-Machine code following
  • 7.MSPM0-QR code recognition
6.5.2 For MSPM0G3519_Wheeled Chassis Kit
  • 1.MSPM0-Automatic Drivingnew
  • 2.MSPM0-Color follownew
  • 3.MSPM0-Number recognitionnew
  • 4.MSPM0-Color reactionnew
  • 5.MSPM0-Road signsnew
  • 6.MSPM0-Machine code followingnew
  • 7.MSPM0-QR code recognitionnew
6.5.3 For STM32_Wheeled Chassis Kit
  • 1.STM32-Automatic Driving
  • 2.STM32-Color follow
  • 3.STM32-Number recognition
  • 4.STM32-K210-Color Reaction
  • 5.STM32-Road signs
  • 6.STM32-Machine code following
  • 7.STM32-QR code recognition
Download
  • Driver development software
  • AI model
  • Source code
  • Instruction manual
  • Hardware_3DModelFile
  • K210_Chip_Data
Download ZIP

Welcome to K210 Module repository

16. Autonomous training model

16. Train the model yourself and use it

16. Train the model yourself and use it16.1. Experimental objectives16.2. Experimental process16.2.1. Train the model16.2.2, call the model16.3、Experimental results16.4、Experimental Summary

16.1. Experimental objectives

This lesson mainly teaches you to train the model yourself and run it on K210

16.2. Experimental process

16.2.1. Train the model

  1. Before training, make sure that you are using the factory firmware of Yabo, otherwise the trained model cannot be used.
  2. Go to the model training website : https://www.kendryte.com/en/products
  1. Register your own account

image-20241017172140817

  1. After logging in, click Model Training

Snipaste_2024-10-23_15-27-54

image-20241017173331850

  1. Click Dataset -->Create Dataset --> Enter the dataset name --> Select the annotation type: Image Detection --> Click Submit. The model we trained in this chapter is used to detect three types of transportation: [airplanes, cars and ships]

image-20241017173626076

  1. Select the dataset we just created

image-20241017174048841

  1. Click Upload Image, upload the image and give the corresponding label

image-20241017175931758

Click the "Label" button to enter the labeling interface and label the image with the corresponding label

image-20241023153317714

image-20241017180119325

Use the mouse to frame the object and click Save.

Snipaste_2024-10-23_15-53-24

image-20241018110706280

  1. Find the created dataset in the "Dataset" column and click the "Training button".

Snipaste_2024-10-23_15-59-05

You can use the default parameters on the training parameter page or adjust them yourself

image-20241017173909207

  1. Waiting for training

image-20241017180407563

Note: The training progress may be stuck at 0% here, please wait patiently

  1. Download the training model

image-20241018101340955

*.kmodel file is the trained model, det.py file is an example of using the model

image-20241018102003681

  1. Upload kmodel to the SD card. The upload location of the model trained in this example is [/sd/KPU/train_model_and_use/det.kmodel]

Note: If the final model effect is not very good, you can try to unify the size of the images in the training set first

16.2.2, call the model

  1. Open the det.py file in the compressed package downloaded in the previous section in the IDE

  2. Modify the path in kpu.load_kmodel(/sd/det.kmodel') to the model path: kpu.load_kmodel('/sd/KPU/train_model_and_use/det.kmodel')

  3. Modify the content of the labels array to the labels in the model you trained (you can see it in the label.txt file)

    # 类名称,按照label.txt顺序填写 Class name, fill in the order according to label.txt
    labels = ["plane", "ship", "car"] 
    # anchors,使用anchor.txt中第二行的值 anchors, use the value of the second line in anchor.txt
    anchor = (9.50, 4.00, 7.97, 5.06, 9.69, 4.81, 7.59, 6.58, 9.36, 6.02) 
  4. Initialize the KPU object

    xxxxxxxxxx
    kpu = KPU()
    # 从sd或flash加载模型  Load model from sd or flash
    kpu.load_kmodel('/sd/KPU/train_model_and_use/det.kmodel')
    #kpu.load_kmodel(0x300000, 584744)
    kpu.init_yolo2(anchor, anchor_num=(int)(len(anchor)/2), img_w=320, img_h=240, net_w=320 , net_h=240 ,layer_w=10 ,layer_h=8, threshold=0.1, nms_value=0.3, classes=len(labels))
  5. Target detection main function

    xxxxxxxxxx
    while(True):
        gc.collect()
        clock.tick()
        img = sensor.snapshot()
        kpu.run_with_output(img)
        dect = kpu.regionlayer_yolo2()
        fps = clock.fps()
        if len(dect) > 0:
            for l in dect :
                a = img.draw_rectangle(l[0],l[1],l[2],l[3],color=(0,255,0))
                info = "%s %.3f" % (labels[l[4]], l[5])
                a = img.draw_string(l[0],l[1],info,color=(255,0,0),scale=2.0)
                print(info)
                del info
        a = img.draw_string(0, 0, "%2.1ffps" %(fps),color=(0,60,255),scale=2.0)
        lcd.display(img)

16.3、Experimental results

Connect the K210 module to the computer via a microUSB cable, click the Connect button in CanMV IDE, and click the Run button to run the example code. You can also download the code as main.py to the K210 module and run it.

After the system is initialized, the LCD displays the camera image and marks the "ship", "plane" and "car" in the image. The specific effect is shown in the figure

image-20241018141800669

image-20241018142429749

image-20241018142517473

 

 

16.4、Experimental Summary

In this section, we learned how to use the online cloud training platform on the Canaan official website to train our own model and use the model in the K210 vision module. After training, please import the model file into the memory card and then insert the memory card into the memory card slot of the K210 module. If the model file in the memory card cannot be read, an error will be reported. Due to the size of the model, the accuracy of recognition may be affected. You can train a better model yourself.

License Plate Recognition
stm_ K210 Autonomous Learning Classification

COMPANY

  • About us
  • Team Style
  • Blog

LEARNING & EXPLORATION

  • Tutorials
  • Edge AI hardware
  • Educational robots
  • Embedded intelligent hardware

WHERE TO BUY

  • Yahboom Online Store
  • Amazon
  • Alibaba
  • AliExpress
  • Mercado

TECHNOLOGY SUPPORT

  • Email: support@yahboom.com

BE A DISTRIBUTOR

  • Email: sales@yahboom.com
QR Code

Copyright © 2017-2026 Yahboom. All Rights Reserved.

EN/中文