The Edge Impulse API exposes programmatic access to most functionality in the studio and it is particularly useful when it comes to automating tasks. You can use the API to edit the labels of many samples at once, train models, or create new impulses. In addition, you can subscribe to events, such as when a new file is processed by the ingestion service. An Edge Impulse Python API bindings is also available as the edgeimpulse-api pip package.
See the following examples:
The Python SDK is built on top of the Edge Impulse Python API bindings, which is known as the edgeimpulse-api package. These are Python wrappers for all of the web API calls that you can use to interact with Edge Impulse projects programmatically (i.e. without needing to use the Studio graphical interface).
The API reference guide for using the Python API bindings can be found here.
The following is a quick demonstration to show you how to use the Python API Bindings. To start, install the edgeimpulse_api package
Note that if you install the edgeimpulse Python SDK package, the edgeimpulse-api package will be installed as a dependency.
Now, you can use the edgeimpulse-api package independently to control your data collection, model training, and deployment at a lower level. Create a project in the Edge Impulse Studio, navigate to Dashboard and click on the Keys tab to view your API keys. Double-click on the API key to highlight it, right-click, and select Copy.
Change the api_key
in the script below to match your API key.
When you run the code above, it will print out information about the project associated with the API key supplied. You should see something like the following:
You can use this information to gain insights into your projects, and you can build these insights into your MLOps pipelines. Additionally, this should give you a start on using the Edge Impulse Python API to construct your own pipelines for data collection, training, deployment, and so on.
This guide provides a quick walk-through on how to upload and update time-series data with multiple labels using the Edge Impulse API.
API Key - Obtain from your project settings on Edge Impulse.
Example Github repository - Clone the following repository, it contains the scripts and the example files:
Export your API key to use in the upload scripts:
Data File: JSON formatted time-series data. See the Data acquisition format speicification
structured_labels.labels
File: JSON with structured labels. See the specification format
Use the upload.sh
script to send your data and labels to Edge Impulse:
To update a sample, run update-sample.sh
with the required project and sample IDs:
We hope this tutorial has helped you to understand how to ingest multi-label data samples to your Edge Impulse project. If you have any questions, please reach out to us on our forum.
The Edge Impulse API gives programmatic access to all features in the studio, and many tasks that might normally have to be performed manually can thus be automated. In this tutorial you'll create a job that deploys your model (as a ZIP file), you monitor the job status, and then finally download the deployed model. The tutorial uses Python, but you can use any environment capable of scripting HTTP requests.
To run this script you'll need:
A recent version of Python 3.
The requests
module:
Your project ID (can be found on Dashboard in the Edge Impulse Studio).
An API Key (under Dashboard > Keys).
Then, create the following script build-model.py:
When you now run python3 download-model.py
you'll see something like:
The EON Tuner is Edge Impulse's AutoML (automated machine learning) tool to help you find and select the best embedded machine learning model for your application within the constraints of your target device.
This notebook will show you how to configure and run the EON Tuner programmatically using the Edge Impulse API!
This section will set up your environment and API credentials so that you can start making calls to the Edge Impulse API from this notebook. Run this block only once per runtime session, or every time you:
Open the notebook on your browser or IDE to start working on it, or
restart the runtime, or
change the project you are working on
API documentation is available at https://docs.edgeimpulse.com/reference/edge-impulse-api
PROJECT_ID
You will need to enter the correct PROJECT_ID
for the project you want to work with, in the code in section 1.3 below. The project ID can be obtained from your Edge Impulse Project's Dashboard under the Project Info section.
The block below will prompt you for your project's API Key. You can obtain this key from your Project's Dashboard, by selecting the Keys tab from the top navigation bar.
Run the block below and enter your API key when prompted. Then continue to the next section.
You can use the code in section 2.2 below to programmatically update the configuration of the EON Tuner.
In basic mode (the default) you will be able to modify the datasetCategory
, targetLatency
and targetDevice
. For additional control, ask your User Success or Solutions Engineer to enable the EON Tuner advanced mode for you.
Run the cell below to start spinning up EON Tuner optimization jobs. If your project is already running an EON Tuner optimization, go instead to section 2.4 to track the job's progress.
Run the cell below to track the progress of your EON Tuner job. You can safely stop and restart the cell at any time since this will not affect the running EON Tuner jobs.
Use the cell below to retrieve the EON Tuner optimization results and save them to the trials
variable.
Your project API key can be used to enable programmatic access to Edge Impulse. You can create and/or obtain a key from your project's Dashboard, under the Keys
tab. API keys are long strings, and start with ei_
:
Open a terminal and run the Edge Impulse daemon. The daemon is the service that connects your hardware with any Edge Impulse project:
Copy your project's ID from the project's Dashboard under the Project Info
section:
Replace the PROJECT_ID
below with the ID of your project you selected and enter your API key when prompted: