deezer / spleeter

Deezer source separation library including pretrained models.
https://research.deezer.com/projects/spleeter.html
MIT License
25.72k stars 2.82k forks source link

[Bug] NotImplementedError when running Docker `deezer/spleeter:conda` #585

Open niekvb opened 3 years ago

niekvb commented 3 years ago

Description

When running docker image deezer/spleeter:conda I encounter a NotImplementedError when trying to seperate an audio file.

Step to reproduce

  1. Executed the following command: docker run -v $(pwd)/output:/output -v $(pwd)/input:/input deezer/spleeter:conda separate -o /output /input/audio_example.mp3

Output

Traceback (most recent call last):
  File "/opt/conda/bin/spleeter", line 11, in <module>
    sys.exit(entrypoint())
  File "/opt/conda/lib/python3.7/site-packages/spleeter/__main__.py", line 250, in entrypoint
    spleeter()
  File "/opt/conda/lib/python3.7/site-packages/typer/main.py", line 214, in __call__
    return get_command(self)(*args, **kwargs)
  File "/opt/conda/lib/python3.7/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/opt/conda/lib/python3.7/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/opt/conda/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/opt/conda/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/conda/lib/python3.7/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/opt/conda/lib/python3.7/site-packages/typer/main.py", line 497, in wrapper
    return callback(**use_params)  # type: ignore
  File "/opt/conda/lib/python3.7/site-packages/spleeter/__main__.py", line 131, in separate
    synchronous=False,
  File "/opt/conda/lib/python3.7/site-packages/spleeter/separator.py", line 382, in separate_to_file
    sources = self.separate(waveform, audio_descriptor)
  File "/opt/conda/lib/python3.7/site-packages/spleeter/separator.py", line 325, in separate
    return self._separate_librosa(waveform, audio_descriptor)
  File "/opt/conda/lib/python3.7/site-packages/spleeter/separator.py", line 263, in _separate_librosa
    outputs = self._get_builder().outputs
  File "/opt/conda/lib/python3.7/site-packages/spleeter/model/__init__.py", line 318, in outputs
    self._build_outputs()
  File "/opt/conda/lib/python3.7/site-packages/spleeter/model/__init__.py", line 501, in _build_outputs
    self._outputs = self.masked_stfts
  File "/opt/conda/lib/python3.7/site-packages/spleeter/model/__init__.py", line 342, in masked_stfts
    self._build_masked_stfts()
  File "/opt/conda/lib/python3.7/site-packages/spleeter/model/__init__.py", line 465, in _build_masked_stfts
    for instrument, mask in self.masks.items():
  File "/opt/conda/lib/python3.7/site-packages/spleeter/model/__init__.py", line 336, in masks
    self._build_masks()
  File "/opt/conda/lib/python3.7/site-packages/spleeter/model/__init__.py", line 449, in _build_masks
    instrument_mask = self._extend_mask(instrument_mask)
  File "/opt/conda/lib/python3.7/site-packages/spleeter/model/__init__.py", line 420, in _extend_mask
    extension_row = tf.zeros((mask_shape[0], mask_shape[1], 1, mask_shape[-1]))
  File "/opt/conda/lib/python3.7/site-packages/tensorflow/python/util/dispatch.py", line 201, in wrapper
    return target(*args, **kwargs)
  File "/opt/conda/lib/python3.7/site-packages/tensorflow/python/ops/array_ops.py", line 2747, in wrapped
    tensor = fun(*args, **kwargs)
  File "/opt/conda/lib/python3.7/site-packages/tensorflow/python/ops/array_ops.py", line 2794, in zeros
    output = _constant_if_small(zero, shape, dtype, name)
  File "/opt/conda/lib/python3.7/site-packages/tensorflow/python/ops/array_ops.py", line 2732, in _constant_if_small
    if np.prod(shape) < 1000:
  File "<__array_function__ internals>", line 6, in prod
  File "/opt/conda/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 3031, in prod
    keepdims=keepdims, initial=initial, where=where)
  File "/opt/conda/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 87, in _wrapreduction
    return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
  File "/opt/conda/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 848, in __array__
    " a NumPy call, which is not supported".format(self.name))
NotImplementedError: Cannot convert a symbolic Tensor (strided_slice_4:0) to a numpy array. This error may indicate that you're trying to pass a Tensor to a NumPy call, which is not supported

Environment

OS Linux
Installation type Docker
RAM available 4GB
Hardware spec N/A
nj-vs-vh commented 3 years ago

I get the exact same error running spleeter separate ... in conda-installed Spleeter on Windows machine.

romi1502 commented 3 years ago

Hi @niekvb, thank you for reporting this issue. Indeed there seems to have an issue which seems to be linked to an incompatibility between tensorflow and numpy versions (as mentioned in this SO post).

We'll investigate the issue. In the meantime, a workaround is to downgrade numpy to 1.18.5:

pip install -U numpy==1.18.5

Note that this is the numpy version that will be used by pip when installing spleeter through pip, so you can also upgrade spleeter with pip:

pip install -U spleeter
risicle commented 3 years ago

FWIW I suspect the fix for this is https://github.com/tensorflow/tensorflow/pull/47957.