Skip to content

Commit

Permalink
SDK release v1.57.9
Browse files Browse the repository at this point in the history
  • Loading branch information
mmajchrzycki committed Sep 5, 2024
1 parent 260787f commit 3efb012
Show file tree
Hide file tree
Showing 9 changed files with 418 additions and 103 deletions.
17 changes: 10 additions & 7 deletions EdgeImpulse.EI-SDK.pdsc
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
<name>EI-SDK</name>
<license>LICENSE-apache-2.0.txt</license>
<description>Edge Impulse SDK</description>
<url>https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.57.1/</url>
<url>https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.57.9/</url>
<supportContact>[email protected]</supportContact>
<repository type="git">https://github.com/edgeimpulse/edge-impulse-sdk-pack.git</repository>
<releases>
<release version="1.57.1" tag="v1.57.1" date="2024-08-23" url="https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.57.1/EdgeImpulse.EI-SDK.1.57.1.pack">
<release version="1.57.9" tag="v1.57.9" date="2024-09-05" url="https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.57.9/EdgeImpulse.EI-SDK.1.57.9.pack">
EI-SDK
</release>
<release version="1.57.1" tag="v1.57.1" date="2024-08-23" url="https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.57.1/EdgeImpulse.EI-SDK.1.57.1.pack">
EI-SDK
</release>
<release version="1.56.9" tag="v1.56.9" date="2024-08-13" url="https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.56.9/EdgeImpulse.EI-SDK.1.56.9.pack">
EI-SDK
</release>
Expand Down Expand Up @@ -98,9 +101,6 @@
</release>
<release version="1.49.27" tag="v1.49.27" date="2024-05-13" url="https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.49.27/EdgeImpulse.EI-SDK.1.49.27.pack">
EI-SDK
</release>
<release version="1.49.23" tag="v1.49.23" date="2024-05-09" url="https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.49.23/EdgeImpulse.EI-SDK.1.49.23.pack">
EI-SDK
</release>
</releases>
<keywords>
Expand Down Expand Up @@ -146,7 +146,7 @@
</packages>
</requirements>
<components>
<component Cclass="EdgeImpulse" Cgroup="SDK" Cversion="1.57.1">
<component Cclass="EdgeImpulse" Cgroup="SDK" Cversion="1.57.9">
<description>Edge Impulse SDK</description>
<!-- short component description -->
<files>
Expand Down Expand Up @@ -372,7 +372,6 @@
<file category="source" name="edgeimpulse/edge-impulse-sdk/porting/sony/debug_log.cpp"/>
<file category="source" name="edgeimpulse/edge-impulse-sdk/porting/ti/ei_classifier_porting.cpp"/>
<file category="source" name="edgeimpulse/edge-impulse-sdk/porting/ti/debug_log.cpp"/>
<file category="header" name="edgeimpulse/edge-impulse-sdk/classifier/ei_performance_calibration.h"/>
<file category="header" name="edgeimpulse/edge-impulse-sdk/classifier/ei_aligned_malloc.h"/>
<file category="header" name="edgeimpulse/edge-impulse-sdk/classifier/ei_run_dsp.h"/>
<file category="header" name="edgeimpulse/edge-impulse-sdk/classifier/ei_nms.h"/>
Expand Down Expand Up @@ -401,6 +400,10 @@
<file category="header" name="edgeimpulse/edge-impulse-sdk/classifier/inferencing_engines/tensaiflow.h"/>
<file category="header" name="edgeimpulse/edge-impulse-sdk/classifier/inferencing_engines/memryx.h"/>
<file category="header" name="edgeimpulse/edge-impulse-sdk/classifier/inferencing_engines/engines.h"/>
<file category="header" name="edgeimpulse/edge-impulse-sdk/classifier/postprocessing/ei_performance_calibration.h"/>
<file category="header" name="edgeimpulse/edge-impulse-sdk/classifier/postprocessing/ei_postprocessing_types.h"/>
<file category="header" name="edgeimpulse/edge-impulse-sdk/classifier/postprocessing/ei_postprocessing.h"/>
<file category="header" name="edgeimpulse/edge-impulse-sdk/classifier/postprocessing/ei_object_counting.h"/>
<file category="header" name="edgeimpulse/edge-impulse-sdk/third_party/ruy/ruy/profiler/instrumentation.h"/>
<file category="header" name="edgeimpulse/edge-impulse-sdk/third_party/gemmlowp/internal/detect_platform.h"/>
<file category="header" name="edgeimpulse/edge-impulse-sdk/third_party/gemmlowp/fixedpoint/fixedpoint_neon.h"/>
Expand Down
4 changes: 2 additions & 2 deletions EdgeImpulse.pidx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<index schemaVersion="1.0.0" xs:noNamespaceSchemaLocation="PackIndex.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance">
<vendor>EdgeImpulse</vendor>
<url>https://raw.githubusercontent.com/edgeimpulse/edge-impulse-sdk-pack/main/</url>
<timestamp>2024-08-23 13:47:11</timestamp>
<timestamp>2024-09-05 09:16:54</timestamp>
<pindex>
<pdsc url="https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.57.1/" vendor="EdgeImpulse" name="EI-SDK" version="1.57.1"/>
<pdsc url="https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.57.9/" vendor="EdgeImpulse" name="EI-SDK" version="1.57.9"/>
</pindex>
</index>
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ typedef struct {
*/
ei_impulse_visual_ad_result_t visual_ad_result;
#endif // EI_CLASSIFIER_HAS_VISUAL_ANOMALY
ei_post_processing_output_t postprocessed_output;

#if EI_DSP_ENABLE_RUNTIME_HR == 1
float heart_rate;
Expand Down
15 changes: 14 additions & 1 deletion edgeimpulse/edge-impulse-sdk/classifier/ei_model_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
#define EI_CLASSIFIER_CLASSIFICATION_MODE_DSP 7

struct ei_impulse;
class ei_impulse_handle_t;

typedef struct {
ei::matrix_t* matrix;
Expand Down Expand Up @@ -131,6 +132,14 @@ typedef struct {
uint32_t output_features_count;
} ei_learning_block_t;

typedef struct {
uint32_t block_id;
EI_IMPULSE_ERROR (*init_fn)(ei_impulse_handle_t *handle, void *config);
EI_IMPULSE_ERROR (*deinit_fn)(ei_impulse_handle_t *handle, void *config);
EI_IMPULSE_ERROR (*postprocess_fn)(ei_impulse_handle_t *handle, ei_impulse_result_t *result, void *config, bool debug);
void *config;
} ei_postprocessing_block_t;

typedef struct {
uint16_t implementation_version;
uint8_t input_datatype;
Expand Down Expand Up @@ -250,6 +259,10 @@ typedef struct ei_impulse {
const uint8_t learning_blocks_size;
const ei_learning_block_t *learning_blocks;

/* postprocessing blocks */
const size_t postprocessing_blocks_size;
const ei_postprocessing_block_t *postprocessing_blocks;

/* inference parameters */
uint8_t inferencing_engine;

Expand All @@ -262,7 +275,6 @@ typedef struct ei_impulse {
/* output details */
uint8_t has_anomaly;
uint16_t label_count;
const ei_model_performance_calibration_t calibration;
const char **categories;
ei_object_detection_nms_config_t object_detection_nms;
} ei_impulse_t;
Expand Down Expand Up @@ -327,6 +339,7 @@ class ei_impulse_handle_t {
public:
ei_impulse_handle_t(const ei_impulse_t *impulse)
: state(impulse), impulse(impulse) {};
void* post_processing_state;
ei_impulse_state_t state;
const ei_impulse_t *impulse;
};
Expand Down
115 changes: 27 additions & 88 deletions edgeimpulse/edge-impulse-sdk/classifier/ei_run_classifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "ei_run_dsp.h"
#include "ei_classifier_types.h"
#include "ei_signal_with_axes.h"
#include "ei_performance_calibration.h"
#include "postprocessing/ei_postprocessing.h"

#include "edge-impulse-sdk/porting/ei_classifier_porting.h"
#include "edge-impulse-sdk/porting/ei_logging.h"
Expand Down Expand Up @@ -86,14 +86,12 @@ EI_IMPULSE_ERROR ei_unscale_fmatrix(ei_learning_block_t *block, ei::matrix_t *fm
/* Private variables ------------------------------------------------------- */

static uint64_t classifier_continuous_features_written = 0;
static RecognizeEvents *avg_scores = NULL;

/* Private functions ------------------------------------------------------- */

/* These functions (up to Public functions section) are not exposed to end-user,
therefore changes are allowed. */


/**
* @brief Display the results of the inference
*
Expand Down Expand Up @@ -355,6 +353,7 @@ extern "C" EI_IMPULSE_ERROR process_impulse(ei_impulse_handle_t *handle,

EI_IMPULSE_ERROR res = run_inference(handle, features, result, debug);
delete[] matrix_ptrs;
res = run_postprocessing(handle, result, debug);
return res;
}

Expand All @@ -376,18 +375,17 @@ extern "C" EI_IMPULSE_ERROR init_impulse(ei_impulse_handle_t *handle) {
/**
* @brief Process a complete impulse for continuous inference
*
* @param impulse struct with information about model and DSP
* @param signal Sample data
* @param result Output classifier results
* @param[in] debug Debug output enable
* @param handle struct with information about model and DSP
* @param signal Sample data
* @param result Output classifier results
* @param[in] debug Debug output enable
*
* @return The ei impulse error.
*/
extern "C" EI_IMPULSE_ERROR process_impulse_continuous(ei_impulse_handle_t *handle,
signal_t *signal,
ei_impulse_result_t *result,
bool debug,
bool enable_maf)
bool debug)
{
auto impulse = handle->impulse;
static ei::matrix_t static_features_matrix(1, impulse->nn_input_frame_size);
Expand Down Expand Up @@ -461,6 +459,11 @@ extern "C" EI_IMPULSE_ERROR process_impulse_continuous(ei_impulse_handle_t *hand
result->timing.dsp_us = ei_read_timer_us() - dsp_start_us;
result->timing.dsp = (int)(result->timing.dsp_us / 1000);

for (int i = 0; i < impulse->label_count; i++) {
// set label correctly in the result struct if we have no results (otherwise is nullptr)
result->classification[i].label = impulse->categories[(uint32_t)i];
}

if (classifier_continuous_features_written >= impulse->nn_input_frame_size) {
dsp_start_us = ei_read_timer_us();

Expand Down Expand Up @@ -513,56 +516,8 @@ extern "C" EI_IMPULSE_ERROR process_impulse_continuous(ei_impulse_handle_t *hand
}

ei_impulse_error = run_inference(handle, features, result, debug);

#if EI_CLASSIFIER_CALIBRATION_ENABLED
if (impulse->sensor == EI_CLASSIFIER_SENSOR_MICROPHONE) {
if((void *)avg_scores != NULL && enable_maf == true) {
if (enable_maf && !impulse->calibration.is_configured) {
// perfcal is not configured, print msg first time
static bool has_printed_msg = false;

if (!has_printed_msg) {
ei_printf("WARN: run_classifier_continuous, enable_maf is true, but performance calibration is not configured.\n");
ei_printf(" Previously we'd run a moving-average filter over your outputs in this case, but this is now disabled.\n");
ei_printf(" Go to 'Performance calibration' in your Edge Impulse project to configure post-processing parameters.\n");
ei_printf(" (You can enable this from 'Dashboard' if it's not visible in your project)\n");
ei_printf("\n");

has_printed_msg = true;
}
}
else {
// perfcal is configured
static bool has_printed_msg = false;

if (!has_printed_msg) {
ei_printf("\nPerformance calibration is configured for your project. If no event is detected, all values are 0.\r\n\n");
has_printed_msg = true;
}

int label_detected = avg_scores->trigger(result->classification);

if (avg_scores->should_boost()) {
for (int i = 0; i < impulse->label_count; i++) {
if (i == label_detected) {
result->classification[i].value = 1.0f;
}
else {
result->classification[i].value = 0.0f;
}
}
}
}
}
}
#endif
delete[] matrix_ptrs;
}
else {
for (int i = 0; i < impulse->label_count; i++) {
// set label correctly in the result struct if we have no results (otherwise is nullptr)
result->classification[i].label = impulse->categories[(uint32_t)i];
}
ei_impulse_error = run_postprocessing(handle, result, debug);
}

return ei_impulse_error;
Expand Down Expand Up @@ -782,17 +737,7 @@ extern "C" void run_classifier_init(void)
classifier_continuous_features_written = 0;
ei_dsp_clear_continuous_audio_state();
init_impulse(&ei_default_impulse);

#if EI_CLASSIFIER_CALIBRATION_ENABLED

const auto impulse = ei_default_impulse.impulse;
const ei_model_performance_calibration_t *calibration = &impulse->calibration;

if(calibration != NULL) {
avg_scores = new RecognizeEvents(calibration,
impulse->label_count, impulse->slice_size, impulse->interval_ms);
}
#endif
init_postprocessing(&ei_default_impulse);
}

/**
Expand All @@ -814,16 +759,7 @@ __attribute__((unused)) void run_classifier_init(ei_impulse_handle_t *handle)
classifier_continuous_features_written = 0;
ei_dsp_clear_continuous_audio_state();
init_impulse(handle);

#if EI_CLASSIFIER_CALIBRATION_ENABLED
auto impulse = handle->impulse;
const ei_model_performance_calibration_t *calibration = &impulse->calibration;

if(calibration != NULL) {
avg_scores = new RecognizeEvents(calibration,
impulse->label_count, impulse->slice_size, impulse->interval_ms);
}
#endif
init_postprocessing(handle);
}

/**
Expand All @@ -839,9 +775,12 @@ __attribute__((unused)) void run_classifier_init(ei_impulse_handle_t *handle)
*/
extern "C" void run_classifier_deinit(void)
{
if((void *)avg_scores != NULL) {
delete avg_scores;
}
deinit_postprocessing(&ei_default_impulse);
}

__attribute__((unused)) void run_classifier_deinit(ei_impulse_handle_t *handle)
{
deinit_postprocessing(handle);
}

/**
Expand Down Expand Up @@ -888,7 +827,7 @@ extern "C" void run_classifier_deinit(void)
* results from inference after run_classifier() returns.
* @param[in] debug Print internal preprocessing and inference debugging information via
* `ei_printf()`.
* @param[in] enable_maf Enable the moving average filter (MAF) for the classifier.
* @param[in] enable_maf_unused Enable the moving average filter (MAF) for the classifier - deprecated, replaced with Performance Calibration
*
* @return Error code as defined by `EI_IMPULSE_ERROR` enum. Will be `EI_IMPULSE_OK` if inference
* completed successfully.
Expand All @@ -897,10 +836,10 @@ extern "C" EI_IMPULSE_ERROR run_classifier_continuous(
signal_t *signal,
ei_impulse_result_t *result,
bool debug = false,
bool enable_maf = true)
bool enable_maf_unused = true)
{
auto& impulse = ei_default_impulse;
return process_impulse_continuous(&impulse, signal, result, debug, enable_maf);
return process_impulse_continuous(&impulse, signal, result, debug);
}

/**
Expand Down Expand Up @@ -948,7 +887,7 @@ extern "C" EI_IMPULSE_ERROR run_classifier_continuous(
* results from inference after run_classifier() returns.
* @param[in] debug Print internal preprocessing and inference debugging information via
* `ei_printf()`.
* @param[in] enable_maf Enable the moving average filter (MAF) for the classifier.
* @param[in] enable_maf_unused Enable the moving average filter (MAF) for the classifier - deprecated, replaced with Performance Calibration
*
* @return Error code as defined by `EI_IMPULSE_ERROR` enum. Will be `EI_IMPULSE_OK` if inference
* completed successfully.
Expand All @@ -958,9 +897,9 @@ __attribute__((unused)) EI_IMPULSE_ERROR run_classifier_continuous(
signal_t *signal,
ei_impulse_result_t *result,
bool debug = false,
bool enable_maf = true)
bool enable_maf_unused = true)
{
return process_impulse_continuous(impulse, signal, result, debug, enable_maf);
return process_impulse_continuous(impulse, signal, result, debug);
}

/**
Expand Down
Loading

0 comments on commit 3efb012

Please sign in to comment.