Skip to content

Commit

Permalink
SDK release v1.61.7
Browse files Browse the repository at this point in the history
  • Loading branch information
francovaro committed Nov 6, 2024
1 parent de187d3 commit c7b04cc
Show file tree
Hide file tree
Showing 17 changed files with 1,707 additions and 97 deletions.
19 changes: 12 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.60.13/</url>
<url>https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.61.7/</url>
<supportContact>[email protected]</supportContact>
<repository type="git">https://github.com/edgeimpulse/edge-impulse-sdk-pack.git</repository>
<releases>
<release version="1.60.13" tag="v1.60.13" date="2024-10-29" url="https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.60.13/EdgeImpulse.EI-SDK.1.60.13.pack">
<release version="1.61.7" tag="v1.61.7" date="2024-11-06" url="https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.61.7/EdgeImpulse.EI-SDK.1.61.7.pack">
EI-SDK
</release>
<release version="1.60.13" tag="v1.60.13" date="2024-10-29" url="https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.60.13/EdgeImpulse.EI-SDK.1.60.13.pack">
EI-SDK
</release>
<release version="1.60.9" tag="v1.60.9" date="2024-10-24" url="https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.60.9/EdgeImpulse.EI-SDK.1.60.9.pack">
EI-SDK
</release>
Expand Down Expand Up @@ -98,9 +101,6 @@
</release>
<release version="1.50.13" tag="v1.50.13" date="2024-05-30" url="https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.50.13/EdgeImpulse.EI-SDK.1.50.13.pack">
EI-SDK
</release>
<release version="1.50.11" tag="v1.50.11" date="2024-05-27" url="https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.50.11/EdgeImpulse.EI-SDK.1.50.11.pack">
EI-SDK
</release>
</releases>
<keywords>
Expand Down Expand Up @@ -146,7 +146,7 @@
</packages>
</requirements>
<components>
<component Cclass="EdgeImpulse" Cgroup="SDK" Cversion="1.60.13">
<component Cclass="EdgeImpulse" Cgroup="SDK" Cversion="1.61.7">
<description>Edge Impulse SDK</description>
<!-- short component description -->
<files>
Expand Down Expand Up @@ -403,9 +403,11 @@
<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_common.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/classifier/postprocessing/ei_object_tracking.h"/>
<file category="header" name="edgeimpulse/edge-impulse-sdk/classifier/postprocessing/tinyEKF/tinyekf_custom.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 Expand Up @@ -656,6 +658,9 @@
<file category="header" name="edgeimpulse/edge-impulse-sdk/porting/espressif/ESP-NN/include/esp_nn_ansi_c.h"/>
<file category="header" name="edgeimpulse/edge-impulse-sdk/porting/espressif/ESP-NN/src/common/common_functions.h"/>
<file category="header" name="edgeimpulse/edge-impulse-sdk/porting/espressif/ESP-NN/src/softmax/softmax_common.h"/>
<file category="header" name="edgeimpulse/edge-impulse-sdk/classifier/postprocessing/alignment/ei_alignment.hpp"/>
<file category="header" name="edgeimpulse/edge-impulse-sdk/classifier/postprocessing/alignment/rectangular_lsap.hpp"/>
<file category="header" name="edgeimpulse/edge-impulse-sdk/classifier/postprocessing/tinyEKF/tinyekf.hpp"/>
<file category="header" name="edgeimpulse/edge-impulse-sdk/dsp/config.hpp"/>
<file category="header" name="edgeimpulse/edge-impulse-sdk/dsp/numpy.hpp"/>
<file category="header" name="edgeimpulse/edge-impulse-sdk/dsp/memory.hpp"/>
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-10-29 12:24:25</timestamp>
<timestamp>2024-11-06 09:42:54</timestamp>
<pindex>
<pdsc url="https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.60.13/" vendor="EdgeImpulse" name="EI-SDK" version="1.60.13"/>
<pdsc url="https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.61.7/" vendor="EdgeImpulse" name="EI-SDK" version="1.61.7"/>
</pindex>
</index>
17 changes: 11 additions & 6 deletions edgeimpulse/edge-impulse-sdk/classifier/ei_fill_result_struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ __attribute__((unused)) static void fill_result_struct_from_cubes(ei_impulse_res
static std::vector<ei_impulse_result_bounding_box_t> results;
int added_boxes_count = 0;
results.clear();

for (auto sc : *cubes) {
bool has_overlapping = false;

Expand Down Expand Up @@ -199,7 +200,7 @@ __attribute__((unused)) static void fill_result_struct_from_cubes(ei_impulse_res
}

result->bounding_boxes = results.data();
result->bounding_boxes_count = results.size();
result->bounding_boxes_count = added_boxes_count;
}
#endif

Expand Down Expand Up @@ -283,8 +284,10 @@ __attribute__((unused)) static EI_IMPULSE_ERROR fill_result_struct_f32_object_de
bool debug) {
#ifdef EI_HAS_SSD
static std::vector<ei_impulse_result_bounding_box_t> results;
int added_boxes_count = 0;
results.clear();
results.resize(impulse->object_detection_count);

for (size_t ix = 0; ix < impulse->object_detection_count; ix++) {

float score = scores[ix];
Expand Down Expand Up @@ -329,13 +332,15 @@ __attribute__((unused)) static EI_IMPULSE_ERROR fill_result_struct_f32_object_de
results[ix].width = static_cast<uint32_t>((xend - xstart) * static_cast<float>(impulse->input_width));
results[ix].height = static_cast<uint32_t>((yend - ystart) * static_cast<float>(impulse->input_height));
results[ix].value = score;

added_boxes_count++;
}
else {
results[ix].value = 0.0f;
}
}
result->bounding_boxes = results.data();
result->bounding_boxes_count = results.size();
result->bounding_boxes_count = added_boxes_count;

return EI_IMPULSE_OK;
#else
Expand Down Expand Up @@ -547,7 +552,7 @@ __attribute__((unused)) static EI_IMPULSE_ERROR fill_result_struct_f32_yolov5(co
}

result->bounding_boxes = results.data();
result->bounding_boxes_count = results.size();
result->bounding_boxes_count = added_boxes_count;

return EI_IMPULSE_OK;
#else
Expand Down Expand Up @@ -647,7 +652,7 @@ __attribute__((unused)) static EI_IMPULSE_ERROR fill_result_struct_quantized_yol
}

result->bounding_boxes = results.data();
result->bounding_boxes_count = results.size();
result->bounding_boxes_count = added_boxes_count;

return EI_IMPULSE_OK;
#else
Expand Down Expand Up @@ -852,7 +857,7 @@ __attribute__((unused)) static EI_IMPULSE_ERROR fill_result_struct_f32_yolox(con
}

result->bounding_boxes = results.data();
result->bounding_boxes_count = results.size();
result->bounding_boxes_count = added_boxes_count;

return EI_IMPULSE_OK;
#else
Expand Down Expand Up @@ -1711,7 +1716,7 @@ __attribute__((unused)) static EI_IMPULSE_ERROR fill_result_struct_f32_yolov2(co
}

result->bounding_boxes = results.data();
result->bounding_boxes_count = results.size();
result->bounding_boxes_count = added_boxes_count;

return EI_IMPULSE_OK;
#else
Expand Down
24 changes: 18 additions & 6 deletions edgeimpulse/edge-impulse-sdk/classifier/ei_model_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,19 @@ typedef struct {
float detection_threshold;
uint32_t suppression_ms;
uint32_t suppression_flags;
} ei_model_performance_calibration_t;
} ei_performance_calibration_config_t;

typedef struct {
uint16_t implementation_version;
uint32_t keep_grace;
uint16_t max_observations;
float iou_threshold;
} ei_object_tracking_config_t;

typedef struct {
uint16_t implementation_version;
std::vector<std::tuple<int, int, int, int>> segments;
} ei_object_counting_config_t;

typedef int (*extract_fn_t)(ei::signal_t *signal, ei::matrix_t *output_matrix, void *config, float frequency);

Expand Down Expand Up @@ -134,9 +146,9 @@ typedef struct {

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);
EI_IMPULSE_ERROR (*init_fn)(ei_impulse_handle_t *handle, void **state, void *config);
EI_IMPULSE_ERROR (*deinit_fn)(void *state, void *config);
EI_IMPULSE_ERROR (*postprocess_fn)(ei_impulse_handle_t *handle, ei_impulse_result_t *result, void *config, void* state);
void *config;
} ei_postprocessing_block_t;

Expand Down Expand Up @@ -340,10 +352,10 @@ typedef DspHandle* _dsp_handle_ptr_t;
class ei_impulse_handle_t {
public:
ei_impulse_handle_t(const ei_impulse_t *impulse)
: state(impulse), impulse(impulse) {};
void* post_processing_state;
: state(impulse), impulse(impulse), post_processing_state(nullptr) {};
ei_impulse_state_t state;
const ei_impulse_t *impulse;
void** post_processing_state;
};

typedef struct {
Expand Down
7 changes: 6 additions & 1 deletion edgeimpulse/edge-impulse-sdk/classifier/ei_run_classifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,12 @@ extern "C" EI_IMPULSE_ERROR process_impulse(ei_impulse_handle_t *handle,
// Shortcut for quantized image models
ei_learning_block_t block = handle->impulse->learning_blocks[0];
if (can_run_classifier_image_quantized(handle->impulse, block) == EI_IMPULSE_OK) {
return run_classifier_image_quantized(handle->impulse, signal, result, debug);
EI_IMPULSE_ERROR res = run_classifier_image_quantized(handle->impulse, signal, result, debug);
if (res != EI_IMPULSE_OK) {
return res;
}
res = run_postprocessing(handle, result, debug);
return res;
}
#endif

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
#pragma once

#include <vector>
#include <tuple>
#include <set>
#include <algorithm>
#include <cmath>
#include "rectangular_lsap.hpp"

#if !defined(STANDALONE)
#include "edge-impulse-sdk/classifier/ei_classifier_types.h"
#endif

__attribute__((unused)) static bool compare_tuples(std::tuple<int, int, float> a, std::tuple<int, int, float> b) {
return std::get<2>(a) < std::get<2>(b);
}

float intersection_over_union(const ei_impulse_result_bounding_box_t bbox1, const ei_impulse_result_bounding_box_t bbox2) {
uint32_t x_left = std::max(bbox1.x, bbox2.x);
uint32_t y_top = std::max(bbox1.y, bbox2.y);
uint32_t x_right = std::min(bbox1.x + bbox1.width, bbox2.x + bbox2.width);
uint32_t y_bottom = std::min(bbox1.y + bbox1.height, bbox2.y + bbox2.height);

if (x_right < x_left || y_bottom < y_top) {
return 0.0;
}

uint32_t intersection_area = (x_right - x_left) * (y_bottom - y_top);
uint32_t bbox1_area = bbox1.width * bbox1.height;
uint32_t bbox2_area = bbox2.width * bbox2.height;

return static_cast<float>(intersection_area) / static_cast<float>(bbox1_area + bbox2_area - intersection_area);
}

class JonkerVolgenantAlignment {
public:
JonkerVolgenantAlignment(float iou_threshold) : iou_threshold(iou_threshold) {
}

std::vector<std::tuple<int, int, float>> align(const std::vector<ei_impulse_result_bounding_box_t> traces,
const std::vector<ei_impulse_result_bounding_box_t> detections) {

if (traces.empty() || detections.empty()) {
return {};
}

std::vector<double> cost_mtx(traces.size() * detections.size());
for (size_t trace_idx = 0; trace_idx < traces.size(); ++trace_idx) {
for (size_t detection_idx = 0; detection_idx < detections.size(); ++detection_idx) {
float iou = intersection_over_union(traces[trace_idx], detections[detection_idx]);
float cost = 1 - iou;
EI_LOGD("t_idx=%zu d_idx=%zu cost=%.6f\n", trace_idx, detection_idx, cost);
cost_mtx[trace_idx * detections.size() + detection_idx] = cost;
}
}

int64_t *alignments_a = new int64_t[traces.size()];
int64_t *alignments_b = new int64_t[detections.size()];

solve(traces.size(), detections.size(), cost_mtx.data(), false, alignments_a, alignments_b);
EI_LOGD("detections size %zu\n", detections.size());
EI_LOGD("traces size %zu\n", traces.size());

for (size_t i = 0; i < traces.size(); i++) {
EI_LOGD("alignments_a[%zu] %lld\n", i, alignments_a[i]);
}

for (size_t i = 0; i < detections.size(); i++) {
EI_LOGD("alignments_b[%zu] %lld\n", i, alignments_b[i]);
}

std::vector<std::tuple<int, int, float>> matches;

for (size_t i = 0; i < traces.size(); i++) {
size_t trace_idx = i;
size_t detection_idx = alignments_b[alignments_a[i]];
float iou = 1 - cost_mtx[trace_idx * detections.size() + detection_idx];
if (iou > iou_threshold) {
matches.emplace_back(trace_idx, detection_idx, iou);
}
}
delete[] alignments_a;
delete[] alignments_b;
return matches;
}

float iou_threshold;
};

class GreedyAlignment {
public:
GreedyAlignment(float iou_threshold) : iou_threshold(iou_threshold) {
}
std::vector<std::tuple<int, int, float>> align(const std::vector<ei_impulse_result_bounding_box_t> traces,
const std::vector<ei_impulse_result_bounding_box_t> detections) {

if (traces.empty() || detections.empty()) {
return {};
}

std::vector<std::tuple<int, int, float>> alignments;
for (size_t trace_idx = 0; trace_idx < traces.size(); ++trace_idx) {
for (size_t detection_idx = 0; detection_idx < detections.size(); ++detection_idx) {
float iou = intersection_over_union(traces[trace_idx], detections[detection_idx]);
float cost = 1 - iou;
EI_LOGD("t_idx=%zu d_idx=%zu cost=%.6f\n", trace_idx, detection_idx, cost);
if (iou > iou_threshold) {
alignments.emplace_back(trace_idx, detection_idx, cost);
}
}
}

std::sort(alignments.begin(), alignments.end(), compare_tuples);
EI_LOGD("alignments.size() %zu\n", alignments.size());
std::vector<std::tuple<int, int, float>> matches;
std::set<int> trace_idxs_matched;
std::set<int> detection_idxs_matched;

for (size_t i = 0; i < alignments.size(); i++) {
uint32_t trace_idx = std::get<0>(alignments[i]);
uint32_t detection_idx = std::get<1>(alignments[i]);
float cost = std::get<2>(alignments[i]);

if (trace_idxs_matched.find(trace_idx) == trace_idxs_matched.end() && detection_idxs_matched.find(detection_idx) == detection_idxs_matched.end()) {
// (1 - cost) to get iou
matches.emplace_back(trace_idx, detection_idx, 1 - cost);
trace_idxs_matched.insert(trace_idx);
if (trace_idxs_matched.size() == traces.size()) return matches;
detection_idxs_matched.insert(detection_idx);
if (detection_idxs_matched.size() == detections.size()) return matches;
}
}

return matches;
}

float iou_threshold;
};
Loading

0 comments on commit c7b04cc

Please sign in to comment.