Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Download and extract a dataset from the Edge Impulse CDN for tutorials, and quick prototyping.
Saves the dataset in the datasets/<name>
folder. Use list_datasets
to show available datasets for download.
Parameters
name: str
force_redownload: bool = False
overwrite_existing: bool = False
show_progress: bool = False
List the available datasets on the Edge Impulse CDN.
Return
List[dict]
Load the timeseries dataset.
Common base class for all non-exit exceptions.
Parameters
message
Bases
builtins.Exception
builtins.BaseException
Subclasses
edgeimpulse.exceptions.InvalidAuthTypeException
edgeimpulse.exceptions.InvalidDeployParameterException
edgeimpulse.exceptions.InvalidDeviceException
edgeimpulse.exceptions.InvalidEngineException
edgeimpulse.exceptions.InvalidModelException
edgeimpulse.exceptions.InvalidTargetException
edgeimpulse.exceptions.MissingApiIngestionEndpointException
edgeimpulse.exceptions.MissingApiKeyException
edgeimpulse.exceptions.TimeoutException
edgeimpulse.exceptions.UnsuccessfulRequestException
edgeimpulse.exceptions.UnsupportedSampleType
Common base class for all non-exit exceptions.
Parameters
message
Bases
edgeimpulse.exceptions.EdgeImpulseException
builtins.Exception
builtins.BaseException
Exception raised when an invalid parameter is passed.
Parameters
msg: str
Bases
edgeimpulse.exceptions.EdgeImpulseException
builtins.Exception
builtins.BaseException
Exception raised when an invalid device is passed.
Parameters
device: str
profile_devices: List[str]
Bases
edgeimpulse.exceptions.EdgeImpulseException
builtins.Exception
builtins.BaseException
Exception raised when an invalid engine is passed.
For a list of valid engines use edgeimpulse.model.list_engines()
.
Parameters
validation_error
Bases
edgeimpulse.exceptions.EdgeImpulseException
builtins.Exception
builtins.BaseException
Common base class for all non-exit exceptions.
Parameters
msg: str
Bases
edgeimpulse.exceptions.EdgeImpulseException
builtins.Exception
builtins.BaseException
Exception raised when an invalid target is passed.
For a list of valid targets use edgeimpulse.model.list_deployment_targets()
.
Parameters
deploy_target: str
target_names: List[str]
Bases
edgeimpulse.exceptions.EdgeImpulseException
builtins.Exception
builtins.BaseException
Common base class for all non-exit exceptions.
Bases
edgeimpulse.exceptions.EdgeImpulseException
builtins.Exception
builtins.BaseException
Common base class for all non-exit exceptions.
Bases
edgeimpulse.exceptions.EdgeImpulseException
builtins.Exception
builtins.BaseException
Exception raised when a timeout has been reached.
Parameters
msg: str
Bases
edgeimpulse.exceptions.EdgeImpulseException
builtins.Exception
builtins.BaseException
Common base class for all non-exit exceptions.
Parameters
error: Optional[str]
Bases
edgeimpulse.exceptions.EdgeImpulseException
builtins.Exception
builtins.BaseException
Exception raised when attempting to upload or download a data type that is not supported by Edge Impulse.
Parameters
error: Optional[str]
Bases
edgeimpulse.exceptions.EdgeImpulseException
builtins.Exception
builtins.BaseException
Initialize the Edge Impulse Api.
Parameters
host: Optional[str] = None
key: Optional[str] = None
key_type: str = 'api'
Instance variables
classify: edgeimpulse_api.api.classify_api.ClassifyApi
Classify samples in your project.
client: edgeimpulse_api.api_client.ApiClient
The client used for initializing the apis, use set_client
to update the client.
deployment: edgeimpulse_api.api.deployment_api.DeploymentApi
Work with your model deployment targets.
devices: edgeimpulse_api.api.devices_api.DevicesApi
Work with devices in your project.
dsp: edgeimpulse_api.api.dsp_api.DSPApi
Work with (DSP) digital signal processing and feature extraction blocks in your project.
export: edgeimpulse_api.api.export_api.ExportApi
Export your project.
host: Optional[str]
Edge Impulse studio host (defaults to production).
impulse: edgeimpulse_api.api.impulse_api.ImpulseApi
Work and manage your Impulse (on-device feature extraction and classification pipeline).
jobs: edgeimpulse_api.api.jobs_api.JobsApi
Start and manage long running jobs.
learn: edgeimpulse_api.api.learn_api.LearnApi
Work with keras and pretrained models.
login: edgeimpulse_api.api.login_api.LoginApi
Login and authenticate.
optimization: edgeimpulse_api.api.optimization_api.OptimizationApi
Optimize and find a better model with the EON tuner.
organization_blocks: edgeimpulse_api.api.organization_blocks_api.OrganizationBlocksApi
Work with organization blocks.
organization_create_project: edgeimpulse_api.api.organization_create_project_api.OrganizationCreateProjectApi
Automate project creation for organizations.
organization_data: edgeimpulse_api.api.organization_data_api.OrganizationDataApi
Work with organization data.
organization_data_campaigns: edgeimpulse_api.api.organization_data_campaigns_api.OrganizationDataCampaignsApi
Work with organization data campaigns.
organization_jobs: edgeimpulse_api.api.organization_jobs_api.OrganizationJobsApi
Start and manage organization jobs.
organization_pipelines: edgeimpulse_api.api.organization_pipelines_api.OrganizationPipelinesApi
Work with organization pipelines.
organization_portals: edgeimpulse_api.api.organization_portals_api.OrganizationPortalsApi
Create and manage organization portals.
organizations: edgeimpulse_api.api.organizations_api.OrganizationsApi
Work with your organizations.
performance_calibration: edgeimpulse_api.api.performance_calibration_api.PerformanceCalibrationApi
Calibrate your model performance with real world data.
projects: edgeimpulse_api.api.projects_api.ProjectsApi
Create and manage your projects.
raw_data: edgeimpulse_api.api.raw_data_api.RawDataApi
Work with your project data.
upload_portal: edgeimpulse_api.api.upload_portal_api.UploadPortalApi
Create and manage data upload portals.
user: edgeimpulse_api.api.user_api.UserApi
Manage user activation, creation and updates.
Authenticate against Edge Impulse.
Parameters
self
key: str
key_type: str = 'api'
host: Optional[str] = None
Return
None
Get the default project ID from the provided API key.
Returns: int: The project associated with the api key.
Parameters
self
Return
int
Runs an organization job until completion.
Parameters
self
organization_id: int
job_id: int
data_cb=None
client=None
timeout_sec: Optional[int] = None
Return
None
Runs a project job until completion.
Parameters
self
job_id: int
data_cb=None
client=None
project_id: Optional[int] = None
timeout_sec: Optional[int] = None
Return
None
Set the API client and initialize the APIs wit that client.
Parameters
self
client: edgeimpulse_api.api_client.ApiClient
Return
None
Wrapper class for the Edge Impulse data acquisition format.
See here for more information: https://docs.edgeimpulse.com/reference/data-acquisition-format.
Parameters
protected: edgeimpulse.data.sample_type.Protected
payload: edgeimpulse.data.sample_type.Payload
signature: Optional[str] = None
Class variables
payload: edgeimpulse.data.sample_type.Payload
protected: edgeimpulse.data.sample_type.Protected
signature: Optional[str]
Wrapper class for the sensor data.
Information about the data acquisition format can be found here: https://docs.edgeimpulse.com/reference/data-acquisition-format.
Parameters
device_type: str
sensors: List[edgeimpulse.data.sample_type.Sensor]
values: List[List[float]]
interval_ms: Optional[int] = 0
device_name: Optional[str] = None
Class variables
device_name: Optional[str]
device_type: str
interval_ms: Optional[int]
sensors: List[edgeimpulse.data.sample_type.Sensor]
values: List[List[float]]
Wrapper class for information about the signature format.
More information can be found here: https://docs.edgeimpulse.com/reference/data-acquisition-format.
Parameters
ver: str = 'v1'
alg: Literal['HS256', 'none'] = 'none'
iat: Optional[int] = None
Class variables
alg: Literal['HS256', 'none']
iat: Optional[int]
ver: str
Wrapper class for sample data, labels, and associated metadata.
Sample data should be contained in a file or file-like object, for example, as the return from open(..., "rb")
. The upload_samples()
function expects Sample objects as input.
Parameters
data: Union[io.BufferedIOBase, _io.StringIO, str]
filename: Optional[str] = None
category: Optional[Literal['training', 'testing', 'anomaly', 'split']] = 'split'
label: Optional[str] = None
bounding_boxes: Optional[List[dict]] = None
metadata: Optional[dict] = None
sample_id: Optional[int] = None
structured_labels: Optional[List[dict]] = None
Class variables
bounding_boxes: Optional[List[dict]]
category: Optional[Literal['training', 'testing', 'anomaly', 'split']]
data: Union[io.BufferedIOBase, _io.StringIO, str]
filename: Optional[str]
label: Optional[str]
metadata: Optional[dict]
sample_id: Optional[int]
structured_labels: Optional[List[dict]]
Wrapper for the response from the Edge Impulse ingestion service when retrieving sample information.
Parameters
sample_id: Optional[int] = None
filename: Optional[str] = None
category: Optional[str] = None
label: Optional[str] = None
Class variables
category: Optional[str]
filename: Optional[str]
label: Optional[str]
sample_id: Optional[int]
Wrapper for the response from the Edge Impulse ingestion service when uploading a sample along with the sample that was uploaded.
Parameters
sample: edgeimpulse.data.sample_type.Sample
response: dict
Represents a sensor in the Edge Impulse data acquisition format.
Note: The units must comply with the SenML units list: https://www.iana.org/assignments/senml/senml.xhtml
Parameters
name: str
units: Literal['m', 'kg', 'g', 's', 'A', 'K', 'cd', 'mol', 'Hz', 'rad', 'sr', 'N', 'Pa', 'J', 'W', 'C', 'V', 'F', 'Ohm', 'S', 'Wb', 'T', 'H', 'Cel', 'lm', 'lx', 'Bq', 'Gy', 'Sv', 'kat', 'm2', 'm3', 'l', 'm/s', 'm/s2', 'm3/s', 'l/s', 'W/m2', 'cd/m2', 'bit', 'bit/s', 'lat', 'lon', 'pH', 'dB', 'dBW', 'Bspl', 'count', '/', '%', '%RH', '%EL', 'EL', '1/s', '1/min', 'beat/min', 'beats', 'S/m', 'B', 'VA', 'VAs', 'var', 'vars', 'J/m', 'kg/m3', 'deg', 'NTU', 'rgba'] = 'm/s'
Class variables
name: str
units: Literal['m', 'kg', 'g', 's', 'A', 'K', 'cd', 'mol', 'Hz', 'rad', 'sr', 'N', 'Pa', 'J', 'W', 'C', 'V', 'F', 'Ohm', 'S', 'Wb', 'T', 'H', 'Cel', 'lm', 'lx', 'Bq', 'Gy', 'Sv', 'kat', 'm2', 'm3', 'l', 'm/s', 'm/s2', 'm3/s', 'l/s', 'W/m2', 'cd/m2', 'bit', 'bit/s', 'lat', 'lon', 'pH', 'dB', 'dBW', 'Bspl', 'count', '/', '%', '%RH', '%EL', 'EL', '1/s', '1/min', 'beat/min', 'beats', 'S/m', 'B', 'VA', 'VAs', 'var', 'vars', 'J/m', 'kg/m3', 'deg', 'NTU', 'rgba']
Response from the Edge Impulse server when uploading multiple samples.
Parameters
successes: List[edgeimpulse.data.sample_type.SampleIngestionResponse]
fails: List[edgeimpulse.data.sample_type.SampleIngestionResponse]
Add new responses to the existing responses.
Parameters
self
successes: List[edgeimpulse.data.sample_type.SampleIngestionResponse]
fails: List[edgeimpulse.data.sample_type.SampleIngestionResponse]
Wrapper class for sample data, labels, and associated metadata.
Sample data should be contained in a file or file-like object, for example, as the return from open(..., "rb")
. The upload_samples()
function expects Sample objects as input.
Parameters
data: Union[io.BufferedIOBase, _io.StringIO, str]
filename: Optional[str] = None
category: Optional[Literal['training', 'testing', 'anomaly', 'split']] = 'split'
label: Optional[str] = None
bounding_boxes: Optional[List[dict]] = None
metadata: Optional[dict] = None
sample_id: Optional[int] = None
structured_labels: Optional[List[dict]] = None
Class variables
bounding_boxes: Optional[List[dict]]
category: Optional[Literal['training', 'testing', 'anomaly', 'split']]
data: Union[io.BufferedIOBase, _io.StringIO, str]
filename: Optional[str]
label: Optional[str]
metadata: Optional[dict]
sample_id: Optional[int]
structured_labels: Optional[List[dict]]
Delete all samples in a given category.
If category is set to None
, all samples in the project are deleted.
Parameters
category: Optional[str] = None
api_key: Optional[str] = None
timeout_sec: Optional[float] = None
Return
Optional[edgeimpulse_api.models.generic_api_response.GenericApiResponse]
Delete a particular sample from a project given the sample ID.
Parameters
sample_id: int
api_key: Optional[str] = None
timeout_sec: Optional[float] = None
Return
Optional[edgeimpulse_api.models.generic_api_response.GenericApiResponse]
Delete any samples from an Edge Impulse project that match the given filename.
Note: the filename
argument must not include the original extension. For example, if you uploaded a file named my-image.01.png
, you must provide the filename
as my-image.01
.
Parameters
filename: str
category: Optional[str] = None
api_key: Optional[str] = None
timeout_sec: Optional[float] = None
Return
Tuple[Optional[Any], ...]
Download samples by their associated IDs from an Edge Impulse project.
Downloaded sample data is returned as a DownloadSample
object, which contains the raw data in a BytesIO object along with associated metadata.
Important! All time series data is returned as a JSON file (in BytesIO format) with a timestamp column. This includes files originally uploaded as CSV, JSON, and CBOR. Edge Impulse Studio removes the timestamp column from any uploaded CSV files and computes an estimated sample rate. The timestamps are computed based on the sample rate, will always start at 0, and will be in milliseconds. These timestamps may not be the same as the original timestamps in the uploaded file.
Parameters
sample_ids: Union[int, List[int]]
api_key: Optional[str] = None
timeout_sec: Optional[float] = None
max_workers: Optional[int] = None
show_progress: Optional[bool] = False
pool_maxsize: Optional[int] = 20
pool_connections: Optional[int] = 20
Return
List[edgeimpulse.data.sample_type.Sample]
Given an ID for a sample in a project, return the filename associated with that sample.
Note that while multiple samples can have the same filename, each sample has a unique sample ID that is provided by Studio when the sample is uploaded.
Parameters
sample_id: int
api_key: Optional[str] = None
timeout_sec: Optional[float] = None
Return
Optional[str]
Get the sample IDs and filenames for all samples in a project, filtered by category, labels, or filename.
Note that filenames are given by the root of the filename when uploaded. For example, if you upload my-image.01.png
, it will be stored in your project with a hash such as my-image.01.png.4f262n1b.json
. To find the ID(s) that match this sample, you must provide the argument filename=my-image.01
. Notice the lack of extension and hash.
Because of the potential for multiple samples (i.e., different sample IDs) with the same filename, we recommend providing unique filenames for your samples when uploading.
Parameters
filename: Optional[str] = None
category: Optional[str] = None
labels: Optional[str] = None
api_key: Optional[str] = None
num_workers: Optional[int] = 4
timeout_sec: Optional[float] = None
Return
List[edgeimpulse.data.sample_type.SampleInfo]
Extract label and category information from the filename and assigns them to the sample object.
Files should look like this my-dataset/training/wave.1.cbor
where wave
is the label and training
is the category. It checks if there is training
, testing
or anomaly
in the filename to determine the sample category.
Parameters
sample: edgeimpulse.data.sample_type.Sample
file: str
Return
None
Convert numpy values to a sample that can be uploaded to Edge Impulse.
Parameters
values
sensors: List[edgeimpulse.data.sample_type.Sensor]
sample_rate_ms: int
Return
edgeimpulse.data.sample_type.Sample
Convert a dataframe to a single sample. Can handle both timeseries and non-timeseries data.
In order to be inferred as timeseries it must have:
More than one row
A sample rate or an index from which the sample rate can be inferred
Therefore must be monotonically increasing
And int or a date
Parameters
df
sample_rate_ms: Optional[int] = None
label: Optional[str] = None
filename: Optional[str] = None
axis_columns: Optional[List[str]] = None
metadata: Optional[dict] = None
label_col: Optional[str] = None
category: Literal['training', 'testing', 'split'] = 'split'
Return
edgeimpulse.data.sample_type.Sample
Download samples by their associated IDs from an Edge Impulse project.
Parameters
sample_ids: Union[int, Sequence[int]]
api_key: Optional[str] = None
timeout_sec: Optional[float] = None
max_workers: Optional[int] = None
show_progress: Optional[bool] = False
pool_maxsize: Optional[int] = 20
pool_connections: Optional[int] = 20
Return
Generator[edgeimpulse.data.sample_type.Sample, None, None]
Upload a directory of files to Edge Impulse.
Tries to autodetect whether it's an Edge Impulse exported dataset, or a standard directory. The files can be in CBOR, JSON, image, or WAV file formats. You can read more about the different file formats accepted by the Edge Impulse ingestion service here:
https://docs.edgeimpulse.com/reference/ingestion-api
Parameters
directory: str
category: Optional[str] = None
label: Optional[str] = None
metadata: Optional[dict] = None
transform: Optional[<built-in function callable>] = None
allow_duplicates: Optional[bool] = False
show_progress: Optional[bool] = False
batch_size: Optional[int] = 1024
Return
edgeimpulse.data.sample_type.UploadSamplesResponse
Upload samples from a downloaded Edge Impulse dataset and preserve the info.labels
information.
Use this when you've exported your data in the studio, via the export
functionality.
Parameters
directory: str
transform: Optional[<built-in function callable>] = None
allow_duplicates: Optional[bool] = False
show_progress: Optional[bool] = False
batch_size: Optional[int] = 1024
Return
edgeimpulse.data.sample_type.UploadSamplesResponse
Upload numpy arrays as timeseries using the Edge Impulse data acquisition format.
Parameters
data
labels: List[str]
sensors: List[edgeimpulse.data.sample_type.Sensor]
sample_rate_ms: int
metadata: Optional[dict] = None
category: Literal['training', 'testing', 'split', 'anomaly'] = 'split'
Return
edgeimpulse.data.sample_type.UploadSamplesResponse
Upload non-timeseries data to Edge Impulse where each dataframe row becomes a sample.
Parameters
df
feature_cols: List[str]
label_col: Optional[str] = None
category_col: Optional[str] = None
metadata_cols: Optional[List[str]] = None
Return
edgeimpulse.data.sample_type.UploadSamplesResponse
Upload a dataframe to Edge Impulse where each column represents a value in the timeseries data and the rows become the individual samples.
Parameters
df
sample_rate_ms: int
data_col_start: Optional[int] = None
label_col: Optional[str] = None
category_col: Optional[str] = None
metadata_cols: Optional[List[str]] = None
data_col_length: Optional[int] = None
data_axis_cols: Optional[List[str]] = None
Return
edgeimpulse.data.sample_type.UploadSamplesResponse
Upload a dataframe where the rows contain multiple samples and timeseries data for those samples.
It uses a group_by
in order to detect what timeseries value belongs to which sample.
Parameters
df
timestamp_col: str
group_by: str
feature_cols: List[str]
label_col: Optional[str] = None
category_col: Optional[str] = None
metadata_cols: Optional[List[str]] = None
Return
edgeimpulse.data.sample_type.UploadSamplesResponse
Upload a single dataframe sample.
Upload a single dataframe sample to Edge Impulse.
Parameters
df
label: Optional[str] = None
sample_rate_ms: Optional[int] = None
filename: Optional[str] = None
axis_columns: Optional[List[str]] = None
metadata: Optional[dict] = None
label_col: Optional[str] = None
category: Literal['training', 'testing', 'split'] = 'split'
Return
edgeimpulse.data.sample_type.UploadSamplesResponse
Upload a directory of files to Edge Impulse.
The samples can be in CBOR, JSON, image, or WAV file formats.
Parameters
directory: str
category: Optional[str] = None
label: Optional[str] = None
metadata: Optional[dict] = None
transform: Optional[<built-in function callable>] = None
allow_duplicates: Optional[bool] = False
show_progress: Optional[bool] = False
batch_size: Optional[int] = 1024
Return
edgeimpulse.data.sample_type.UploadSamplesResponse
Upload one or more samples to an Edge Impulse project using the ingestion service.
Each sample must be wrapped in a Sample
object, which contains metadata about that sample. Give this function a single Sample
or a List of Sample
objects to upload to your project. The data
field of the Sample
must be a raw binary stream, such as a BufferedIOBase object (which you can create with the open(..., "rb")
function).
Parameters
samples: Union[edgeimpulse.data.sample_type.Sample, List[edgeimpulse.data.sample_type.Sample]]
allow_duplicates: Optional[bool] = False
api_key: Optional[str] = None
timeout_sec: Optional[float] = None
max_workers: Optional[int] = None
show_progress: Optional[bool] = False
pool_maxsize: Optional[int] = 20
pool_connections: Optional[int] = 20
Return
edgeimpulse.data.sample_type.UploadSamplesResponse
Wrapper class for sample data, labels, and associated metadata.
Sample data should be contained in a file or file-like object, for example, as the return from open(..., "rb")
. The upload_samples()
function expects Sample objects as input.
Parameters
data: Union[io.BufferedIOBase, _io.StringIO, str]
filename: Optional[str] = None
category: Optional[Literal['training', 'testing', 'anomaly', 'split']] = 'split'
label: Optional[str] = None
bounding_boxes: Optional[List[dict]] = None
metadata: Optional[dict] = None
sample_id: Optional[int] = None
structured_labels: Optional[List[dict]] = None
Class variables
bounding_boxes: Optional[List[dict]]
category: Optional[Literal['training', 'testing', 'anomaly', 'split']]
data: Union[io.BufferedIOBase, _io.StringIO, str]
filename: Optional[str]
label: Optional[str]
metadata: Optional[dict]
sample_id: Optional[int]
structured_labels: Optional[List[dict]]
Delete all samples in a given category.
If category is set to None
, all samples in the project are deleted.
Parameters
category: Optional[str] = None
api_key: Optional[str] = None
timeout_sec: Optional[float] = None
Return
Optional[edgeimpulse_api.models.generic_api_response.GenericApiResponse]
Delete a particular sample from a project given the sample ID.
Parameters
sample_id: int
api_key: Optional[str] = None
timeout_sec: Optional[float] = None
Return
Optional[edgeimpulse_api.models.generic_api_response.GenericApiResponse]
Delete any samples from an Edge Impulse project that match the given filename.
Note: the filename
argument must not include the original extension. For example, if you uploaded a file named my-image.01.png
, you must provide the filename
as my-image.01
.
Parameters
filename: str
category: Optional[str] = None
api_key: Optional[str] = None
timeout_sec: Optional[float] = None
Return
Tuple[Optional[Any], ...]
Download samples by their associated IDs from an Edge Impulse project.
Downloaded sample data is returned as a DownloadSample
object, which contains the raw data in a BytesIO object along with associated metadata.
Important! All time series data is returned as a JSON file (in BytesIO format) with a timestamp column. This includes files originally uploaded as CSV, JSON, and CBOR. Edge Impulse Studio removes the timestamp column from any uploaded CSV files and computes an estimated sample rate. The timestamps are computed based on the sample rate, will always start at 0, and will be in milliseconds. These timestamps may not be the same as the original timestamps in the uploaded file.
Parameters
sample_ids: Union[int, List[int]]
api_key: Optional[str] = None
timeout_sec: Optional[float] = None
max_workers: Optional[int] = None
show_progress: Optional[bool] = False
pool_maxsize: Optional[int] = 20
pool_connections: Optional[int] = 20
Return
List[edgeimpulse.data.sample_type.Sample]
Given an ID for a sample in a project, return the filename associated with that sample.
Note that while multiple samples can have the same filename, each sample has a unique sample ID that is provided by Studio when the sample is uploaded.
Parameters
sample_id: int
api_key: Optional[str] = None
timeout_sec: Optional[float] = None
Return
Optional[str]
Get the sample IDs and filenames for all samples in a project, filtered by category, labels, or filename.
Note that filenames are given by the root of the filename when uploaded. For example, if you upload my-image.01.png
, it will be stored in your project with a hash such as my-image.01.png.4f262n1b.json
. To find the ID(s) that match this sample, you must provide the argument filename=my-image.01
. Notice the lack of extension and hash.
Because of the potential for multiple samples (i.e., different sample IDs) with the same filename, we recommend providing unique filenames for your samples when uploading.
Parameters
filename: Optional[str] = None
category: Optional[str] = None
labels: Optional[str] = None
api_key: Optional[str] = None
num_workers: Optional[int] = 4
timeout_sec: Optional[float] = None
Return
List[edgeimpulse.data.sample_type.SampleInfo]
Extract label and category information from the filename and assigns them to the sample object.
Files should look like this my-dataset/training/wave.1.cbor
where wave
is the label and training
is the category. It checks if there is training
, testing
or anomaly
in the filename to determine the sample category.
Parameters
sample: edgeimpulse.data.sample_type.Sample
file: str
Return
None
Convert numpy values to a sample that can be uploaded to Edge Impulse.
Parameters
values
sensors: List[edgeimpulse.data.sample_type.Sensor]
sample_rate_ms: int
Return
edgeimpulse.data.sample_type.Sample
Convert a dataframe to a single sample. Can handle both timeseries and non-timeseries data.
In order to be inferred as timeseries it must have:
More than one row
A sample rate or an index from which the sample rate can be inferred
Therefore must be monotonically increasing
And int or a date
Parameters
df
sample_rate_ms: Optional[int] = None
label: Optional[str] = None
filename: Optional[str] = None
axis_columns: Optional[List[str]] = None
metadata: Optional[dict] = None
label_col: Optional[str] = None
category: Literal['training', 'testing', 'split'] = 'split'
Return
edgeimpulse.data.sample_type.Sample
Upload a directory of files to Edge Impulse.
Tries to autodetect whether it's an Edge Impulse exported dataset, or a standard directory. The files can be in CBOR, JSON, image, or WAV file formats. You can read more about the different file formats accepted by the Edge Impulse ingestion service here:
https://docs.edgeimpulse.com/reference/ingestion-api
Parameters
directory: str
category: Optional[str] = None
label: Optional[str] = None
metadata: Optional[dict] = None
transform: Optional[<built-in function callable>] = None
allow_duplicates: Optional[bool] = False
show_progress: Optional[bool] = False
batch_size: Optional[int] = 1024
Return
edgeimpulse.data.sample_type.UploadSamplesResponse
Upload samples from a downloaded Edge Impulse dataset and preserve the info.labels
information.
Use this when you've exported your data in the studio, via the export
functionality.
Parameters
directory: str
transform: Optional[<built-in function callable>] = None
allow_duplicates: Optional[bool] = False
show_progress: Optional[bool] = False
batch_size: Optional[int] = 1024
Return
edgeimpulse.data.sample_type.UploadSamplesResponse
Upload numpy arrays as timeseries using the Edge Impulse data acquisition format.
Parameters
data
labels: List[str]
sensors: List[edgeimpulse.data.sample_type.Sensor]
sample_rate_ms: int
metadata: Optional[dict] = None
category: Literal['training', 'testing', 'split', 'anomaly'] = 'split'
Return
edgeimpulse.data.sample_type.UploadSamplesResponse
Upload non-timeseries data to Edge Impulse where each dataframe row becomes a sample.
Parameters
df
feature_cols: List[str]
label_col: Optional[str] = None
category_col: Optional[str] = None
metadata_cols: Optional[List[str]] = None
Return
edgeimpulse.data.sample_type.UploadSamplesResponse
Upload a dataframe to Edge Impulse where each column represents a value in the timeseries data and the rows become the individual samples.
Parameters
df
sample_rate_ms: int
data_col_start: Optional[int] = None
label_col: Optional[str] = None
category_col: Optional[str] = None
metadata_cols: Optional[List[str]] = None
data_col_length: Optional[int] = None
data_axis_cols: Optional[List[str]] = None
Return
edgeimpulse.data.sample_type.UploadSamplesResponse
Upload a dataframe where the rows contain multiple samples and timeseries data for those samples.
It uses a group_by
in order to detect what timeseries value belongs to which sample.
Parameters
df
timestamp_col: str
group_by: str
feature_cols: List[str]
label_col: Optional[str] = None
category_col: Optional[str] = None
metadata_cols: Optional[List[str]] = None
Return
edgeimpulse.data.sample_type.UploadSamplesResponse
Upload a single dataframe sample.
Upload a single dataframe sample to Edge Impulse.
Parameters
df
label: Optional[str] = None
sample_rate_ms: Optional[int] = None
filename: Optional[str] = None
axis_columns: Optional[List[str]] = None
metadata: Optional[dict] = None
label_col: Optional[str] = None
category: Literal['training', 'testing', 'split'] = 'split'
Return
edgeimpulse.data.sample_type.UploadSamplesResponse
Upload a directory of files to Edge Impulse.
The samples can be in CBOR, JSON, image, or WAV file formats.
Parameters
directory: str
category: Optional[str] = None
label: Optional[str] = None
metadata: Optional[dict] = None
transform: Optional[<built-in function callable>] = None
allow_duplicates: Optional[bool] = False
show_progress: Optional[bool] = False
batch_size: Optional[int] = 1024
Return
edgeimpulse.data.sample_type.UploadSamplesResponse
Upload one or more samples to an Edge Impulse project using the ingestion service.
Each sample must be wrapped in a Sample
object, which contains metadata about that sample. Give this function a single Sample
or a List of Sample
objects to upload to your project. The data
field of the Sample
must be a raw binary stream, such as a BufferedIOBase object (which you can create with the open(..., "rb")
function).
Parameters
samples: Union[edgeimpulse.data.sample_type.Sample, List[edgeimpulse.data.sample_type.Sample]]
allow_duplicates: Optional[bool] = False
api_key: Optional[str] = None
timeout_sec: Optional[float] = None
max_workers: Optional[int] = None
show_progress: Optional[bool] = False
pool_maxsize: Optional[int] = 20
pool_connections: Optional[int] = 20
Return
edgeimpulse.data.sample_type.UploadSamplesResponse
Initialize the Edge Impulse Api.
Parameters
host: Optional[str] = None
key: Optional[str] = None
key_type: str = 'api'
Instance variables
classify: edgeimpulse_api.api.classify_api.ClassifyApi
Classify samples in your project.
client: edgeimpulse_api.api_client.ApiClient
The client used for initializing the apis, use set_client
to update the client.
deployment: edgeimpulse_api.api.deployment_api.DeploymentApi
Work with your model deployment targets.
devices: edgeimpulse_api.api.devices_api.DevicesApi
Work with devices in your project.
dsp: edgeimpulse_api.api.dsp_api.DSPApi
Work with (DSP) digital signal processing and feature extraction blocks in your project.
export: edgeimpulse_api.api.export_api.ExportApi
Export your project.
host: Optional[str]
Edge Impulse studio host (defaults to production).
impulse: edgeimpulse_api.api.impulse_api.ImpulseApi
Work and manage your Impulse (on-device feature extraction and classification pipeline).
jobs: edgeimpulse_api.api.jobs_api.JobsApi
Start and manage long running jobs.
learn: edgeimpulse_api.api.learn_api.LearnApi
Work with keras and pretrained models.
login: edgeimpulse_api.api.login_api.LoginApi
Login and authenticate.
optimization: edgeimpulse_api.api.optimization_api.OptimizationApi
Optimize and find a better model with the EON tuner.
organization_blocks: edgeimpulse_api.api.organization_blocks_api.OrganizationBlocksApi
Work with organization blocks.
organization_create_project: edgeimpulse_api.api.organization_create_project_api.OrganizationCreateProjectApi
Automate project creation for organizations.
organization_data: edgeimpulse_api.api.organization_data_api.OrganizationDataApi
Work with organization data.
organization_data_campaigns: edgeimpulse_api.api.organization_data_campaigns_api.OrganizationDataCampaignsApi
Work with organization data campaigns.
organization_jobs: edgeimpulse_api.api.organization_jobs_api.OrganizationJobsApi
Start and manage organization jobs.
organization_pipelines: edgeimpulse_api.api.organization_pipelines_api.OrganizationPipelinesApi
Work with organization pipelines.
organization_portals: edgeimpulse_api.api.organization_portals_api.OrganizationPortalsApi
Create and manage organization portals.
organizations: edgeimpulse_api.api.organizations_api.OrganizationsApi
Work with your organizations.
performance_calibration: edgeimpulse_api.api.performance_calibration_api.PerformanceCalibrationApi
Calibrate your model performance with real world data.
projects: edgeimpulse_api.api.projects_api.ProjectsApi
Create and manage your projects.
raw_data: edgeimpulse_api.api.raw_data_api.RawDataApi
Work with your project data.
upload_portal: edgeimpulse_api.api.upload_portal_api.UploadPortalApi
Create and manage data upload portals.
user: edgeimpulse_api.api.user_api.UserApi
Manage user activation, creation and updates.
Authenticate against Edge Impulse.
Parameters
self
key: str
key_type: str = 'api'
host: Optional[str] = None
Return
None
Get the default project ID from the provided API key.
Returns: int: The project associated with the api key.
Parameters
self
Return
int
Runs an organization job until completion.
Parameters
self
organization_id: int
job_id: int
data_cb=None
client=None
timeout_sec: Optional[int] = None
Return
None
Runs a project job until completion.
Parameters
self
job_id: int
data_cb=None
client=None
project_id: Optional[int] = None
timeout_sec: Optional[int] = None
Return
None
Set the API client and initialize the APIs wit that client.
Parameters
self
client: edgeimpulse_api.api_client.ApiClient
Return
None
Adds labels to a DataFrame based on provided label information.
Parameters
df
labels
label_col_name='label'
Converts JSON CBOR data to a pandas DataFrame.
Parameters
data
ts_col_name=None
Converts a sample to a DataFrame and adds labels if provided.
Parameters
sample
label_col_name: Optional[str] = 'label'
ts_col_name: Optional[str] = None
Fetch samples based on the provided parameters and stream them by their IDs.
Parameters
filename: Optional[str] = None
category: Optional[str] = None
labels: Optional[str] = None
max_workers=None
Generates structured labels from a DataFrame based on transitions in the specified label column.
This function iterates over the rows of a pandas DataFrame and detects changes in the values of a specified label column. It groups consecutive rows with the same label value, and for each group, it returns a dictionary containing the start index, end index, and the label. Optionally, the result can be returned in a dictionary format, compatible with file saving, including the file name.
Parameters
df
label_col='label'
file_name=None
Transform a machine learning model into a library for an edge device.
Transforms a trained model into a library, package, or firmware ready to deploy on an embedded device. Can optionally apply post-training quantization if a representative data sample is uploaded.
Supported model formats:
Keras Model instance <https://www.tensorflow.org/api_docs/python/tf/keras/Model>
_
TensorFlow SavedModel <https://www.tensorflow.org/guide/saved_model>
_ (as path to directory or .zip
file)
ONNX model file <https://learn.microsoft.com/en-us/windows/ai/windows-ml/get-onnx-model>
_ (as path to .onnx
file)
TensorFlow Lite file <https://www.tensorflow.org/lite/guide>
_ (as bytes, or path to any file that is not .zip
or .onnx
)
Representative data for quantization:
Must be a numpy array or .npy
file.
Each element must have the same shape as your model's input.
Must be representative of the range (maximum and minimum) of values in your training data.
Note: the available deployment options will change depending on the values given for model
, model_output_type
, and model_input_type
. For example, the openmv
deployment option is only available if model_input_type
is set to ImageInput
. If you attempt to deploy to an unavailable target, you will receive the error Could not deploy: deploy_target: ...
.
Parameters
model: Union[pathlib.Path, str, bytes, Any]
model_output_type: Union[edgeimpulse.model.output_type.Classification, edgeimpulse.model.output_type.Regression, edgeimpulse.model.output_type.ObjectDetection]
model_input_type: Union[edgeimpulse.model.input_type.ImageInput, edgeimpulse.model.input_type.AudioInput, edgeimpulse.model.input_type.TimeSeriesInput, edgeimpulse.model.input_type.OtherInput, ForwardRef(None)] = None
representative_data_for_quantization: Union[pathlib.Path, str, bytes, Any, ForwardRef(None)] = None
deploy_model_type: Optional[str] = None
engine: str = 'tflite'
deploy_target: str = 'zip'
output_directory: Optional[str] = None
api_key: Optional[str] = None
timeout_sec: Optional[float] = None
Return
_io.BytesIO
List suitable deployment targets for the project associated with configured or provided api key.
Parameters
api_key: Optional[str] = None
Return
List[str]
List all the engines that can be passed to deploy()
's engine
parameter.
Returns: List[str]: List of engines
Return
List[str]
List all the model types that can passed to deploy()
's deploy_model_type
parameter.
Returns: List[str]: List of model types
Return
List[str]
List possible values for the device
field when calling edgeimpulse.model.profile()
.
Parameters
api_key: Optional[str] = None
Return
List[str]
Profile the performance of a trained model on a range of embedded targets, or a specific device.
The response includes estimates of memory usage and latency for the model across a range of targets, including low-end MCU, high-end MCU, high-end MCU with accelerator, microprocessor unit (MPU), and a GPU or neural network accelerator. It will also include details of any conditions that preclude operation on a given type of device.
If you request a specific device
, the results will also include estimates for that specific device. A list of devices can be obtained from edgeimpulse.model.list_profile_devices()
.
You can call .summary()
on the response to obtain a more readable version of the most relevant information.
Parameters
model: Union[pathlib.Path, str, bytes, Any]
device: Optional[str] = None
api_key: Optional[str] = None
timeout_sec: Optional[float] = None
Return
edgeimpulse.model._functions.profile.ProfileResponse
Check for standard errors and raise an exception with the details if found.
Parameters
request
Configure generic api client which the right key.
Parameters
key: str
key_type: Optional[str] = 'api'
host: Optional[str] = 'https://studio.edgeimpulse.com/v1'
Return
edgeimpulse_api.api_client.ApiClient
Connects to the websocket server.
Parameters: token (str): The authentication token. host (str, optional): The hostname. If None, API_ENDPOINT will be used.
Returns: object: Websocket object.
Parameters
token
host: str = None
Return
socketio.client.Client
Derive project id from api_key used to configure generic client.
Parameters
client: edgeimpulse_api.api_client.ApiClient
Return
int
Envode a file as base64.
Parameters
filename: str
Gets a websocket to listen to organization events.
Parameters
client
organization_id: int
host: str = None
Return
socketio.client.Client
Pull a list of profile devices.
Parameters
client: edgeimpulse_api.api_client.ApiClient
project_id: Optional[int] = None
Return
List[str]
Pull a list of deploy targets.
Parameters
client: edgeimpulse_api.api_client.ApiClient
project_id: Optional[int] = None
Return
List[str]
Gets a websocket to listen to project events.
Parameters
client
project_id: int
host: str = None
Return
socketio.client.Client
Get user agent string for API calls so we can track usage.
Parameters
add_platform_info=False
Load tflite model.
Parameters
model: Union[pathlib.Path, str, bytes, Any]
tempdir: str
Return
Tuple[str, str]
Ensure representative data is saved to disk for upload.
Parameters
data: Union[pathlib.Path, str, bytes, Any]
Return
Optional[str]
Check if model is a keras model.
Parameters
model
Check if array is a numpy array.
Parameters
array
Check if given model is an onnx model.
Parameters
model
Check if given path is a numpy file.
Parameters
path
Check if given path is a onnx file.
Parameters
path
Check if directory contains a saved model.
Parameters
model_dir
Check if path is poiting to a zipped model.
Parameters
model
Check if given path is a. string or a Path
.
Parameters
path
Create zip archive from a model path.
Parameters
saved_model_path
Return True if NumPy is installed, otherwise False.
Return
bool
Return True if ONNX is installed, otherwise False.
Return
bool
Return True if pandas is installed, otherwise False.
Return
bool
Poll a specific job within a project until done or timmeout is reached.
Parameters
jobs_client: edgeimpulse_api.api.jobs_api.JobsApi
project_id: int
job_id: int
timeout_sec: Optional[float] = None
Return
edgeimpulse_api.models.get_job_response.GetJobResponse
Runs a project or organization job until completion.
Parameters
ws
job_id: int
data_cb=None
timeout_sec: Optional[int] = None
Runs an organization job until completion.
Parameters
organization_id: int
job_id: int
data_cb=None
client=None
timeout_sec: Optional[int] = None
Return
None
Runs a project job until completion.
Parameters
job_id: int
data_cb=None
client=None
project_id: Optional[int] = None
timeout_sec: Optional[int] = None
Return
None
Save a machine learning model to the specified directory.
Parameters
model: Union[pathlib.Path, str, bytes]
directory: str
Return
str
Save the representive data to a directory.
Parameters
data: Union[pathlib.Path, str, bytes]
directory: str
Return
str
Return True if TensorFlow is installed, otherwise False.
Return
bool
Upload a model and data to Edge Impulse servers.
Parameters
tempdir: str
client: edgeimpulse_api.api_client.ApiClient
project_id: int
model: Union[pathlib.Path, str, bytes, Any]
representative_data: Union[pathlib.Path, str, bytes, Any, ForwardRef(None)] = None
device: Optional[str] = None
timeout_sec: Optional[float] = None
Return
edgeimpulse_api.models.get_job_response.GetJobResponse
Check the current state of the tuner and optionally waits until the tuner has completed.
Parameters
timeout_sec: Optional[int] = None
wait_for_completion: bool = True
Return
edgeimpulse_api.models.optimize_state_response.OptimizeStateResponse
Retrieve the current state of the tuner run.
Returns: OptimizeStateResponse: The OptimizeStateResponse object representing the current Tuner state.
Parameters
tuner_coordinator_job_id: int
Return
edgeimpulse_api.models.optimize_state_response.OptimizeStateResponse
List the tuner runs that have been done in the current project.
Returns: ListTunerRunsResponse: An object containing all the tuner runs
Return
edgeimpulse_api.models.list_tuner_runs_response.ListTunerRunsResponse
Retrieve and print logs for the tuner coordinator job.
Returns: None
Parameters
limit: int = 500
Return
None
Retrieve and print logs for the tuner job.
Returns: None
Parameters
limit: int = 500
Return
None
Replace the current Impulse configuration with one found in a trial fromm the tuner.
Parameters
trial_id: str
timeout_sec: Optional[float] = None
wait_for_completion: Optional[bool] = True
Return
edgeimpulse_api.models.start_job_response.StartJobResponse
Start a tuner job with custom configuration.
Parameters
config: edgeimpulse_api.models.optimize_config.OptimizeConfig
Return
edgeimpulse_api.models.start_job_response.StartJobResponse
Start the EON tuner with default settings. Use start_custom_tuner
to specify config.
Parameters
space: List[edgeimpulse_api.models.tuner_space_impulse.TunerSpaceImpulse]
target_device: str
target_latency: int
tuning_max_trials: Optional[int] = None
name: Optional[str] = None
Return
edgeimpulse_api.models.start_job_response.StartJobResponse
Get a tuner trial report dataframe with model metrics and block configuration.
This method needs pandas to be installed.
Generate a dataframe on the tuner trials including used input, model, learn block configuration and model validation metrics.
Parameters
state: edgeimpulse_api.models.optimize_state_response.OptimizeStateResponse
Build and download an impulse from Edge Impulse.
Build a model and download it from Edge Impulse. The model can be built for a specific target and engine. The model can be saved to a file if output_directory
is provided and the file name will be derived from the deployment target.
Parameters
deploy_model_type: Optional[str] = None
engine: str = 'tflite'
deploy_target: str = 'zip'
output_directory: Optional[str] = None
api_key: Optional[str] = None
timeout_sec: Optional[float] = None
Return
_io.BytesIO
Check the current state of the tuner and optionally waits until the tuner has completed.
Parameters
timeout_sec: Optional[int] = None
wait_for_completion: bool = True
Return
edgeimpulse_api.models.optimize_state_response.OptimizeStateResponse
Retrieve the current state of the tuner run.
Returns: OptimizeStateResponse: The OptimizeStateResponse object representing the current Tuner state.
Parameters
tuner_coordinator_job_id: int
Return
edgeimpulse_api.models.optimize_state_response.OptimizeStateResponse
List the tuner runs that have been done in the current project.
Returns: ListTunerRunsResponse: An object containing all the tuner runs
Return
edgeimpulse_api.models.list_tuner_runs_response.ListTunerRunsResponse
Retrieve and print logs for the tuner coordinator job.
Returns: None
Parameters
limit: int = 500
Return
None
Retrieve and print logs for the tuner job.
Returns: None
Parameters
limit: int = 500
Return
None
Replace the current Impulse configuration with one found in a trial fromm the tuner.
Parameters
trial_id: str
timeout_sec: Optional[float] = None
wait_for_completion: Optional[bool] = True
Return
edgeimpulse_api.models.start_job_response.StartJobResponse
Start a tuner job with custom configuration.
Parameters
config: edgeimpulse_api.models.optimize_config.OptimizeConfig
Return
edgeimpulse_api.models.start_job_response.StartJobResponse
Start the EON tuner with default settings. Use start_custom_tuner
to specify config.
Parameters
space: List[edgeimpulse_api.models.tuner_space_impulse.TunerSpaceImpulse]
target_device: str
target_latency: int
tuning_max_trials: Optional[int] = None
name: Optional[str] = None
Return
edgeimpulse_api.models.start_job_response.StartJobResponse
Get a tuner trial report dataframe with model metrics and block configuration.
This method needs pandas to be installed.
Generate a dataframe on the tuner trials including used input, model, learn block configuration and model validation metrics.
Parameters
state: edgeimpulse_api.models.optimize_state_response.OptimizeStateResponse
Name: edgeimpulse
Summary: Python SDK for Edge Impulse.
Version: 1.0.15
Requires: edgeimpulse-api, python-socketio, requests
License: Apache-2.0