sample_type module#

class edgeimpulse.data.sample_type.DataAcquisition(
protected: Protected,
payload: Payload,
signature: str | None = None,
)[source]#

Bases: object

Wrapper class for the Edge Impulse data acquisition format.

See here for more information: https://docs.edgeimpulse.com/reference/data-acquisition-format.

protected#

Information about the signature format.

Type:

Protected

payload#

Sensor data.

Type:

Payload

signature#

Cryptographic signature of the data. Default is None.

Type:

Optional[str]

payload: Payload#
protected: Protected#
signature: str = None#
class edgeimpulse.data.sample_type.Payload(
device_type: str,
sensors: List[Sensor],
values: List[List[float]],
interval_ms: int | None = 0,
device_name: str | None = None,
)[source]#

Bases: object

Wrapper class for the sensor data.

Information about the data acquisition format can be found here: https://docs.edgeimpulse.com/reference/data-acquisition-format.

device_type#
  • Device type, for example the exact model of the device.

Should be the same for all similar devices. For example “DISCO-L475VG-IOT01A”

Type:

str

sensors#

List of Sensor objects representing the data acquisition sensors, such as “accX”, “accY”, “accZ” for a three-axis accelerometer where the units for each would be “m/s2”.

Type:

List[Sensor]

values[List, int]#

List of lists containing float values representing the data from each of the sensors.

interval_ms#

Interval in milliseconds between data samples. Default is 0.

Type:

Optional[int]

device_name#

Unique identifier for this device. Only set this when the device has a globally unique identifier (e.g. MAC address). If this field is set the device shows up on the ‘Devices’ page in the studio.

Type:

Optional[str]

Example

from edgeimpulse.data.sample_type import Payload, Sensor

payload = Payload(
    device_type="DISCO-L475VG-IOT01A",
    sensors=[
        Sensor(name="accX", units="m/s2"),
        Sensor(name="accY", units="m/s2"),
        Sensor(name="accZ", units="m/s2"),
    ],
    values=[
        [-9.81, 0.03, 1.21],
        [-9.83, 0.04, 1.27],
        [-9.12, 0.03, 1.23],
        [-9.14, 0.01, 1.25]
    ],
    interval_ms=10,
    device_name="ac:87:a3:0a:2d:1b"
)
device_name: str | None = None#
device_type: str#
interval_ms: int | None = 0#
sensors: List[Sensor]#
values: List[List[float]]#
class edgeimpulse.data.sample_type.Protected(
ver: str = 'v1',
alg: Literal['HS256', 'none'] = 'none',
iat: int | None = None,
)[source]#

Bases: object

Wrapper class for information about the signature format.

More information can be found here: https://docs.edgeimpulse.com/reference/data-acquisition-format.

ver#

Version of the signature format. Default is “v1”.

Type:

str

alg#

Algorithm used to generate the signature. Default is “none”.

Type:

str

iat#

Date and time when the file was created in seconds since epoch. Only set this when the device creating the file has an accurate clock. Default is None.

Type:

Optional[int]

Example

from edgeimpulse.data.sample_type import Protected

protected = Protected(
    ver="v1",
    alg="none",
    iat=1609459200
)
alg: Literal['HS256', 'none'] = 'none'#
iat: int | None = None#
ver: str = 'v1'#
class edgeimpulse.data.sample_type.Sample(
data: BufferedIOBase,
filename: str | None = None,
category: Literal['training', 'testing', 'anomaly', 'split'] | None = 'split',
label: str | None = None,
bounding_boxes: Sequence[dict] | None = None,
metadata: dict | None = None,
sample_id: int | None = None,
structured_labels: Sequence[dict] | None = None,
)[source]#

Bases: object

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.

filename#

Name to give the sample when stored in the Edge Impulse project

Type:

str

data#

IO stream of data to be read during the upload process. This can be a BytesIO object, such as the return from open(…, “rb”).

Type:

BufferedIOBase

category#

Which dataset to store your sample. The default, “split,” lets the Edge Impulse server randomly assign the location of your sample based on the project’s split ratio (default 80% training and 20% test).

Type:

Optional[Literal[“training”, “testing”, “anomaly”, “split”]]

label#

The label to assign to your sample for classification and regression tasks.

Type:

Optional[str]

bounding_boxes#

Array of dictionary objects that define the bounding boxes for a given sample (object detection projects only). See our image annotation guide for how to format bounding box dictionaries.

Type:

Optional[dict]

metadata#

Dictionary of optional metadata that you would like to include for your particular sample (example: {“source”: “microphone”, “timestamp”: “120”})

Type:

Optional[dict]

sample_id#

Unique ID of the sample. This is automatically assigned by the Edge Impulse server when the sample is uploaded. You can use this ID to retrieve the sample later. This value is ignored when uploading samples and should not be set by the user.

Type:

Optional[int]

structured_labels#

Array of dictionary objects that define the labels in this sample at various intervals. <https://edge-impulse.gitbook.io/docs/edge-impulse-studio/data-acquisition/multi-label>`_ to read more. Example: [{“label”: “noise”,”startIndex”: 0,”endIndex”: 5000}, {“label”: “water”,”startIndex”: 5000,”endIndex”: 10000}]

Type:

Optional[Sequence[dict]]

bounding_boxes: Sequence[dict] | None = None#
category: Literal['training', 'testing', 'anomaly', 'split'] | None = 'split'#
data: BufferedIOBase#
filename: str | None = None#
label: str | None = None#
metadata: dict | None = None#
sample_id: int | None = None#
structured_labels: Sequence[dict] | None = None#
class edgeimpulse.data.sample_type.SampleInfo(
sample_id: int | None = None,
filename: str | None = None,
category: str | None = None,
label: str | None = None,
)[source]#

Bases: object

Wrapper for the response from the Edge Impulse ingestion service when retrieving sample information.

sample_id#

The sample ID.

Type:

Optional[int]

filename#

The filename of the sample.

Type:

Optional[str]

category#

The category of the sample.

Type:

Optional[str]

label#

The label of the sample.

Type:

Optional[str]

category: str | None = None#
filename: str | None = None#
label: str | None = None#
sample_id: int | None = None#
class edgeimpulse.data.sample_type.SampleIngestionResponse(
sample: Sample,
response: dict,
)[source]#

Bases: object

__repr__() str[source]#

Return a string providing an overview of the response.

Returns:

Response from the server.

Return type:

str

class edgeimpulse.data.sample_type.Sensor(
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',
)[source]#

Bases: object

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

name#

Name of the sensor.

Type:

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”

])

Measurement units of the sensor as defined by https://www.iana.org/assignments/senml/senml.xhtml. Defaults to “m/s”.

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 edgeimpulse.data.sample_type.UploadSamplesResponse(
successes: List[SampleIngestionResponse],
fails: List[SampleIngestionResponse],
)[source]#

Bases: object

__repr__() str[source]#

Return a string providing an overview of the number of successes and fails from the responses.

Returns:

Successful upload along with number of successes and fails.

Return type:

str