Run eim model in linux distro

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?

How were you able to download the .eim x86 model file? I will appreciate your details. :slight_smile:

Hello @rgvgreatcoder,

x86 on Linux is not yet officially supported (consequently either documented). However, we needed it for a project so most of the work has been done and you should be able to download it when downloading it from your Ubuntu machine.

Can you try to install Edge Impulse Linux CLI from your Ubuntu machine please to be able to download the model?

npm install edge-impulse-linux -g

Then, if you run the helper, you should see the following output:

edge-impulse-linux-runner --help
Usage: edge-impulse-linux-runner [options]

Edge Impulse Linux runner 1.2.6

Options:
  -V, --version        output the version number
  --model-file <file>  Specify model file, if not provided the model will be fetched from Edge Impulse
  --api-key <key>      API key to authenticate with Edge Impulse (overrides current credentials)
  --download <file>    Just download the model and store it on the file system
  --clean              Clear credentials
  --silent             Run in silent mode, don't prompt for credentials
  --quantized          Download int8 quantized neural networks, rather than the float32 neural networks. These might run faster on some architectures, but
                       have reduced accuracy.
  --enable-camera      Always enable the camera. This flag needs to be used to get data from the microphone on some USB webcams.
  --dev                List development servers, alternatively you can use the EI_HOST environmental variable to specify the Edge Impulse instance.
  --verbose            Enable debug logs
  -h, --help           output usage information

So make sure you can run the standalone inference using:

edge-impulse-linux-runner --model-file coin-detector.eim

If theses steps work, you can use our Python SDK to go further.

Note that I haven’t fully used our Python SDK on linux yet, I will probably use it later this month in order to prepare the following webinar: https://www.sparkfun.com/perfecting_factory_5_with_edge

Regards,

Louis

@rgvgreatcoder @louis Note: x86 on Linux is officially supported. If you want to download from the Studio go to Dashboard, and enable ‘Show Linux deploys’. You can then download all available eim models from the Deployment page.

You can also download via the CLI via:

edge-impulse-linux-runner --download mymodel.eim --force-target runner-linux-x86_64
1 Like

Guys,

I wanted to share that I was able to run both: edge impulse CLI and edge impulse library in my Python code, in my Ubuntu 20.04 that runs in WSL2 in my Windows 10 machine!

Using the Windows Terminal to open up Ubuntu, I ran the following:

pip3 install edge_impulse_linux # To use in the Python code
npm install edge-impulse-linux -g # To install the CLI

Then I used Visual Studio Code with the “Remote - WSL” plug in, I was basically running VSCode inside Ubuntu machine. So in there, I created the my new Python project.

To use the edge impulse model (.eim file) on my Python code, I ran the following command to download it (as you mentioned above):

edge-impulse-linux-runner --download mymodel.eim --force-target runner-linux-x86_64

I had no issues after that. Thank you all for your support! … :smiley: