kwsModelAutoDeploy Tool User Guide*
Reminder
This document describes model deployment for the lvp_kws project on the grus chip.
- The SDK is published on GitHub: https://github.com/NationalChip/lvp_kws
- The tool is located in the SDK tools/kws_model_auto_deploy directory
If you want to deploy models to the ovp_aiot project on the fornax chip, please refer to the Kws Model Deployment Tool Guide document.
Introduction:*
This is a tool that automatically deploys models generated by the BunKws training framework into the lvp_kws SDK. After using this tool, users can directly compile firmware that can be flashed to GX8002 devices.
Video Tutorial:*
How to deploy a KWS model to the SDK and compile firmware: https://www.bilibili.com/video/BV1cnjwzvEfJ/?spm_id_from=333.1387.homepage.video_card.click
Tool Command Help*
- Command Documentation
$ ./kwsModelAutoDeploy -h
usage: kwsModelAutoDeploy [-h] [-v] [-i INPUTPATH] [-r SDKROOTPATH] [-p PROJECTNAME] [-dv DEPLOYVERSION] [-d]
This is a tool that can automatically deploy models generated by the BunKws training framework into the lvp_kws SDK
optional arguments:
-h, --help show this help message and exit
-v, -V, --version Print software version info
-i INPUTPATH, --inputPath INPUTPATH
Input directory path of the model files output by BunKws
Note:
1. This directory should contain the following files
model_79.pt
├── keyword.txt # Ordered word list (mainly specifies the order)
├── model.h # Model file
└── report.xlsx # Model test report (mainly provides thresholds)
-r SDKROOTPATH, --sdkRootPath SDKROOTPATH
SDK root path, which is the base path for all operations
Note:
1. This path should end with lvp_tws
For example: ~/work/2025-04-21-Kws2SdkDeploy/lvp/lvp_tws
-p PROJECTNAME, --projectName PROJECTNAME
Set the project name (the model will be deployed to a directory named after this project in the SDK)
Note:
1. The name can consist of letters and underscores, no other characters allowed
For example: xiaoshu_ai
-dv DEPLOYVERSION, --deployVersion DEPLOYVERSION
Custom deployment version for the project model (mainly to define a version for the model deployed to the SDK)
Note:
1. Optional; defaults to v0.1.0. If the version already exists under the current project, the tool will prompt whether to overwrite during execution
2. If the set version already exists under the current project, the tool will prompt whether to overwrite during execution
-d, --debug
Enable debug mode; disabled by default. Mainly adjusts the print level to debug and outputs detailed logs for debugging
Usage Examples*
Case 1: All Trained Words Are Main Wake-up Words*
-
In this case, there is basically no need to configure event IDs or main wake-up flags in the file; just generate directly
-
Event ID defaults to 100
- Automatically defaults to main wake-up
$ ./kwsModelAutoDeploy -i model_77.pt -r ~/work/2025-04-21-Kws2SdkDeploy/lvp/lvp_tws -p xiaoshu_aiot -dv v.0.1.0
WARNING: [KwsModelAutoDeploy]: Note! The xiaoshu_aiot project already exists and the set v.0.1.0 version already exists
WARNING: [KwsModelAutoDeploy]: Note! Existing versions under the xiaoshu_aiot project: ['v.0.1.0']
Overwrite the existing v.0.1.0 version? y/n: yes
INFO: [GetWordThreshold]: Note! Word: 你好小树 has no 'Event ID' configured in /home/liushk/work/2025-04-21-Kws2SdkDeploy/lvp/lvp_tws/tools/kws_model_auto_deploy/model_77.pt/keyword.txt, defaulting to 100
INFO: [GetWordThreshold]: Note! Word: 你好小树 has no 'Main Wake-up' configured in /home/liushk/work/2025-04-21-Kws2SdkDeploy/lvp/lvp_tws/tools/kws_model_auto_deploy/model_77.pt/keyword.txt, defaulting to main wake-up
INFO: [GetWordThreshold]: Note! Word: 打开灯光 has no 'Event ID' configured in /home/liushk/work/2025-04-21-Kws2SdkDeploy/lvp/lvp_tws/tools/kws_model_auto_deploy/model_77.pt/keyword.txt, defaulting to 100
INFO: [GetWordThreshold]: Note! Word: 打开灯光 has no 'Main Wake-up' configured in /home/liushk/work/2025-04-21-Kws2SdkDeploy/lvp/lvp_tws/tools/kws_model_auto_deploy/model_77.pt/keyword.txt, defaulting to main wake-up
INFO: [GetWordThreshold]: Note! Word: 关闭灯光 has no 'Event ID' configured in /home/liushk/work/2025-04-21-Kws2SdkDeploy/lvp/lvp_tws/tools/kws_model_auto_deploy/model_77.pt/keyword.txt, defaulting to 100
INFO: [GetWordThreshold]: Note! Word: 关闭灯光 has no 'Main Wake-up' configured in /home/liushk/work/2025-04-21-Kws2SdkDeploy/lvp/lvp_tws/tools/kws_model_auto_deploy/model_77.pt/keyword.txt, defaulting to main wake-up
WARNING: [KwsModelAutoDeploy]: Overview of word information for this model deployment
WARNING: Order: 0 Word: 你好小树 Threshold: 935 Event ID: 100 Main Wake-up: 1
WARNING: Order: 1 Word: 打开灯光 Threshold: 907 Event ID: 100 Main Wake-up: 1
WARNING: Order: 2 Word: 关闭灯光 Threshold: 903 Event ID: 100 Main Wake-up: 1
INFO: [CreateLvpAcousticModelPackage]: Note! Generating LVP acoustic model package!
INFO: [CreateLvpAcousticModelPackage]: Note! LVP acoustic model package generation completed!
INFO: [RebulidLvpAutoconf]: Note! Using default configuration: /home/liushk/work/2025-04-21-Kws2SdkDeploy/lvp/lvp_tws/configs/kws_model_auto_deploy_config/kws_model_auto_deploy.config
INFO: [Shell]: Note! Command: make defconfig
INFO: [RebulidLvpAutoconf]: Note! Successfully generated: /home/liushk/work/2025-04-21-Kws2SdkDeploy/lvp/lvp_tws/.config in the LVP SDK project!!!
Case 2: Trained with Main Wake-up Words and Command Words*
-
In this case, you need to enter the KWS original model package and correctly configure the event ID and main wake-up flag in
keyword.txt -
The tool will read the words, word order, event IDs, main wake-up flags, etc., from keyword.txt and deploy them to the SDK
-
Missing or unconfigured items will automatically use default values
- Event ID defaults to 100
- Automatically defaults to main wake-up
-
Step 1:
-
Configure the
Event IDandMain Wake-upfieldsvim model_77.pt/keyword.txt # Enter the ordered word list file of the BunKws output model package # Before modification <filler> -1 你好小树 0 打开灯光 1 关闭灯光 2 # Add the Event ID and Main Wake-up fields; after modification <filler> -1 你好小树 0 事件id: 100 是否主唤醒:1 #1 indicates main wake-up, 0 indicates non-main wake-up 打开灯光 1 事件id: 101 是否主唤醒: 0 关闭灯光 2 事件id: 102 是否为主唤醒 0 -
Step 2:
-
After modification, save and exit
-
Execute the tool deployment
$ ./kwsModelAutoDeploy -i model_77.pt -r ~/work/2025-04-21-Kws2SdkDeploy/lvp/lvp_tws -p xiaoshu_aiot -dv v.0.1.0 WARNING: [KwsModelAutoDeploy]: Note! The xiaoshu_aiot project already exists and the set v.0.1.0 version already exists WARNING: [KwsModelAutoDeploy]: Note! Existing versions under the xiaoshu_aiot project: ['v.0.1.0'] Overwrite the existing v.0.1.0 version? y/n: yes WARNING: [KwsModelAutoDeploy]: Overview of word information for this model deployment WARNING: Order: 0 Word: 你好小树 Threshold: 935 Event ID: 100 Main Wake-up: 1 WARNING: Order: 1 Word: 打开灯光 Threshold: 907 Event ID: 101 Main Wake-up: 0 WARNING: Order: 2 Word: 关闭灯光 Threshold: 903 Event ID: 102 Main Wake-up: 0 INFO: [CreateLvpAcousticModelPackage]: Note! Generating LVP acoustic model package! INFO: [CreateLvpAcousticModelPackage]: Note! LVP acoustic model package generation completed! INFO: [RebulidLvpAutoconf]: Note! Using default configuration: /home/liushk/work/2025-04-21-Kws2SdkDeploy/lvp/lvp_tws/configs/kws_model_auto_deploy_config/kws_model_auto_deploy.config INFO: [Shell]: Note! Command: make defconfig INFO: [RebulidLvpAutoconf]: Note! Successfully generated: /home/liushk/work/2025-04-21-Kws2SdkDeploy/lvp/lvp_tws/.config in the LVP SDK project!!!