Skip to main content

Edge Impulse Linux SDK for Python

This library lets you run machine learning models and collect sensor data on Linux machines using Python. This SDK is part of Edge Impulse where we enable developers to create the next generation of intelligent device solutions with embedded machine learning. Start here to learn more and train your first model.

Installation guide

  1. Install a recent version of Python 3 and pip tools.

  2. Install the SDK:

    Raspberry Pi

    $ sudo apt-get install libatlas-base-dev libportaudio0 libportaudio2 libportaudiocpp0 portaudio19-dev libopenjp2-7 libgtk-3-0 libswscale-dev libavformat58 libavcodec58
    $ pip3 install edge_impulse_linux -i https://pypi.python.org/simple
    

    Other platforms

    $ pip3 install edge_impulse_linux
    
  3. Clone this repository to get the examples:

    $ git clone https://github.com/edgeimpulse/linux-sdk-python
    
  4. Install pip dependencies:

    $ pip3 install -r requirements.txt
    

    For the computer vision examples you'll want opencv-python>=4.5.1.48,<5 Note on macOS on apple silicon, you will need to use a later version, 4.10.0.84 tested and installs cleanly

Collecting data

Before you can classify data you'll first need to collect it. If you want to collect data from the camera or microphone on your system you can use the Edge Impulse CLI, and if you want to collect data from different sensors (like accelerometers or proprietary control systems) you can do so in a few lines of code.

Collecting data from the camera or microphone

To collect data from the camera or microphone, follow the getting started guide for your development board.

Collecting data from other sensors

To collect data from other sensors you'll need to write some code to collect the data from an external sensor, wrap it in the Edge Impulse Data Acquisition format, and upload the data to the Ingestion service. Here's an end-to-end example.

Classifying data

To classify data (whether this is from the camera, the microphone, or a custom sensor) you'll need a model file. This model file contains all signal processing code, classical ML algorithms and neural networks - and typically contains hardware optimizations to run as fast as possible. To grab a model file:

  1. Train your model in Edge Impulse.

  2. Install the Edge Impulse for Linux CLI.

  3. Download the model file via:

    $ edge-impulse-linux-runner --download modelfile.eim
    

    This downloads the file into modelfile.eim. (Want to switch projects? Add --clean)

Then you can start classifying realtime sensor data. We have examples for:

  • 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.
  • Video - grabs frames from a video source from your hard drive and classifies it.
  • Custom data - classifies custom sensor data.

Troubleshooting

Collecting print out from the model

To display the logging messages (ie, you may be used to in other deployments), init the runner like so

# model_info = runner.init(debug=True) # to get debug print out

This will pipe stdout and stderr into the same of your own process

[Errno -9986] Internal PortAudio error (macOS)

If you see this error you can re-install portaudio via:

brew uninstall --ignore-dependencies portaudio
brew install portaudio --HEAD​

Abort trap (6) (macOS)

This error shows when you want to gain access to the camera or the microphone on macOS from a virtual shell (like the terminal in Visual Studio Code). Try to run the command from the normal Terminal.app.

Metadata

Release files for edge-impulse-linux 1.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for edge-impulse-linux 1.2.2
File Size Uploaded
edge_impulse_linux-1.2.2.tar.gz 12.0 kB Details

Release files / edge_impulse_linux-1.2.2.tar.gz

Download URL edge_impulse_linux-1.2.2.tar.gz
Size 12.0 kB
Tags Source
SHA-256 checksum
How to use checksums
3a908edc53c0382e133c9e3b8d6f7f4e3870a3abe0a7986edc7ae6f4c3611cad
BLAKE2b-256 checksum
How to use checksums
661ed8ef9cdd120533ea66752e858dfa8f14ded2e71e71e03e66a3b65fd0d6a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.25

Release history Release notifications | RSS feed

This release

1.2.2 This release

1 release file

1.2.1

1 release file

1.2.0

1 release file

1.1.0

1 release file

1.0.12

1 release file

1.0.11

1 release file

1.0.10

1 release file

1.0.9

1 release file

1.0.8

1 release file

1.0.7

1 release file

1.0.6

1 release file

1.0.5

1 release file

1.0.4

1 release file

1.0.3

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page