Requirement:

For training:

  • scikit-learn
  • pytorch

For deployment on board:

  • MDK5

How to train our model

We implemented custom feature extraction and used logistic regression from scikit-learn. the training script is present in model_training_design\train_model.py Our implementation is based on the feature extraction function implemented in the train_model.py file. The best intercept from the logicistic regression are extracted and used for deployment on the board.

To run the training, simply run the python script train_model.py with following parameters path_data and path_indices, the result will display the Intercept and Coefficients learned from the logistic regression.

How to validate UBPercept model

Note: He have not used X-CUBE-AI for generating our model, rather we implemented our own from scratch.

In the folder deploy_design, we have the design implemented in the main.c and used the template provided by TEST_OwnModel.zip. In the project, the file main.c contains all the functions needed for classification result.

Note: no need to implement Model_Init() method is the function as we do not have any neural network to be loaded, rather all the logistic regression intercept and coefficient are hardcoded in the main.c, predict_logistic_reg_v2() function.

We only impelemnted aiRun function to inference the input IEMG segment. The rest of the code, including data reception, data transmission and serial communication, is retained as a template.

Use the same steps as defined in Load Program to Board section of README-Cube.md Also mentioned below:

Load Program to Board

  1. Connet the boadr to computer.

    image-20220627203515997
  2. Open project in MDK5 and build.

    build

  3. Check if the debugger is connected.

    First, click Options for Target.

    targets

    Then switch to Debug and click Settings.

    debug

    If the debugger is connected, you can see the IDCODE and the Device Name.

    swdio

    Finally, switch to Flash Download and check Reset and Run

    full chip

  4. Now you can load program to the board.

    load

Validation

We use usb2micro usb cable to connect the development board and the upper computer to achieve communication.

image-20220827121203762

Afering connect the board to PC, run the validation.py , when seeing output like below, press the reset button shown in the picture, and the validation will start.

iShot_2022-08-27_12.04.57