Run eim model in linux distro

Possibile implementation eim model to machine linux using python ??
If yoes what best method??
Thanks a lot…

@Daniele771 Yes, see https://docs.edgeimpulse.com/docs/edge-impulse-for-linux -> Python section.

But Every time i Need to expand my dataset i’ll ti retrain all?

@Daniele771,

Yes, consider this learning process as an iterative process.
When you have more data, once in a while retrain your model and redeploy it and you will have better results over time.

Regards,

So i install in Linux edge-impulse-cli and ok but i’m not fully understand now how use model trained

.
Can i download model in tflite from dashboard ?
For testing in python …

Yes you can.

To use your model with python I would mostly start with one of our examples like this one:

Try to run it and then you can start changing the code.

We also have different examples for different sensors depending on your project:

  • Audio - grabs data from the microphone and classifies it in realtime.
  • Camera - grabs data from a webcam and classifies it in realtime.
  • Camera (full frame) - grabs data from a webcam and classifies it twice (once cut from the left, once cut from the right). This is useful if you have a wide-angle lense and don’t want to miss any events.
  • Still image - classifies a still image from your hard drive.
  • Custom data - classifies custom sensor data.

Regards,

Louis

2 Likes

That’s fantastic !!! Right now i have only two word on and off
:slight_smile: how to handle???

You can try the Audio script then :wink:

1 Like

Thanks a lot ok so i installed edge-linux-cli but when i run … for example edge-impulse-daemon
say command not found i attach installation …! how to connect at my web dashboard or download eim file??

You need the Edge Impulse for Linux CLI, see the install scripts here: https://docs.edgeimpulse.com/docs/edge-impulse-for-linux.

1 Like

Seems something wrong on path … i write ```
npm config get prefix

and i have 
/home/dani/.npm-global

Ok solve problem for Kali Linux !! Need to add Path manually " nano etc/enviroments and add for my case /home/dani/.npm-global/bin but now he Say can’t run in x64 machine only arm processor can i download manually eim file ?

@Daniele771 I’ve enabled the EIM models in the UI in your project (See Deployment tab). Note that on Linux x86 we don’t load hardware acceleration at the moment, so this will be pretty slow for image models, but fine for audio.

1 Like

thanks a lot ! i download x86 eim…file but i have this error when i run classify.py

python3 classify.py dani.eim 1 ⨯
Traceback (most recent call last):
File “/home/dani/Immagini/linux-sdk-python-master/examples/audio/classify.py”, line 65, in
main(sys.argv[1:])
File “/home/dani/Immagini/linux-sdk-python-master/examples/audio/classify.py”, line 43, in main
model_info = runner.init()
File “/home/dani/.local/lib/python3.9/site-packages/edge_impulse_linux/audio.py”, line 132, in init
model_info = super(AudioImpulseRunner, self).init()
File “/home/dani/.local/lib/python3.9/site-packages/edge_impulse_linux/runner.py”, line 26, in init
raise Exception(‘Model file "’ + self._model_path + ‘" is not executable’)
Exception: Model file “/home/dani/Immagini/linux-sdk-python-master/examples/audio/dani.eim” is not executable

i try to run also that

edge-impulse-linux-runner --model-file /home/dani/Immagini/linux-sdk-python-master/examples/audio/dani.eim

events.js:291
throw er; // Unhandled ‘error’ event
^

Error: spawn /home/dani/Immagini/linux-sdk-python-master/examples/audio/dani.eim EACCES
at Process.ChildProcess._handle.onexit (internal/child_process.js:268:19)
at onErrorNT (internal/child_process.js:470:16)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
Emitted ‘error’ event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:274:12)
at onErrorNT (internal/child_process.js:470:16)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
errno: ‘EACCES’,
code: ‘EACCES’,
syscall: ‘spawn /home/dani/Immagini/linux-sdk-python-master/examples/audio/dani.eim’,
path: ‘/home/dani/Immagini/linux-sdk-python-master/examples/audio/dani.eim’,
spawnargs: [ ‘/dev/shm/edge-impulse-clihPBt1n/runner.sock’ ]
}

can clarify why? help :slight_smile:

It seems that you don’t have the permission to access this .eim file.
Can you try using sudo? Or grant the directory access (linux-sdk-python-master/) to your user?

Regards,

You need to make the model executable via:

chmod +x path-to-model.eim
1 Like

I ran chmod +x .eim and no errors. However, when ran my python program again I got the following error:

File "/home/winlinuxuser/projects/classify-vehicle/test-numpy.py", line 20, in countAxles
  model_info = runner.init()
File "/home/winlinuxuser/.local/lib/python3.8/site-packages/edge_impulse_linux/image.py", line 19, in init
  model_info = super(ImageImpulseRunner, self).init()
File "/home/winlinuxuser/.local/lib/python3.8/site-packages/edge_impulse_linux/runner.py", line 30, in init
  self._runner = subprocess.Popen([self._model_path, socket_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
File "/usr/lib/python3.8/subprocess.py", line 858, in __init__
  self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.8/subprocess.py", line 1704, in _execute_child
  raise child_exception_type(errno_num, err_msg, err_filename)
  OSError: [Errno 8] Exec format error: '/home/winlinuxuser/projects/classify-vehicle/coin-detector.eim'

How are you referencing your .eim file in your python script?

From my Raspberry Pi 4 I downloaded the eim file as follows:

edge-impulse-linux-runner --download coin-detector.eim

Then I copied the .eim file to a Python program I am developing in Visual Studio Code > WSL2 > Ubuntu (my development box, where I intend to test & debug edge-impulse-linux models and OpenCV, is a Windows 10 machine with WSL2). My Python code where the model is used and crashes with the error I mentioned on my original post is the following one:

runner = None
model = 'coin-detector.eim'
dir_path = os.path.dirname(os.path.realpath(__file__))
modelfile = os.path.join(dir_path, model)

with ImageImpulseRunner(modelfile) as runner:
   try:
      model_info = runner.init() #<-- crashes here.

I should say, I believe to have installed edge-impulse-linux on my WSL2 > Ubuntu 20.04 development box as follows:

pip3 install edge_impulse_linux

Could the issue be the fact I am using an .eim model I downloaded from my Pi4 and I am using it on a Python program running in Ubuntu 20.04 (which should be an x86 instead)? If so, how can I download the .eim x86 file instead? If not, what I could be missing and/or doing wrong? :thinking:

I too get /home/winlinuxuser/.npm-global when I run npm config get prefix in my WSL2 Ubuntu 20.04 machine. If this is a wrong path, what should the correct path be?