DeepFilterNet icon indicating copy to clipboard operation
DeepFilterNet copied to clipboard

Error: thread 'main' panicked

Open dgoryeo opened this issue 3 years ago • 5 comments

I get the following error message when attempting to run the latest win-64 exe [windows 11]:

thread 'main' panicked at 'called Option::unwrap() on a None value', libDF\src\tract.rs:365:28 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

Any idea how to tackle this? Thanks.

dgoryeo avatar Jan 14 '23 01:01 dgoryeo

Same error seen on latest deep-filter-v0.4.0-aarch64-apple-darwin binary.

recursionbane avatar Jan 16 '23 22:01 recursionbane

Hm not sure why there is an error. It seems like that the input noisy array is not contiguous, resulting in an error at unwrap here: https://github.com/Rikorose/DeepFilterNet/blob/v0.4.0/libDF/src/tract.rs#L365

Rikorose avatar Jan 18 '23 07:01 Rikorose

i just found that wav file's hz was creating issue, after exporting file at 44.1khz ffmpeg -i audio_in.wav -ar 441000 audio-out.wav now i can run deep-filter on "audio-out.wav"

surinder83singh avatar Mar 05 '23 21:03 surinder83singh

Short version for ASAP solution without changing sample rate:

  1. Install python, I tested python 3.10 on win10
  2. Install v1.13.1 torch and torchaudio (NOT 2.0.0) with appropriate method (pip install worked for me) from https://pytorch.org/get-started/previous-versions/
  3. pip install deepfilternet
  4. pip install soundfile
  5. This python script will work, run in appropriate environment like python myscript.py:
from df.enhance import enhance, init_df, load_audio, save_audio

audio_path = f'c:/convert_from/1.wav'
output_path = f'c:/convert_to/1_enhanced.wav'
if __name__ == "__main__":
    # Load default model
    model, df_state, _ = init_df(config_allow_defaults=True)
    # Download and open some audio file. You use your audio files here
    audio, _ = load_audio(audio_path, sr=df_state.sr())
    # Denoise the audio
    enhanced = enhance(model, df_state, audio)
    # Save for listening
    save_audio(output_path, enhanced, df_state.sr())

https://pytorch.org/get-started/previous-versions/

Long version: I'm getting same error, is that 441000 number in comment above is 441kHz, not 44.1kHz? And there is text in library description about 48kHz only supporting. How's that work? (well, I tested and it work, also converting file to mono).

Here is wav (358488 bytes): https://sndup.net/v2sb/

C:\convert_from\2023-05-14>deep-filter-v0.4.0-x86_64-pc-windows-msvc.exe Untitled_corr.wav
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', libDF\src\tract.rs:365:28
stack backtrace:
   0:     0x7ff6e7965410 - <unknown>
   1:     0x7ff6e77d846b - <unknown>
   2:     0x7ff6e7958db1 - <unknown>
   3:     0x7ff6e79670e1 - <unknown>
   4:     0x7ff6e7967767 - <unknown>
   5:     0x7ff6e79675a3 - <unknown>
   6:     0x7ff6e796751f - <unknown>
   7:     0x7ff6e79674f4 - <unknown>
   8:     0x7ff6e8573b85 - <unknown>
   9:     0x7ff6e8573c7c - <unknown>
  10:     0x7ff6e7839297 - <unknown>
  11:     0x7ff6e775f6be - <unknown>
  12:     0x7ff6e77ec706 - <unknown>
  13:     0x7ff6e777492d - <unknown>
  14:     0x7ff6e85726cc - <unknown>
  15:     0x7ffd4b817614 - BaseThreadInitThunk
  16:     0x7ffd4c8026a1 - RtlUserThreadStart

Not sure, will it be help, but then I tried running from python script: installing older versions of torch and torchaudio (like torch 1.13.1 torchaudio 0.13.1) and reinstalling deepfilternet without commenting that from torch._six import string_classes (was done so it starts to work with torch/torchaudio 2.0). https://pytorch.org/get-started/previous-versions/

If I run with python 3.11 pip install torch==2.0.0+cu118 torchvision==0.15.1+cu117 torchaudio==2.0.1 --index-url https://download.pytorch.org/whl/cu118, with commented out from torch._six import string_classes for different sample rate looks like it just resamples from 44100 to 48000 (I've tested also other resampling rates) and somehow it starts to be good for it (and this also works with deep-filter-v0.4.0-x86_64-pc-windows-msvc.exe, so that's why I'm telling here about running from python, maybe it's resembling somehow):

2023-05-15 11:13:14 | INFO     | DF | Running on torch 2.0.1+cu118
fatal: not a git repository (or any of the parent directories): .git
2023-05-15 11:13:14 | INFO     | DF | Loading model settings of DeepFilterNet2
2023-05-15 11:13:14 | INFO     | DF | Using DeepFilterNet2 model at ..\Users\i\miniconda3\envs\yu\Lib\site-packages\pretrained_models\DeepFilterNet2
2023-05-15 11:13:14 | INFO     | DF | Initializing model `deepfilternet2`
2023-05-15 11:13:16 | INFO     | DF | Found checkpoint ..\Users\i\miniconda3\envs\yu\Lib\site-packages\pretrained_models\DeepFilterNet2\checkpoints\model_96.ckpt.best with epoch 96
2023-05-15 11:13:16 | WARNING  | DF | Unexpected key: erb_comp.c
2023-05-15 11:13:16 | WARNING  | DF | Unexpected key: erb_comp.mn
2023-05-15 11:13:16 | INFO     | DF | Model loaded
2023-05-15 11:13:16 | WARNING  | DF | Audio sampling rate does not match model sampling rate (44100, 48000). Resampling...
C:\Users\i\miniconda3\envs\yu\Lib\site-packages\torchaudio\functional\functional.py:1458: UserWarning: "sinc_interpolation" resampling method name is being deprecated and replaced by "sinc_interp_hann" in the next release. The default behavior remains unchanged.

When trying to feed original file, I'm getting:

2023-05-15 11:28:57 | INFO     | DF | Running on torch 2.0.1+cu118
fatal: not a git repository (or any of the parent directories): .git
2023-05-15 11:28:57 | INFO     | DF | Loading model settings of DeepFilterNet2
2023-05-15 11:28:57 | INFO     | DF | Using DeepFilterNet2 model at ..\Users\i\miniconda3\envs\yu\Lib\site-packages\pretrained_models\DeepFilterNet2
2023-05-15 11:28:57 | INFO     | DF | Initializing model `deepfilternet2`
2023-05-15 11:28:59 | INFO     | DF | Found checkpoint ..\Users\i\miniconda3\envs\yu\Lib\site-packages\pretrained_models\DeepFilterNet2\checkpoints\model_96.ckpt.best with epoch 96
2023-05-15 11:28:59 | WARNING  | DF | Unexpected key: erb_comp.c
2023-05-15 11:28:59 | WARNING  | DF | Unexpected key: erb_comp.mn
2023-05-15 11:28:59 | INFO     | DF | Model loaded
Traceback (most recent call last):
  File "C:\Users\i\miniconda3\envs\yu\Lib\site-packages\torch\utils\_contextlib.py", line 115, in decorate_context
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\i\miniconda3\envs\yu\Lib\site-packages\df\enhance.py", line 242, in enhance
    spec, erb_feat, spec_feat = df_features(audio, df_state, nb_df, device=get_device())
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\i\miniconda3\envs\yu\Lib\site-packages\df\enhance.py", line 152, in df_features
    spec = df.analysis(audio.numpy())  # [C, Tf] -> [C, Tf, F]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: [df] Input array empty or not contiguous.
python-BaseException

After switching to python 3.10 and pip install torch==1.13.1+cu117 torchvision==0.14.1+cu117 torchaudio==0.13.1 --extra-index-url https://download.pytorch.org/whl/cu117 (there is no whl's for python 3.11 on win10 from older torch) and eliminating audio backend error with pip install soundfile and fixing ValueError: Value 'mask_only' not found in config (defaults not allowed). with model, df_state, _ = init_df(config_allow_defaults=True) it finally worked. So it seems just commenting out from torch._six import string_classes in hope of pip install torch==2.0.0+cu118 torchvision==0.15.1+cu117 torchaudio==2.0.1 will work breaks something.

yadalik avatar May 15 '23 09:05 yadalik

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 Aug 14 '23 02:08 github-actions[bot]