Skip to content

Commit

Permalink
SDK release v1.49.23
Browse files Browse the repository at this point in the history
  • Loading branch information
francovaro committed May 9, 2024
1 parent 15ffa8f commit 396f530
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 5 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.49.21/</url>
<url>https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.49.23/</url>
<supportContact>[email protected]</supportContact>
<repository type="git">https://github.com/edgeimpulse/edge-impulse-sdk-pack.git</repository>
<releases>
<release version="1.49.21" tag="v1.49.21" date="2024-05-03" url="https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.49.21/EdgeImpulse.EI-SDK.1.49.21.pack">
<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>
<release version="1.49.21" tag="v1.49.21" date="2024-05-03" url="https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.49.21/EdgeImpulse.EI-SDK.1.49.21.pack">
EI-SDK
</release>
<release version="1.49.18" tag="v1.49.18" date="2024-04-30" url="https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.49.18/EdgeImpulse.EI-SDK.1.49.18.pack">
EI-SDK
</release>
Expand Down Expand Up @@ -128,7 +131,7 @@
</packages>
</requirements>
<components>
<component Cclass="EdgeImpulse" Cgroup="SDK" Cversion="1.49.21">
<component Cclass="EdgeImpulse" Cgroup="SDK" Cversion="1.49.23">
<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-05-03 10:40:48</timestamp>
<timestamp>2024-05-09 08:51:12</timestamp>
<pindex>
<pdsc url="https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.49.21/" vendor="EdgeImpulse" name="EI-SDK" version="1.49.21"/>
<pdsc url="https://github.com/edgeimpulse/edge-impulse-sdk-pack/releases/download/v1.49.23/" vendor="EdgeImpulse" name="EI-SDK" version="1.49.23"/>
</pindex>
</index>
1 change: 1 addition & 0 deletions edgeimpulse/edge-impulse-sdk/classifier/ei_model_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
#define EI_CLASSIFIER_IMAGE_SCALING_TORCH 2
#define EI_CLASSIFIER_IMAGE_SCALING_MIN1_1 3
#define EI_CLASSIFIER_IMAGE_SCALING_MIN128_127 4
#define EI_CLASSIFIER_IMAGE_SCALING_BGR_SUBTRACT_IMAGENET_MEAN 5

// maps back to ClassificationMode in keras-types.ts
#define EI_CLASSIFIER_CLASSIFICATION_MODE_CLASSIFICATION 1
Expand Down
30 changes: 30 additions & 0 deletions edgeimpulse/edge-impulse-sdk/classifier/ei_run_classifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,8 @@ to preserve backwards compatibility. */
#if EI_CLASSIFIER_LOAD_IMAGE_SCALING
static const float torch_mean[] = { 0.485, 0.456, 0.406 };
static const float torch_std[] = { 0.229, 0.224, 0.225 };
// This is ordered BGR
static const float tao_mean[] = { 103.939, 116.779, 123.68 };

EI_IMPULSE_ERROR ei_scale_fmatrix(ei_learning_block_t *block, ei::matrix_t *fmatrix) {
if (block->image_scaling == EI_CLASSIFIER_IMAGE_SCALING_TORCH) {
Expand Down Expand Up @@ -661,6 +663,20 @@ EI_IMPULSE_ERROR ei_scale_fmatrix(ei_learning_block_t *block, ei::matrix_t *fmat
return EI_IMPULSE_DSP_ERROR;
}
}
else if (block->image_scaling == EI_CLASSIFIER_IMAGE_SCALING_BGR_SUBTRACT_IMAGENET_MEAN) {
int scale_res = numpy::scale(fmatrix, 255.0f);
if (scale_res != EIDSP_OK) {
ei_printf("ERR: Failed to scale matrix (%d)\n", scale_res);
return EI_IMPULSE_DSP_ERROR;
}
// Transpose RGB to BGR and subtract mean
for (size_t ix = 0; ix < fmatrix->rows * fmatrix->cols; ix += 3) {
float r = fmatrix->buffer[ix + 0];
fmatrix->buffer[ix + 0] = fmatrix->buffer[ix + 2] - tao_mean[0];
fmatrix->buffer[ix + 1] -= tao_mean[1];
fmatrix->buffer[ix + 2] = r - tao_mean[2];
}
}

return EI_IMPULSE_OK;
}
Expand Down Expand Up @@ -705,6 +721,20 @@ EI_IMPULSE_ERROR ei_unscale_fmatrix(ei_learning_block_t *block, ei::matrix_t *fm
return EI_IMPULSE_DSP_ERROR;
}
}
else if (block->image_scaling == EI_CLASSIFIER_IMAGE_SCALING_BGR_SUBTRACT_IMAGENET_MEAN) {
// Transpose BGR to RGB and add mean
for (size_t ix = 0; ix < fmatrix->rows * fmatrix->cols; ix += 3) {
float b = fmatrix->buffer[ix + 0];
fmatrix->buffer[ix + 0] = fmatrix->buffer[ix + 2] + tao_mean[2];
fmatrix->buffer[ix + 1] += tao_mean[1];
fmatrix->buffer[ix + 2] = b + tao_mean[0];
}
int scale_res = numpy::scale(fmatrix, 1 / 255.0f);
if (scale_res != EIDSP_OK) {
ei_printf("ERR: Failed to scale matrix (%d)\n", scale_res);
return EI_IMPULSE_DSP_ERROR;
}
}
return EI_IMPULSE_OK;
}
#endif
Expand Down

0 comments on commit 396f530

Please sign in to comment.