7.4 Training Loop
Create a loop with a training platform and the Nx AI Manager.
General preparation
This tutorial assumes you have the following things already set up:
Nx Cloud account.
Nx Meta system installed.
System connected to Nx Cloud account.
Client installed.
Device added to configuration.
Nx AI plugin installed.
Installed the sclbl-integration-sdk repository.
git clone https://github.com/scailable/sclbl-integration-sdk.git
Followed the ‘Get started’ instructions.
Edge Impulse preparation
When building a loop with Edge Impulse there are a couple of requirements.
Project with a model configured.
API key:
From the main dashboard page find the tab ‘Keys’ and select it.
If there are no keys press ‘Add new API key’.
Enter a name and select the role ‘Admin’.
Project ID:
The project ID is located in the URL of the page. For instance in https://studio.edgeimpulse.com/studio/1234 the project-id is 1234.
Steps
We will describe the loop in 6 steps.
Add model to the Nx AI Cloud
Update postprocessor
Configure model and postprocessor
Run the model
Check the data
Update the model in the cloud
Update model in the system
Step 1: Add model to Nx AI Cloud
We will add the model of the training platform to the Nx AI Cloud.
For Edge Impulse
Log in the Nx AI Cloud and click ‘Add a model’.
Select ‘Edge Impulse’, enter the API key and project ID.
Click ‘Link model’.
Now the model will be downloaded from Edge Impulse and will be prepared for use.
Step 2: Update postprocessor
We will take an example postprocessor from the sclbl-integration-sdk and modify it with a specific condition to filter only specific images to send.
For Edge Impulse
Open the sclbl-integration-sdk into your favourite editor.
Open the following Python script: postprocessor-python-edgeimpulse-example/postprocessor-python-edgeimpulse-example.py
Find the location where the API is set and replace it with the API-key from your project. Look for the line:
edgeimpulse.API_KEY
Find the line
upload_sample = False
and modify the code below that to suit your condition.Compile and install the postprocessor using the instructions in the README.md of the project.
Step 3: Configure model and postprocessor
We will select the model and postprocessor.
In the Nx client go to the device, right click and select ‘Camera settings’.
Go to the tab ‘Plugins’ and select the ‘Nx AI Manager’.
Click ‘Manage server’ and click the icon with left-right arrows called ‘Replace model’ or ‘Assign a new model’ if a model was not already assigned.
Choose the model from step 1 and click ‘Ok’.
Under the heading ‘Assigned Models’, select ‘Post Processor’ and select your post processor from step 2. If you didn’t rename it from the README it is called ‘Example-Postprocessor’.
Under the heading ‘Runtime Status’, click ‘Start’ and wait for the status to be ‘Runtime is running’.
Click ‘Ok’ at the bottom.
Step 4: Run the model
To run the model the device must be visible in the layout.
Double click your device to make it visible.
On the top right click the left icon ‘Object search’ if the model contains bounding boxes to see them.
Step 5: Check the data
Now we are going to check the incoming data, label it and then retrain.
Edge Impulse
Go to the project page.
Select ‘Data acquisition’.
Training and Test should contain data coming from the server.
Label the data.
Select ‘Retrain model’ and then ‘Train model’.
Step 6: Update the model in the cloud
We are going to update the model in the Nx AI Cloud.
Two ways to update the model
Go back to the ‘Manage server’ in the Nx Client / AI plugin and click the name of the model.
Log into the AI Cloud and go to the model.
Click the button ‘Update from <TrainingPlatform>’
Step 7: Update model in the system (WorkInProgress)
We are going to update the models in the system.
(option not available yet) In the Nx Client / AI plugin click the button ‘Update models’.
Manually delete the model cache. Follow these instructions:
On the cmdline:
cd /opt/networkoptix-metavms/mediaserver/bin/plugins/nxai_plugin/nxai_manager/cache
rm *
In the Nx Client / AI plugin stop and start the plugin