In this post I will show you how to improve my first model that I made in Edge Impulse. As you will remember, I obtained an accuracy of 70.5% and a loss value of 0.89.
Reporting a Bug in OpenMV
If I increase the number of images samples, we can increase the accuracy scores and reduce loss value, however the size model will be increase above 2 MB. Remember that the flash memory of the Nicla Vision is 2 MB. The idea is to load the model in the flash memory because if we use the ROM memory to load the model and run the code, this will not work.Below I show you an error report that I had when I increased the number of samples.
So that you understand me, here are the details of the bug that I reported to technical support of OpenMV: https://forums.openmv.io/t/openmv-cant-build-a-new-firmware-for-nicla-vision/8200
Selecting Best Samples
Since we are limited by the memory of the Nicla Vision, Then my strategy is to select the best images loaded in my project and reorganize it.
When I talk about choosing the best images, I mean the ones with the best details, and with backgrounds of different colors. Blurred and cropped images must be removed. Below you can see samples of images of bees, spiders and unknown images that I used to train my model.
Below I show you the features generated after these changes. As you can see, the three classes are bee, spider and unknown.
Training the Model
We retrain the model and see that we get better results. now the accuracy is 74.1% and the loss value is 0.58.
With the changes made we have increased the accuracy from 70.5% to 74.1%. We have also reduced the loss value from 0.89 to 0.58. Therefore we have improved and now we can test this model on our Nicla Vision board.
Model Testing
Edge Impulse has a facility to test the model created with the uploaded dataset. Below I show you the results and you can see a good accuracy of 81.69%, which is a good indicator for our purposes.
OpenMV Library
- Now that we have a Machine Vision model that works, we can use EdgeImpulse to generate an OpenMV library that can be flashed to the Nicla Vision and be called from a Python script.
- As we saw in the previous chapter, Select Deployment from the menu bar, choose OpenMV from the library section, and click Build
- This will build the file, then open a file browser to input the download location – you will get the zip archive.
Once downloaded the compressed file in zip format, below I show you the model files.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.