Inference Error on STM32 Proteus simulation

Yes please,

so far I got here, where I can upload a firmware (I haven’t compile the firmware yet though):

Best,

Louis

add componets like this the right click on the board and select the HEX file location

To upload the HEX you click on program file and browse to the location of your generated HEX file, found in Debug folder for your project

I just tried to run the simulation with your HEX file but it seems that I cannot run simulation from the demo version of the Software. I’ll double check tomorrow if the issue comes from the demonstration version of the software or elsewhere.

Best,

Louis

Noted with thanks, Also cross check on the board, I had used STM32F401CE…Just noticed in the earlier image you used different one

Hi @louis check that the board selected is the one @ookosoft used . the code generated should match the board @ookosoft used

Yes I did change it to STM32F401CE but I got the same issue, I’ll share the errors I’m getting tomorrow with you.
Otherwise, I’ll try to look at your project with the SMT IDE to see if something looks odds.

Regards,

Louis

This is the error:

CM4.DLL failed to create DSIM model for primitive type 'CM4_CORE'.



I have not experienced this before but from most forums they seem to attribute such to licensing

@janjongboom @louis When I multiplied the value by 100 in the run classifier header file function below got results on proteus even though still not 100% same as from live classification

/**

  • Fill the result structure from a quantized output tensor
    */
    attribute((unused)) static void fill_result_struct_i8(ei_impulse_result_t *result, int8_t *data, float zero_point, float scale, bool debug) {
    for (uint32_t ix = 0; ix < EI_CLASSIFIER_LABEL_COUNT; ix++) {
    float value = static_cast(data[ix] - zero_point) * scale * 100;

     if (debug) {
         ei_printf("%s:\t", ei_classifier_inferencing_categories[ix]);
         ei_printf_float(value);
         ei_printf("\n");
     }
     result->classification[ix].label = ei_classifier_inferencing_categories[ix];
     result->classification[ix].value = value;
    

    }
    }

From live classification it was COPD:0 Healthy: 99

Hey @ookosoft,

I assume you do not do any custom processing on your raw data, you just changed the while loop?
I opened the project you sent me with the STM32CubeIDE but strangely, I had to re-import all the Edge Impulse dependencies.

Regards,

Louis

Hi @louis i work closely with @ookosoft this tutorial was used https://docs.edgeimpulse.com/docs/using-cubeai in the creation of the STM32 project

@marvin,

Great! I followed the same tutorial :slight_smile:
My bad, I tried to re-import your project from scratch and now I see all the Edge Impulse references in the main.cpp file

@louis when @ookosoft adjusted a code in ei_runclassifier.h rather than in main.cpp he got different values. remember we have two labels. our issue was that everytime we got [-0.5,-0.5] for each label which means the classification was not happening, but when he adjusted line 383 in ei_classifier.h there is an improvement, the values still don’t match with the live classification though

@marvin Could be a quantization error, you can double check by using the float32 model instead when deploying. That should always match 1:1 with the implementation in Studio. But with the other issues we see it could just as well be an error in the simulation. Hard to give support here as we don’t have a license :slight_smile:

@janjongboom thanks so much. there is actually a great improvement @ookosoft and i have seen . instead of a [-0.5,-0.5] for two classes, we get [1,-0] for a 100% correct classification.

1 Like