diff --git a/EdgeImpulse.EI-SDK.pdsc b/EdgeImpulse.EI-SDK.pdsc index 846c2d4..848b935 100644 --- a/EdgeImpulse.EI-SDK.pdsc +++ b/EdgeImpulse.EI-SDK.pdsc @@ -5,13 +5,16 @@ EI-SDK LICENSE-apache-2.0.txt Edge Impulse SDK - https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.57.9/ + https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.57.11/ hello@edgeimpulse.com https://github.com/edgeimpulse/edge-impulse-sdk-pack.git - + EI-SDK + + EI-SDK + EI-SDK @@ -98,9 +101,6 @@ EI-SDK - - - EI-SDK @@ -146,7 +146,7 @@ - + Edge Impulse SDK diff --git a/EdgeImpulse.pidx b/EdgeImpulse.pidx index 335fe79..fd6b363 100644 --- a/EdgeImpulse.pidx +++ b/EdgeImpulse.pidx @@ -2,8 +2,8 @@ EdgeImpulse https://raw.githubusercontent.com/edgeimpulse/edge-impulse-sdk-pack/main/ - 2024-09-05 09:16:54 + 2024-09-12 14:30:49 - + diff --git a/edgeimpulse/edge-impulse-sdk/classifier/ei_fill_result_struct.h b/edgeimpulse/edge-impulse-sdk/classifier/ei_fill_result_struct.h index e3bfd04..2dc85db 100644 --- a/edgeimpulse/edge-impulse-sdk/classifier/ei_fill_result_struct.h +++ b/edgeimpulse/edge-impulse-sdk/classifier/ei_fill_result_struct.h @@ -404,17 +404,13 @@ __attribute__((unused)) static EI_IMPULSE_ERROR fill_result_struct_f32(const ei_ __attribute__((unused)) static EI_IMPULSE_ERROR fill_result_visual_ad_struct_f32(const ei_impulse_t *impulse, ei_impulse_result_t *result, float *data, - float threshold, + ei_learning_block_config_tflite_graph_t* block_config, bool debug) { #if EI_CLASSIFIER_HAS_VISUAL_ANOMALY float max_val = 0; float sum_val = 0; - // the feature extractor output will be 1/8 of input - // due to the cut-off layer chosen in MobileNetV2 - uint32_t grid_size_x = (impulse->input_width / 8) / 2 - 1; - uint32_t grid_size_y = (impulse->input_height / 8) / 2 - 1; - for (uint32_t ix = 0; ix < grid_size_x * grid_size_y; ix++) { + for (uint32_t ix = 0; ix < impulse->visual_ad_grid_size_x * impulse->visual_ad_grid_size_y; ix++) { float value = data[ix]; sum_val += value; if (value > max_val) { @@ -422,7 +418,7 @@ __attribute__((unused)) static EI_IMPULSE_ERROR fill_result_visual_ad_struct_f32 } } - result->visual_ad_result.mean_value = sum_val / (grid_size_x * grid_size_y); + result->visual_ad_result.mean_value = sum_val / (impulse->visual_ad_grid_size_x * impulse->visual_ad_grid_size_y); result->visual_ad_result.max_value = max_val; static ei_vector results; @@ -430,16 +426,16 @@ __attribute__((unused)) static EI_IMPULSE_ERROR fill_result_visual_ad_struct_f32 int added_boxes_count = 0; results.clear(); - for (uint32_t x = 0; x <= grid_size_x - 1; x++) { - for (uint32_t y = 0; y <= grid_size_y - 1; y++) { - if (data[x * grid_size_x + y] >= threshold) { + for (uint32_t x = 0; x <= impulse->visual_ad_grid_size_x - 1; x++) { + for (uint32_t y = 0; y <= impulse->visual_ad_grid_size_y - 1; y++) { + if (data[x * impulse->visual_ad_grid_size_x + y] >= block_config->threshold) { ei_impulse_result_bounding_box_t tmp = { .label = "anomaly", - .x = static_cast(y * (static_cast(impulse->input_height) / grid_size_y)), - .y = static_cast(x * (static_cast(impulse->input_width) / grid_size_x)), - .width = (impulse->input_width / grid_size_x), - .height = (impulse->input_height / grid_size_y), - .value = data[x * grid_size_x + y] + .x = static_cast(y * (static_cast(impulse->input_height) / impulse->visual_ad_grid_size_y)), + .y = static_cast(x * (static_cast(impulse->input_width) / impulse->visual_ad_grid_size_x)), + .width = (impulse->input_width / impulse->visual_ad_grid_size_x), + .height = (impulse->input_height / impulse->visual_ad_grid_size_y), + .value = data[x * impulse->visual_ad_grid_size_x + y] }; results.push_back(tmp); diff --git a/edgeimpulse/edge-impulse-sdk/classifier/ei_model_types.h b/edgeimpulse/edge-impulse-sdk/classifier/ei_model_types.h index 3fea30b..93b5685 100644 --- a/edgeimpulse/edge-impulse-sdk/classifier/ei_model_types.h +++ b/edgeimpulse/edge-impulse-sdk/classifier/ei_model_types.h @@ -253,6 +253,8 @@ typedef struct ei_impulse { /* object detection */ uint16_t object_detection_count; uint32_t fomo_output_size; + uint16_t visual_ad_grid_size_x; + uint16_t visual_ad_grid_size_y; uint32_t tflite_output_features_count; /* learning blocks */ diff --git a/edgeimpulse/edge-impulse-sdk/classifier/inferencing_engines/tflite_helper.h b/edgeimpulse/edge-impulse-sdk/classifier/inferencing_engines/tflite_helper.h index c567805..384b21e 100644 --- a/edgeimpulse/edge-impulse-sdk/classifier/inferencing_engines/tflite_helper.h +++ b/edgeimpulse/edge-impulse-sdk/classifier/inferencing_engines/tflite_helper.h @@ -550,7 +550,7 @@ EI_IMPULSE_ERROR fill_result_struct_from_output_tensor_tflite( else if (block_config->classification_mode == EI_CLASSIFIER_CLASSIFICATION_MODE_VISUAL_ANOMALY) { if (!result->copy_output) { - fill_res = fill_result_visual_ad_struct_f32(impulse, result, output->data.f, block_config->threshold, debug); + fill_res = fill_result_visual_ad_struct_f32(impulse, result, output->data.f, block_config, debug); } } // if we copy the output, we don't need to process it as classification