Skip to content

Commit

Permalink
Firmware and SDK release 14 Mar 2024
Browse files Browse the repository at this point in the history
  • Loading branch information
mmajchrzycki committed Mar 14, 2024
1 parent b41ff93 commit afc5c7a
Show file tree
Hide file tree
Showing 8 changed files with 247 additions and 236 deletions.
9 changes: 6 additions & 3 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.47.2/</url>
<url>https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.48.1/</url>
<supportContact>[email protected]</supportContact>
<repository type="git">https://github.com/edgeimpulse/edge-impulse-sdk-pack.git</repository>
<releases>
<release version="1.47.2" tag="v1.47.2" date="2024-03-12" url="https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.47.2/EdgeImpulse.EI-SDK.1.47.2.pack">
<release version="1.48.1" tag="v1.48.1" date="2024-03-14" url="https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.48.1/EdgeImpulse.EI-SDK.1.48.1.pack">
EI-SDK
</release>
<release version="1.47.2" tag="v1.47.2" date="2024-03-12" url="https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.47.2/EdgeImpulse.EI-SDK.1.47.2.pack">
EI-SDK
</release>
<release version="1.47.0" tag="v1.47.0" date="2024-03-08" url="https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.47.0/EdgeImpulse.EI-SDK.1.47.0.pack">
EI-SDK
</release>
Expand Down Expand Up @@ -83,7 +86,7 @@
</packages>
</requirements>
<components>
<component Cclass="EdgeImpulse" Cgroup="SDK" Cversion="1.47.2">
<component Cclass="EdgeImpulse" Cgroup="SDK" Cversion="1.48.1">
<description>Edge Impulse SDK</description>
<!-- short component description -->
<files>
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-03-12 12:26:06</timestamp>
<timestamp>2024-03-14 14:16:31</timestamp>
<pindex>
<pdsc url="https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.47.2/" vendor="EdgeImpulse" name="EI-SDK" version="1.47.2"/>
<pdsc url="https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.48.1/" vendor="EdgeImpulse" name="EI-SDK" version="1.48.1"/>
</pindex>
</index>
353 changes: 155 additions & 198 deletions edgeimpulse/edge-impulse-sdk/classifier/ei_fill_result_struct.h

Large diffs are not rendered by default.

54 changes: 40 additions & 14 deletions edgeimpulse/edge-impulse-sdk/classifier/ei_nms.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,12 @@ EI_IMPULSE_ERROR ei_run_nms(
float *scores,
int *classes,
size_t bb_count,
bool clip_boxes) {
bool clip_boxes,
bool debug) {

if (bb_count < 1) {
return EI_IMPULSE_OK;
}

int *selected_indices = (int*)ei_malloc(1 * bb_count * sizeof(int));
float *selected_scores = (float*)ei_malloc(1 * bb_count * sizeof(float));
Expand Down Expand Up @@ -246,12 +251,11 @@ EI_IMPULSE_ERROR ei_run_nms(
std::vector<ei_impulse_result_bounding_box_t> new_results;

for (size_t ix = 0; ix < (size_t)num_selected_indices; ix++) {
// ei_printf("Found bb with label %s\n", bb.label);

int out_ix = selected_indices[ix];
ei_impulse_result_bounding_box_t r;
r.label = impulse->categories[classes[out_ix]];
r.value = selected_scores[ix];
ei_impulse_result_bounding_box_t bb;
bb.label = impulse->categories[classes[out_ix]];
bb.value = selected_scores[ix];

float ymin = boxes[(out_ix * 4) + 0];
float xmin = boxes[(out_ix * 4) + 1];
Expand All @@ -265,11 +269,16 @@ EI_IMPULSE_ERROR ei_run_nms(
xmax = std::min(std::max(xmax, 0.0f), (float)impulse->input_width);
}

r.y = static_cast<uint32_t>(ymin);
r.x = static_cast<uint32_t>(xmin);
r.height = static_cast<uint32_t>(ymax) - r.y;
r.width = static_cast<uint32_t>(xmax) - r.x;
new_results.push_back(r);
bb.y = static_cast<uint32_t>(ymin);
bb.x = static_cast<uint32_t>(xmin);
bb.height = static_cast<uint32_t>(ymax) - bb.y;
bb.width = static_cast<uint32_t>(xmax) - bb.x;
new_results.push_back(bb);

if (debug) {
ei_printf("Found bb with label %s\n", bb.label);
}

}

results->clear();
Expand All @@ -290,7 +299,9 @@ EI_IMPULSE_ERROR ei_run_nms(
*/
EI_IMPULSE_ERROR ei_run_nms(
const ei_impulse_t *impulse,
std::vector<ei_impulse_result_bounding_box_t> *results) {
std::vector<ei_impulse_result_bounding_box_t> *results,
bool clip_boxes,
bool debug) {

size_t bb_count = 0;
for (size_t ix = 0; ix < results->size(); ix++) {
Expand All @@ -301,6 +312,10 @@ EI_IMPULSE_ERROR ei_run_nms(
bb_count++;
}

if (bb_count < 1) {
return EI_IMPULSE_OK;
}

float *boxes = (float*)ei_malloc(4 * bb_count * sizeof(float));
float *scores = (float*)ei_malloc(1 * bb_count * sizeof(float));
int *classes = (int*) ei_malloc(bb_count * sizeof(int));
Expand Down Expand Up @@ -335,7 +350,8 @@ EI_IMPULSE_ERROR ei_run_nms(
EI_IMPULSE_ERROR nms_res = ei_run_nms(impulse, results,
boxes, scores,
classes, bb_count,
true /*clip_boxes*/);
clip_boxes,
debug);


ei_free(boxes);
Expand All @@ -349,7 +365,17 @@ EI_IMPULSE_ERROR ei_run_nms(
/**
* Run non-max suppression over the results array (for bounding boxes)
*/
EI_IMPULSE_ERROR ei_run_nms(std::vector<ei_impulse_result_bounding_box_t> *results) {
EI_IMPULSE_ERROR ei_run_nms(
const ei_impulse_t *impulse,
std::vector<ei_impulse_result_bounding_box_t> *results,
bool debug = false) {
return ei_run_nms(impulse, results, true, debug);
}

/**
* Run non-max suppression over the results array (for bounding boxes)
*/
EI_IMPULSE_ERROR ei_run_nms(std::vector<ei_impulse_result_bounding_box_t> *results, bool debug = false) {
#if EI_CLASSIFIER_HAS_MODEL_VARIABLES == 1
auto& impulse = *ei_default_impulse.impulse;
#else
Expand All @@ -358,7 +384,7 @@ EI_IMPULSE_ERROR ei_run_nms(std::vector<ei_impulse_result_bounding_box_t> *resul
.object_detection_nms.iou_threshold = 0.2f
};
#endif
return ei_run_nms(&impulse, results);
return ei_run_nms(&impulse, results, debug);
}

#endif // #if (EI_CLASSIFIER_OBJECT_DETECTION_LAST_LAYER == EI_CLASSIFIER_LAST_LAYER_YOLOV5) || (EI_CLASSIFIER_OBJECT_DETECTION_LAST_LAYER == EI_CLASSIFIER_LAST_LAYER_YOLOV5_V5_DRPAI) || (EI_CLASSIFIER_OBJECT_DETECTION_LAST_LAYER == EI_CLASSIFIER_LAST_LAYER_YOLOX) || (EI_CLASSIFIER_OBJECT_DETECTION_LAST_LAYER == EI_CLASSIFIER_LAST_LAYER_TAO_RETINANET) || (EI_CLASSIFIER_OBJECT_DETECTION_LAST_LAYER == EI_CLASSIFIER_LAST_LAYER_TAO_SSD) || (EI_CLASSIFIER_OBJECT_DETECTION_LAST_LAYER == EI_CLASSIFIER_LAST_LAYER_TAO_YOLOV3) || (EI_CLASSIFIER_OBJECT_DETECTION_LAST_LAYER == EI_CLASSIFIER_LAST_LAYER_TAO_YOLOV4)
Expand Down
7 changes: 7 additions & 0 deletions edgeimpulse/edge-impulse-sdk/classifier/ei_run_classifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ __attribute__((unused)) void display_results(ei_impulse_result_t* result)
if (!bb_found) {
ei_printf(" No objects found\n");
}

#elif (EI_CLASSIFIER_LABEL_COUNT == 1) && (!EI_CLASSIFIER_HAS_ANOMALY)// regression
ei_printf("#Regression results:\r\n");
ei_printf(" %s: ", result->classification[0].label);
ei_printf_float(result->classification[0].value);
ei_printf("\n");

#elif EI_CLASSIFIER_LABEL_COUNT > 1 // if there is only one label, this is an anomaly only
ei_printf("#Classification results:\r\n");
for (size_t ix = 0; ix < EI_CLASSIFIER_LABEL_COUNT; ix++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,22 +253,25 @@ EI_IMPULSE_ERROR run_nn_inference(
impulse,
result,
out_data,
impulse->tflite_output_features_count);
impulse->tflite_output_features_count,
debug);
break;
}
case EI_CLASSIFIER_LAST_LAYER_TAO_YOLOV3:
fill_res = fill_result_struct_f32_tao_yolov3(
impulse,
result,
out_data,
impulse->tflite_output_features_count);
impulse->tflite_output_features_count,
debug);
break;
case EI_CLASSIFIER_LAST_LAYER_TAO_YOLOV4: {
fill_res = fill_result_struct_f32_tao_yolov4(
impulse,
result,
out_data,
impulse->tflite_output_features_count);
impulse->tflite_output_features_count,
debug);
break;
}
default: {
Expand Down Expand Up @@ -308,4 +311,4 @@ EI_IMPULSE_ERROR run_nn_inference_image_quantized(
}

#endif // #if (EI_CLASSIFIER_INFERENCING_ENGINE == EI_CLASSIFIER_TENSORRT)
#endif // _EI_CLASSIFIER_INFERENCING_ENGINE_TENSORRT_H_
#endif // _EI_CLASSIFIER_INFERENCING_ENGINE_TENSORRT_H_
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,8 @@ EI_IMPULSE_ERROR fill_result_struct_from_output_tensor_tflite(
output->data.int8,
output->params.zero_point,
output->params.scale,
impulse->tflite_output_features_count);
impulse->tflite_output_features_count,
debug);
}
else if (output->type == kTfLiteUInt8) {
fill_res = fill_result_struct_quantized_yolov5(
Expand All @@ -346,15 +347,17 @@ EI_IMPULSE_ERROR fill_result_struct_from_output_tensor_tflite(
output->data.uint8,
output->params.zero_point,
output->params.scale,
impulse->tflite_output_features_count);
impulse->tflite_output_features_count,
debug);
}
else if (output->type == kTfLiteFloat32) {
fill_res = fill_result_struct_f32_yolov5(
impulse,
result,
version,
output->data.f,
impulse->tflite_output_features_count);
impulse->tflite_output_features_count,
debug);
}
else {
ei_printf("ERR: Invalid output type (%d) for YOLOv5 last layer\n", output->type);
Expand All @@ -371,7 +374,8 @@ EI_IMPULSE_ERROR fill_result_struct_from_output_tensor_tflite(
impulse,
result,
output->data.f,
impulse->tflite_output_features_count);
impulse->tflite_output_features_count,
debug);
#endif
break;
}
Expand Down Expand Up @@ -402,7 +406,8 @@ EI_IMPULSE_ERROR fill_result_struct_from_output_tensor_tflite(
output->data.int8,
output->params.zero_point,
output->params.scale,
impulse->tflite_output_features_count);
impulse->tflite_output_features_count,
debug);
}
else if (output->type == kTfLiteUInt8) {
fill_res = fill_result_struct_quantized_tao_decode_detections(
Expand All @@ -411,14 +416,16 @@ EI_IMPULSE_ERROR fill_result_struct_from_output_tensor_tflite(
output->data.uint8,
output->params.zero_point,
output->params.scale,
impulse->tflite_output_features_count);
impulse->tflite_output_features_count,
debug);
}
else if (output->type == kTfLiteFloat32) {
fill_res = fill_result_struct_f32_tao_decode_detections(
impulse,
result,
output->data.f,
impulse->tflite_output_features_count);
impulse->tflite_output_features_count,
debug);
}
else {
ei_printf("ERR: Invalid output type (%d) for TAO last layer\n", output->type);
Expand All @@ -435,7 +442,8 @@ EI_IMPULSE_ERROR fill_result_struct_from_output_tensor_tflite(
output->data.int8,
output->params.zero_point,
output->params.scale,
impulse->tflite_output_features_count);
impulse->tflite_output_features_count,
debug);
}
else if (output->type == kTfLiteUInt8) {
fill_res = fill_result_struct_quantized_tao_yolov3(
Expand All @@ -444,14 +452,16 @@ EI_IMPULSE_ERROR fill_result_struct_from_output_tensor_tflite(
output->data.uint8,
output->params.zero_point,
output->params.scale,
impulse->tflite_output_features_count);
impulse->tflite_output_features_count,
debug);
}
else if (output->type == kTfLiteFloat32) {
fill_res = fill_result_struct_f32_tao_yolov3(
impulse,
result,
output->data.f,
impulse->tflite_output_features_count);
impulse->tflite_output_features_count,
debug);
}
else {
ei_printf("ERR: Invalid output type (%d) for TAO YOLOv3 layer\n", output->type);
Expand All @@ -468,7 +478,8 @@ EI_IMPULSE_ERROR fill_result_struct_from_output_tensor_tflite(
output->data.int8,
output->params.zero_point,
output->params.scale,
impulse->tflite_output_features_count);
impulse->tflite_output_features_count,
debug);
}
else if (output->type == kTfLiteUInt8) {
fill_res = fill_result_struct_quantized_tao_yolov4(
Expand All @@ -477,14 +488,16 @@ EI_IMPULSE_ERROR fill_result_struct_from_output_tensor_tflite(
output->data.uint8,
output->params.zero_point,
output->params.scale,
impulse->tflite_output_features_count);
impulse->tflite_output_features_count,
debug);
}
else if (output->type == kTfLiteFloat32) {
fill_res = fill_result_struct_f32_tao_yolov4(
impulse,
result,
output->data.f,
impulse->tflite_output_features_count);
impulse->tflite_output_features_count,
debug);
}
else {
ei_printf("ERR: Invalid output type (%d) for TAO YOLOv4 layer\n", output->type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,8 @@ EI_IMPULSE_ERROR run_nn_inference(
result,
version,
out_data,
impulse->tflite_output_features_count);
impulse->tflite_output_features_count,
debug);
#endif
break;
}
Expand All @@ -301,7 +302,8 @@ EI_IMPULSE_ERROR run_nn_inference(
impulse,
result,
out_data,
impulse->tflite_output_features_count);
impulse->tflite_output_features_count,
debug);
#endif
break;
}
Expand Down

0 comments on commit afc5c7a

Please sign in to comment.