Classify more than one input_buffer of data for C++ Deployed Code

Question/Issue: Is there a way to classify more than one input_buffer of data at once for the C++ deployed Code?

Context/Use case: Hello, I would like to classify multiple input_buffers of data at once with the C++ deployed code. If there a way to have multiple input_buffers or reading in an array of data from a text file to use in the code?

Hi @ea4917

I guess you should be able to but can you please share some code for us to review, @mateusz or @shawn_edgeimpulse can offer some input if you share enough detail. Thanks!

Best

Eoin

Hi @ea4917 ,
The general answer is no. You can’t add two input data to the same impulse at the same time. If you want to achieve something like parallel computing to speed up the operation, our SDK does not support such a solution. Bear in mind that running two interpreters in parallel will require twice as many resources (especially RAM) and possibly an MCU/CPU with two or more cores.
However, if you could share more details as @Eoin suggests, then we can propose another solution.

As for reading the input data from a text file (I assume you are running it under Linux), it’s relatively easy. Just write a simple code to open the file, read and parse the data, and send it to the classifier.
A Python example is here

BR,
Matt

Hi @Eoin and @mateusz,

Thanks for getting back to me. This is the link to my project: Left Foot Move Classification - Dashboard - Edge Impulse. I deployed it using c++, so that is the code I have. And I am using a Mac computer.

For the python example, how can I make sure the impulse runs my own classifier? Also, since I am using a Mac computer will the linux runner work?

Thanks,

Hi @mateusz,

I tried following the instruction of the ReadMe of the GitHub you linked. But when I run the custom classify.py: linux-sdk-python/examples/custom/classify.py

I get this error: (although I do have python3 and lumpy installed)
Traceback (most recent call last):
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/init.py”, line 24, in
from . import multiarray
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/multiarray.py”, line 10, in
from . import overrides
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/overrides.py”, line 8, in
from numpy.core._multiarray_umath import (
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpython-310-darwin.so, 0x0002): tried: ‘/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpython-310-darwin.so’ (mach-o file, but is an incompatible architecture (have ‘x86_64’, need ‘arm64’)), ‘/System/Volumes/Preboot/Cryptexes/OS/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpython-310-darwin.so’ (no such file), ‘/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpython-310-darwin.so’ (mach-o file, but is an incompatible architecture (have ‘x86_64’, need ‘arm64’))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/init.py”, line 130, in
from numpy.config import show as show_config
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/config.py”, line 4, in
from numpy.core._multiarray_umath import (
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/init.py”, line 50, in
raise ImportError(msg)
ImportError:

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  • The Python version is: Python3.10 from “/usr/local/bin/python3”
  • The NumPy version is: “1.26.4”

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: dlopen(/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpython-310-darwin.so, 0x0002): tried: ‘/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpython-310-darwin.so’ (mach-o file, but is an incompatible architecture (have ‘x86_64’, need ‘arm64’)), ‘/System/Volumes/Preboot/Cryptexes/OS/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpython-310-darwin.so’ (no such file), ‘/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpython-310-darwin.so’ (mach-o file, but is an incompatible architecture (have ‘x86_64’, need ‘arm64’))

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “/Users/…/linux_python?/linux-sdk-python/examples/custom/classify.py”, line 5, in
from edge_impulse_linux.runner import ImpulseRunner
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/edge_impulse_linux/init.py”, line 2, in
from edge_impulse_linux import audio
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/edge_impulse_linux/audio.py”, line 2, in
import numpy as np
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/init.py”, line 135, in
raise ImportError(msg) from e
ImportError: Error importing numpy: you should not try to import numpy from
its source directory; please exit the numpy source tree, and relaunch
your python interpreter from there.

@ea4917

For the python example, how can I make sure the impulse runs my own classifier?

For this purpose, just make sure you are passing the correct EIM file deployed from Studio (EIM is our custom format for models deployed to Linux/Mac targets). As you see the classify.py script prints the project name and owner.

Also, since I am using a Mac computer will the linux runner work?

To run your model under Mac OS, just export the model for macOS (x86). You will get the EIM model, then:

  1. Mark the model as executable: chmod +x path-to-model.eim
  2. Remove the quarantine flag: xattr -d com.apple.quarantine ./path-to-model.eim

The errors you see suggest you are trying to run x86 binary under Apple Silicon (M1/2/3). If you have Rosetta installed, the x86 EIM should work fine.

Best regards,
Matt

Hello @mateusz,

I’m unable to run my model under Mac OS. I’m not sure how to export the model for mac0S (x86). The I have previously deployed the model to c++, but I’m not sure where to get the EIM model.

Also, where would I find the path-to-model.eim?

Thanks

@ea4917
Go to the Deployment section, and in the Search deployment options field, type macos

The file you will download is the *.eim model