Skip to main content

Python runner for real-time ML classification

Project description

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.

  2. Install the SDK:

    Raspberry Pi

    $ sudo apt-get install libatlas-base-dev libportaudio0 libportaudio2 libportaudiocpp0 portaudio19-dev
    $ 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
    

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.
  • Custom data - classifies custom sensor data.

Troubleshooting

[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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

edge_impulse_linux-1.0.4.tar.gz (7.4 kB view details)

Uploaded Source

File details

Details for the file edge_impulse_linux-1.0.4.tar.gz.

File metadata

  • Download URL: edge_impulse_linux-1.0.4.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.6

File hashes

Hashes for edge_impulse_linux-1.0.4.tar.gz
Algorithm Hash digest
SHA256 7e2473daa3b0d032706a204fc73a33a11eaa147bc814d45df4266fc3119a4067
MD5 7855dfd68196ad787a06834b004a1676
BLAKE2b-256 b722ef1fd26c26de76b76a5bcfd8b2ed1f7ba150af042949ec3f940aec4538d7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page