ModusToolbox ML Model Prediction Issue

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
jasminewu
Level 1
Level 1
First reply posted 5 sign-ins First question asked

I have an audio ML model I want to use to predict voice input to PSoC 6 (CY8CKIT-062-BLE). 

I've included a zip file with the main files. The code is a modified version of the ML configurator sample code. 

There is a basic state machine to determine when someone is actually speaking, and once it is done the audio is preprocessed then fed into the model. The preprocessing (STFT) function works (or at least runs to completion and returns numbers) but when trying to feed the input into mtb_ml_model_run, the code freezes. I added a bunch of print statements (trying to see where it freezes and what the cy_rslt is) but for some reason none of them show up in the serial monitor (although previous ones do).

The mtb_model_init function returns success, although it won't print to the serial monitor until the button is pressed (which is a little strange), so not sure if that may be relevant to the problem.

I'm not sure exactly what the problem could be or what strategies would be useful to try and debug it, as I'm pretty new to ModusToolbox. The log files I see are only for loading the ML models in, and am unsure what the source of the problem could be.

I think it might take a thorough look into the code to figure out the problem, and this is part of a project due on 5/10. If someone is unable to look at it before then, then there is no rush, but I would still be curious as to what is going on.

Thank you!

** Also, I was unable to include the entire zip file (it was too large) but here is a link to the zip:

https://drive.google.com/file/d/1L4VVZGF-5iH7e-5ROv8F1C899Ri3Hfa-/view?usp=sharing

 

0 Likes
1 Solution
RodolfoGL
Employee
Employee
250 solutions authored 250 sign-ins 5 comments on KBA

Yes, your model is too big to fit to the internal PSoC memory. It seems you don't have enough SRAM, since the error shown states "Balloc". 

The model weights are stored by default on the flash, but it is loaded to the RAM on initialization. What you can do is to keep the model weights in the flash only. This would slow down the performance, but you might be able to run your model without needing to use a smaller model. If you are still not able to run, you can even place to the external flash.

Refer to the ML User Guide , page 11 on the bottom. It explains what you need to do.

View solution in original post

0 Likes
3 Replies
Rakshith
Moderator
Moderator
Moderator
250 likes received 1000 replies posted 750 replies posted

Hi @jasminewu

I was checking your main.c and I see that you have printf statements before the bsp_init. Prints to the serial terminal will work after cy_retarget_io_init().  Also, can you please check if retarget io init is successful? Once you confirm the return status you can print a line to confirm that the print statements are working. Can you also debug this project and check the call stack to see if the code is hitting a hard fault? 
I was unable to access the zip file. I have requested access to it.

Thanks and Regards,
Rakshith M B
0 Likes
lock attach
Attachments are accessible only for community members.
jasminewu
Level 1
Level 1
First reply posted 5 sign-ins First question asked

Hi @Rakshith,

Thanks for the quick response! I have also been doing some debugging and noticed that too.

I think I found the source of my problem - the model never actually initializes correctly. I get the following printout in the serial monitor. After seeing that, I changed the model resolution to the lowest (8x8), but am still getting the error. 

Does this mean the problem is just the model size? My model is 1400 KB, while the example has a 184KB model. I've already been trying to reduce the model size, but can try more if that seems to be the problem.

Here is the updated zip code file:

https://drive.google.com/file/d/1yj1sZ036JnqwBlo3S4fzHURWD87ePxCV/view?usp=sharing

 

0 Likes
RodolfoGL
Employee
Employee
250 solutions authored 250 sign-ins 5 comments on KBA

Yes, your model is too big to fit to the internal PSoC memory. It seems you don't have enough SRAM, since the error shown states "Balloc". 

The model weights are stored by default on the flash, but it is loaded to the RAM on initialization. What you can do is to keep the model weights in the flash only. This would slow down the performance, but you might be able to run your model without needing to use a smaller model. If you are still not able to run, you can even place to the external flash.

Refer to the ML User Guide , page 11 on the bottom. It explains what you need to do.

0 Likes