Local training pipeline for "Brainchip / Image Classification project using BrainChip MetaTF and Akidanet models"
This is the local training pipeline (based on Keras / TensorFlow) for your Edge Impulse project Brainchip / Image Classification project using BrainChip MetaTF and Akidanet models (http://localhost:4800/studio/134706). Use it to train your model locally or run experiments. Once you're done with experimentation you can push the model back into Edge Impulse, and retrain from there.
You run this pipeline via Docker. This encapsulates all dependencies and packages for you.
-
Install Docker Desktop.
-
Open a command prompt or terminal window.
-
Build the container:
$ docker build -t custom-block-134706 .
-
Train your model:
macOS, Linux
$ docker run --rm -v $PWD:/scripts custom-block-134706 --data-directory data --out-directory out
Windows
$ docker run --rm -v "%cd%":/scripts custom-block-134706 --data-directory data --out-directory out
-
This will write your model (in TFLite, Saved Model and H5 format) to the
out/
directory.
If you have extra packages that you want to install within the container, add them to requirements.txt
and rebuild the container.
To get up-to-date data from your project:
-
Install the Edge Impulse CLI v1.16 or higher.
-
Open a command prompt or terminal window.
-
Fetch new data via:
$ edge-impulse-blocks runner --download-data data/
You can also push this block back to Edge Impulse, that makes it available like any other ML block so you can retrain your model when new data comes in, or deploy the model to device. See Docs > Adding custom learning blocks for more information.
-
Install the Edge Impulse CLI.
-
Make sure you run the training pipeline once locally - as we download some things on demand. This is not possible in Edge Impulse as your block runs without a connection to the outside world.
-
If you require extra dependencies you need to add them to
requirements.txt
(or callpoetry install
again inDockerfile
). -
Open a command prompt or terminal window.
-
Push the block to Edge Impulse via:
$ edge-impulse-blocks push
-
Depending on the data your block operates on, you can add it via:
- Object Detection: Create impulse > Add learning block > Object Detection (Images), then select the block via 'Choose a different model' on the 'Object detection' page.
- Image classification: Create impulse > Add learning block > Transfer learning (Images), then select the block via 'Choose a different model' on the 'Transfer learning' page.
- Audio classification: Create impulse > Add learning block > Transfer Learning (Keyword Spotting), then select the block via 'Choose a different model' on the 'Transfer learning' page.
- Other (classification): Create impulse > Add learning block > Custom classification, then select the block via 'Choose a different model' on the 'Machine learning' page.
- Other (regression): Create impulse > Add learning block > Custom regression, then select the block via 'Choose a different model' on the 'Regression' page.
- Build the container (see above).
- Go to an organization, Custom blocks > Machine learning > Add new Machine learning block.
- Set 'Docker container' to
custom-block-134706
. - Add the block under Create impulse.
This is a lot faster than building through the CLI, as you bypass Kaniko.