Skip to content

Commit b5043f4

Browse files
authored
Merge pull request #1234 from arduino/sebromero/img-classifier-deployment
Update tutorial to reflect latest version of EI studio
2 parents b55faf7 + 4ba29f3 commit b5043f4

File tree

5 files changed

+6
-23
lines changed

5 files changed

+6
-23
lines changed
-14.6 KB
Loading

content/hardware/06.nicla/boards/nicla-vision/tutorials/image-classification/content.md

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -143,33 +143,18 @@ The ML model is trained and already optimized to be used with microcontrollers.
143143

144144
### Deploy
145145

146-
Deploying the ML model to your board requires a few steps. The Edge Impulse® Studio provides an export feature for OpenMV. Switch to the deployment section in the menu, select OpenMV under "Build firmware" and click "build". This will create an OpenMV compatible library and download it as a zip file. Unzip it.
146+
Deploying the ML model to your board requires a few simple steps. The Edge Impulse® Studio provides an export feature for OpenMV. Since the Nicla Vision doesn't have any on-board SRAM we need to bake the machine learning model into the firmware and load it from the flash. Switch to the deployment section in the menu, select "OpenMV Firmware" under "Configure your deployment" and click "build". This will create an OpenMV compatible firmware that includes the machine learning model. Unzip the file once it's downloaded. The download should start automatically.
147147

148148
![The Edge Impulse® Studio has a built-in export function for OpenMV](assets/deployment.png)
149149

150-
Since the Nicla Vision doesn't have any on-board SRAM we need to build the machine learning model into the firmware and load it from the flash. To do so, go to https://github.com/openmv/openmv and [fork](https://docs.github.com/en/get-started/quickstart/fork-a-repo) the repository. In your fork click on "Actions" and enable the workflows by clicking on the green button.
151150

152-
Rename the machine learning model and the label file to fruit_detection.tflite and fruit_detection.txt respectively. In your fork, replace the built-in machine learning model under `src/lib/libtf/models` with the model you downloaded from Edge Impulse® Studio. Commit the files and push the commit to the repository. It will build a new firmware automatically.
153-
154-
![The model that shall be baked into the firmware needs to be stored under src/lib/libtf/models](assets/github_model_path.png)
155-
156-
You can inspect the build process under "Actions".
157-
158-
![In the actions section you can monitor the build process once it starts.](assets/github_actions.png)
159-
160-
Once the firmware has been built you can download it from the releases section that you can find in the "Code" tab. Put the board in bootloader mode and click on the connect symbol in the OpenMV IDE. In the dialog select "Load a specific firmware". Select `firmware.bin` in the folder that you just created and flash it to the board.
161-
162-
![In the release section you can find the generated firmware ready to download and install.](assets/github_releases.png)
151+
Put the board in bootloader mode and click on the connect symbol in the OpenMV IDE. In the dialog select "Load a specific firmware". Select `edge_impulse_firmware_arduino_nicla_vision.bin` in the folder that you created while unziping the downloaded file and flash it to the board.
163152

164153
### Run the Script
165154

166-
The final step is to run the **ei_image_classification.py** script. Open it in the OpenMV. As the model is now baked into the firmware you need to adjust the lines where it loads the model and the labels as follows:
155+
The final step is to run the **ei_image_classification.py** script. Open it in the OpenMV IDE.
167156

168-
```python
169-
labels, net = tf.load_builtin_model('fruit_detection')
170-
```
171-
172-
Also, replace the print statement in the innermost for loop with the following code:
157+
Replace the print statement in the innermost for loop with the following code:
173158

174159
```python
175160
confidence = predictions_list[i][1]
@@ -199,7 +184,7 @@ sensor.set_hmirror(True)
199184
sensor.set_windowing((240, 240)) # Set 240x240 window.
200185
sensor.skip_frames(time=2000) # Let the camera adjust.
201186

202-
labels, net = tf.load_builtin_model('fruit_detection')
187+
labels, net = tf.load_builtin_model('trained')
203188

204189
clock = time.clock()
205190
while(True):
@@ -231,6 +216,4 @@ You have learned about classification as a machine learning concept which catego
231216

232217
## Troubleshooting
233218

234-
### GitHub Workflow
235-
236-
If you’re encountering difficulties while using the GitHub workflow in your forked repository, make sure that you chose `MobileNetV2 96x96 0.1` as model type, otherwise the model will likely be too big. Also make sure you are changing the files in your own, forked repository and not in the original OpenMV repository.
219+
If you’re encountering difficulties while deploying your machine learning model, make sure that you chose `MobileNetV2 96x96 0.1` as model type, otherwise the model will likely be too big.

0 commit comments

Comments
 (0)