Different Inference Time on Edge Impulse Studio vs STM32 Discovery Kit

Question/Issue:
[I am here to report an issue i am having with my model when i deploy it on my target board - stm32l4r9 discovery kit.]

Project ID:
[614273]

Context/Use case:
[Respiratory rate estimation]

Summary:
[First of, the inference time recorded on the edge impulse studio is about 133ms post training. however when i deploy on the device inference time is about 6200ms - which i am able to infer by using a timer on my board. I have used a timer - which starts just before the classifier runs and stops when the classifier ends - because whenever the results are printed on screen the default code shows 0 ms… which is not true when you visualize it over a plot

I have tried to fix issue on my own but to no avail. Hence why I am coming here
Please find screenshot attached]

Expected Results:
[Inference time of 133 ms]

Actual Results:
[Inference time of 6200ms]

Reproducibility:

  • [*] Always
  • [ ] Sometimes
  • [ ] Rarely

Environment:

  • Platform: [STM32 Discovery Kit]
  • Build Environment Details: [STM32CubeIDE]
  • OS Version: [Windows 10]
  • Edge Impulse Version (Firmware): [Not sure]

Hi @kenadis - my initial suggestion is to switch off any prints that you have and only print the time result

I am assuming you are measuring the time before an after calling “run_inference” - however if you call it with “debug = true” all your features and other things are printed, which eats a lot of time.

So, set “debug = false” and make sure nothing else is printed between your measurements

@ivan Thanks for your suggestion.

In my current implementation i only have print function being executed after run_classifier().

After implementing your suggestion of setting debug to false. The Inference time reduces from 6200ms to 5800 ms now. But overall the inference time is still high compared to what was estimated during training and testing on the Studio.

Also I am curious to know why the run_classifier() function does not by default print the inference time.

Find attached screenshot of my code and print out results


image