bmsasilva/soundClass

Error message when trying to create training data with app_model()

Closed this issue · 5 comments

I am probably missing a key detail here, but I am getting an error message when I try to create the training data with the shiny app.

I created my own labels with app_label() on a subset of example recordings and stored them in the sqlite database. When I select them and the database for training, this error message is returned:

Error in spec_df[k, ] <- as.numeric(r(spec)) :
number of items to replace is not a multiple of replacement length
[1] "recording 1 of 12"
Error in spec_df[k, ] <- as.numeric(r(spec)) :
number of items to replace is not a multiple of replacement length
[1] "recording 2 of 12"
.
.
.

[1] "recording 12 of 12"
Warning: Error in data.frame: arguments imply differing number of rows: 0, 2
149: stop
148: data.frame
147: data_keras
146: spectro_calls
145: eventReactiveValueFunc
101: spec_calls
99: renderTable
98: func
85: renderFunc
84: output$spec
3: runApp
2: print.shiny.appobj
1:

Any help would be much appreciated! Thank you.

Hi @johannesnelson johannesnelson,
can you please share the training parameters you are using?

Sure.

When creating the training data labels with app_label(), I had the spectrogram parameters set to:

Threshold: 100dB
Window length: 4ms
Overlap: 50%
Resolution: Low

For the app_model() settings:

Time expanded: 1
Size (ms): 20
Moving window (ms): 1
Overlap: 50%
Resolution: Low
Threshold: 100dB
No filter on frequency

I tried a couple combinations (to make the window size match the window length, etc. but none seem to be working out for me. I think it might be something I just am missing on my end, so if you could help point me in the right direction, that would be great!

I believe that the problem is in the "Time expanded" parameter. The bat example data is composed of recordings with 1x and 10x which requires this parameter to be set to "auto". (I've tested with the example .sqlite and I encounter the same error if the time expanded is not set to "auto").

Additionally it is necessary to define the filter on frequency or you will get another error (for the example recordings I suggest 10 and 120). This is because the filter is used to standardize the size of the spectrograms, as required by CNN's.

Hope all goes well this time. If not please let me know.

That helped, thank you! I am looking forward to tinkering with this app to see if it can help me with my research.

Glad to help. You can check the paper of the package here: https://www.researchgate.net/publication/363095066_soundClass_An_automatic_sound_classification_tool_for_biodiversity_monitoring_using_machine_learning

If you need further assistance, you can message me via researchgate or send an email (I'm the corresponding author)

Best
Bruno