DeepFilterNet icon indicating copy to clipboard operation
DeepFilterNet copied to clipboard

How to reuse the model instance, in Python?

Open Mikkolehtimaki opened this issue 11 months ago • 1 comments

So calling init_df gives me the model and a state. If I want to make multiple calls to enhance, can I keep using the same state? Calling state.reset() does not seem to result in the same state as returned from init_df.

Mikkolehtimaki avatar Mar 12 '24 12:03 Mikkolehtimaki

[Caveat: this is what I think is happening, but I could be wrong.] When you create a new DFState, as returned from init_df, then memory for the frame analysis/synthesis (e.g., storing the part of the previous frame from the overlap) is zeroed and also the normalisation states for the spectrum and ERB spectrum will be initialised to specific values (the normalisations states are updated for each frame). When you call state.reset(), it resets the memory for the frame analysis/synthesis to zero, but it does not re-initialise the normalisations, which is why you see different results. If you are using a pre-used, but reset, state on independent audio, the fact that the normalisation was not reset can result is a short impulsive transient before the normalisation settles down and loses memory of the previous data that was passed through the state. (Note - you get a similar normalisation transient effect from a new state anyway as the normalisation starts at somewhat arbitrary values and takes a short time to see enough data to settle).

mattpitkin avatar Mar 19 '24 11:03 mattpitkin

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Jun 18 '24 02:06 github-actions[bot]