Project Overview

This model employs the built-in accelerometer on Wio Terminal to recognize FLIP, WAVE, and IDLE movements.
It’s quite difficult to resolve the problem by using normal rule-based programming.
Because the same actions we called of human being are not exactly the same every time. If we use programming method that we will consider the different actions that different people do, there will be hundreds of different rules. In fact, it’s still an idealized situation. And there are still many different motions of people are not considered, such as speed, angle, and direction. A little changes in these factors will require new rules to be created. But machine learning can easily handle these changes.

Expected results

As the pictures below, Wio Terminal displays the current recognition results for the Wio Terminal’s actions in real-time. FLIP, WAVE, and IDLE.

Preparation

To achieve the expectation, we need these things:
Hardware requirements: Wio Terminal
Connection method:
image.png

Project Steps

  1. Create and Select Models
  2. Data Acquisition
  3. Training and Deployment
  4. Programming

    Steps

    1. Create and select models

    1.1 Create the “Motion Recognition(Built-in accelerometer)” model

    Click on “Model Creation”, click on “Motion Recognition(Built-in accelerometer)”, as shown in steps 1 and 2 below.
    image.png
    Enter a NAME according to the requirements.
    image.png
    Click “Ok”
    image.png
    Click Ok and it will automatically jump to the Data Acquisition interface.

    1.2 View the model

    image.png

    2. Data Acquisition

    2.1 Default label

    image.png
    image.png

    2.2 Connect the device and upload the default data acquisition programme in Codecraft

    When the Wio Terminal is connected, in the Codecraft surface, please clickimage.png, in the location shown below. This action will upload the default data acquisition programme.
    image.png
    The “Upload” pop-up window will appear, as shown in the figure below.
    Select the serial port number corresponding to the current Wio Terminal (not necessarily COM26 as shown in the figure) and click the “OK” button.
    image.png
    A pop-up window indicates that it is being uploaded, please wait…
    image.png
    The upload time is usually tens of seconds, and you will see the “Upload Successful” screen shown below when it is completed. This is shown in the image below.
    image.png
    Click “Roger” to close the upload success pop-up window above and return to the programming screen.

Motion Recognition by using built-in accelerometer - 图13 Caution

For the web version of Codecraft, if you don’t install or run the Device Assistant, you may get the message in the image below that you haven’t opened the Device Assistant yet. image.png In this case you can check this page for further information: Download, installation and “Device Assistance” Usage .

2.3 Data Acquisition

There is a step-by-step introduction to data acquisition in the upper right hyperlink, follow the instructions to collect data.
image.png
Attention:

  • Wio Terminal button location.
  • Animated gif has been accelerated, the actual action can slightly slow down.
  • Please notice the red tips.
  • When you move the mouse over the description text, there will be more detailed content.

image.png
image.png
Starting and finishing data acquisition according to the Wio Terminal display.
image.png This signal means data is being collected.
image.png
image.pngOK means collection is complete.
Motion Recognition by using built-in accelerometer - 图21

Wio Terminal shows that the data acquisition is finished, and CodeCraft is still uploading the data, it will take 1~2s to transfer the data from Wio Terminal to CodeCraft.
Now, the data acquisition is finished.
image.png
Click on “Training & Deployment”image.png

2.4 Collecting data from custom labels

Sampling data for custom labels is similar to the steps for capturing default labels

  • Add or modify the labels
  • Upload the data acquisition programme
  • Collect data
  1. Adding or modifying labels
  • Adding lables

In the LABLE screen, clickimage.png, positioned as shown in the image below.
image.png
Enter the label name and click “OK”.
image.png
The new label “shake” is added to the tab bar after successful addition.
image.png

  • Modify a label

You can change one of the default labels to a custom label name by modifying the label name.
Click on the label to be modified, a pop-up window will appear for modifying the label, just enter a new name.
image.png
The old label will be replaced with the modified label name after modification.
image.png

  1. Upload the data acquisition programme
    Select one of the blocks, as the picture below, and change the block name from “turn” to “shake”.
    shake.png
    After the successful changed, it will be shown as the following red box.
    shake5.png
    Click “Upload” to upload the data acquisition programme.
    image.png
    Select the serial port number corresponding to the current Wio Terminal (not necessarily COM26 as shown in the figure) and click the “OK” button, as shown in steps 1 and 2 below.
    image.png
    A pop-up window indicates that it is being uploaded, please wait and relax…
    Motion Recognition by using built-in accelerometer - 图34
    The upload time is usually 10s, and you will see the “Upload Successfully” when it is completed. This is shown in the image below.
    Motion Recognition by using built-in accelerometer - 图35
    Click “Roger” to close the upload success pop-up window above and return to the programming screen.

    3. Training and deployment

    3.1 Set neural network and parameters

    Select the suitable neural network size: one of small, medium and large
    Set parameters, set the number of training cycles (positive integer), learning rate (number from 0 to 1), minimum confidence rating(number from 0 to 1).
    The interface provides default parameter values.
    image.png

    3.2 Start training the model

    Click “Start training”
    image.png
    When you click “Start training”, the interface will say “Loading…”.
    image.png

The duration of “Loading..” varies depending on the size of the selected neural network (small, medium and large) and the number of training cycles, and the larger the size of the network and the number of training cycles, the longer it will take, so please be patient.

You can also infer the waiting time by observing the “Log”. In the figure below, “Epoch: 22/30” indicates that the total number of training rounds is 30, and 22 rounds have been trained.
image.png
After loading, you can see “TrainModel Job Completed” in the “Log”,and “Model Training Report” will be appeared to the interface.
image.png

3.3 Observe the model performance to select the ideal model

In the “Model Training Report” screen, you can observe the training results, including the accuracy, loss, and performance of the model on Wio Terminal.
If the training results are not satisfactory, you can go back to the first step of training the model, select another size of the neural network, or adjust the parameter settings and train again until you get a model with satisfactory results.
image.png

3.4 Deploy the ideal model

In the “Model Training Report” screen, click “Deploy Model”.
image.png
image.png
Click “Ok” to jump to the “Programming” screen after the pop-up window indicates that the deployment is complete.
image.png

4. Use and programming

4.1 Write the program for using the model

In the “Programming” interface, click on “Use Model” to use the deployed model.
image.png
Try to use your model by writing the following programme.
3axis.png

4.2 Upload the program to Wio Terminal

Click the “Upload” button.
image.png
Select the serial port number corresponding to the current Wio Terminal (not necessarily COM20 as shown in the figure) and click the “OK” button.
image.png
The first upload time is long and increases with the complexity of the model, so please be patient. The upload time for small models is about 4 minutes or longer(depend on your performance of your machine).
Motion Recognition by using built-in accelerometer - 图49
image.png

4.3 Wio Terminal test model

Description of result:
Even if the training model score reaches high still does not mean that the model is a good model. The phenomenon of a high score of the training model and poor prediction in actual use is called OVERFITTING, which is equivalent to the model memorizing the details of the training dataset rigidly and will not do the problem when facing new data, and is a problem that machine learning training models will encounter.
The solutions to this problem are:

  • Increase the dataset
  • Reduce the learning rate

Retrain the model again.

Save

Click on “SuperMaker”.
image.png
Modify the name and click Save.
image.png
image.png
You can view the saved works in “My projects”
image.png
Click on “turn” to see the corresponding work.
image.png