How to classify socks using a Raspberry Pi, Edge Impulse, and balena

I am following this guide: Edge Impulse and Balena in order to classify socks using a Raspberry Pi 3, Edge Impulse and Balena.

I have trained the model using three labels: pair, unpair and unknown and deployed the EdgeImpulse balenaCam project to the rpi 3 with balena.

It is deployed and works as expected.
Actually if I go to the local ip, I can see the live stream of the camera.

However the problem is that I see the default labels of the github project: flipflops, running, sneakers and unknown instead of my own: pair, unpair and unknown: image
Why are the default labels not overriden?
How can I fix this?
Thank you for your time


Hello @stratosb first of all thanks for writing at the blogpost.

Actually another user of this library complained yesterday about this and Edge Impulse is working on trying to solve the problem.

Could you please confirm that you changed the EI API KEY and PROJECT ID?

Thank you for your reply @mpous .

I do confirm that I have changed both device service variables.

Trying the project myself to see where is the bug!

Actually this code updates automatically the Edge Impulse project from your account

1 Like

From the Edge Impulse Dashboard, I created a new API KEY today and named it balena.

I used this one for the device service variable, and not the one with name stratosb-project-1-key

Is this ok?

Yes! i used to do the same! Testing here :slight_smile:

Hey @stratosb I am facing the same problem too!
As per the latest updates from @mpous and some other people at Edge Impulse can you confirm that you have first build the model and exported as a .wasm file from the deployment tab in Edge Impulse studio and then started running it in the balena dashboard ?
Also did you get any errors while compiling…because I too got one error in the deployment tab.

Hi @arijit,
Thank you for your reply.
Yes I first built the model and exported the .wasm file.
However according to the guide, we won’t need this file since the project automatically downloads the model once it’s on the balenaCloud using our Edge Impulse API KEY and PROJECT ID.
What error did you get while compiling at the Edge Impulse dashboard or the Balena dashboard?

Hello @stratosb!
Well I do know that the blog post doesn’t says so. Did you get any errors while compiling and exporting the .wasm library from the Edge Impulse studio ?

Hi @arijit, although the .wasm library is exported, the build output returns the following error:

Job started
Compiling WASM library…
mkdir -p build/
emcc -DTF_LITE_DISABLE_X86_NEON -std=c++11 -I. -Isource -Iedge-impulse-sdk/ -Iedge-impulse-sdk/utensor -Iedge-impulse-sdk/utensor/src -Iedge-impulse-sdk/utensor/src/uTensor -Iedge-impulse-sdk/utensor/src/uTensor/core -Iedge-impulse-sdk/utensor/src/uTensor/loaders -Iedge-impulse-sdk/utensor/src/uTensor/ops -Iedge-impulse-sdk/utensor/src/uTensor/util -Iedge-impulse-sdk/tensorflow -Iedge-impulse-sdk/third_party -Iedge-impulse-sdk/third_party/flatbuffers -Iedge-impulse-sdk/third_party/flatbuffers/include -Iedge-impulse-sdk/third_party/flatbuffers/include/flatbuffers -Iedge-impulse-sdk/third_party/gemmlowp/ -Iedge-impulse-sdk/third_party/gemmlowp/fixedpoint -Iedge-impulse-sdk/third_party/gemmlowp/internal -Iedge-impulse-sdk/third_party/ruy -Imodel-parameters -Itflite-model -Iedge-impulse-sdk/anomaly -Iedge-impulse-sdk/classifier -Iedge-impulse-sdk/dsp -Iedge-impulse-sdk/dsp/kissfft -Iedge-impulse-sdk/porting -O3 -s WASM=1 -s ASSERTIONS=1 -s ALLOW_MEMORY_GROWTH=1 -s TOTAL_MEMORY=128MB --bind tflite-model/*.cpp emcc_binding.cpp /app/libsdk.o -o build/edge-impulse-standalone.js
tflite-model/trained_model_compiled.cpp:5991:72: warning: format specifies type ‘unsigned int’ but the argument has type ‘size_t’ (aka ‘unsigned long’) [-Wformat]
printf(“ERR: Failed to allocate persistent buffer of size %u\n”, bytes);
~~ ^~~~~
1 warning generated.
Compiling WASM library OK
Job completed

Did you get the same warning?

Yup I’m getting the exact same error! I guess there might be some problem with the Edge Impulse server.

1 Like

Actually, I have opened an issue about this on EdgeImpulse: EdgeImpulse forum

Hi @mpous,
what is the feedback from your testing?
Can I try it again?
Has it been fixed?
Thank you

Hello @stratosb apologizes! i was off the last days!

Could you please confirm me if you are using the Raspberry Pi 3 32bit or 64bit balenaOS?

No worries Marc,
I am using the Raspberry Pi 3 32bit and balenaOS 2.58.3+rev1.
Thank you.

Could you please try with a new app on 64bits?

You mean balenaOS 64-bit?
This means that balenaOS 2.58.3+rev1 is 32-bit?

Which version is balenaOS 64-bit and how can I differentiate it from its 32-bit version?
Can balenaOS 64-bit run on Raspberry Pi 3 32bit?

I mean this Captura de Pantalla 2021-01-07 a les 14.55.29

1 Like

To answer your previous question, the balenaOS 64 bits can run 32 bits containers, that’s ok. Not the other way round.

I’m asking this because it used to work with Raspberry Pi 4 (it’s only 64 bits) and it’s weird why it doesn’t work on 32 bits.

Last day we talked i tried with 2 pi 3 i have on my desk but the sd cards had issues and i failed to test. I will try again!

1 Like

Ok I will try it and let you know.
Thank you for your support.