ina-foss / inaSpeechSegmenter

CNN-based audio segmentation toolkit. Allows to detect speech, music, noise and speaker gender. Has been designed for large scale gender equality studies based on speech time per gender.
MIT License
736 stars 126 forks source link

Invalid input shape for input Tensor #82

Closed frankenjoe closed 6 months ago

frankenjoe commented 6 months ago

Unit tests fails with:

Invalid input shape for input Tensor("data:0", shape=(32, 68, 21), dtype=float32). Expected shape (None, None, 68, 21), but input has incompatible shape (32, 68, 21)

System information

Expected Behavior

Unit tests pass.

Current Behavior

Some of the tests fail due to a incompatible shape, e.g.:

batch_processing 1 files
1/1 [('/tmp/tmpaijglfr4/0021.csv', 0, 'ok')]
Traceback (most recent call last):
  File ".../inaSpeechSegmenter/./scripts/ina_speech_segmenter.py", line 80, in <module>
    seg.batch_process(input_files, output_files, verbose=True, output_format=args.export_format)
  File ".../inaSpeechSegmenter/inaSpeechSegmenter/segmenter.py", line 325, in batch_process
    lseg = self.segment_feats(mspec, loge, difflen, 0)
  File ".../inaSpeechSegmenter/inaSpeechSegmenter/segmenter.py", line 268, in segment_feats
    lseg = self.vad(mspec, lseg, difflen)
  File ".../inaSpeechSegmenter/inaSpeechSegmenter/segmenter.py", line 162, in __call__
    rawpred = self.nn.predict(batch, batch_size=self.batch_size, verbose=2)
  File ".../inaSpeechSegmenter/.venv/lib/python3.10/site-packages/keras/src/utils/traceback_utils.py", line 123, in error_handler
    raise e.with_traceback(filtered_tb) from None
  File ".../inaSpeechSegmenter/.venv/lib/python3.10/site-packages/keras/src/models/functional.py", line 274, in _adjust_input_rank
    raise ValueError(
ValueError: Exception encountered when calling Sequential.call().

Invalid input shape for input Tensor("data:0", shape=(32, 68, 21), dtype=float32). Expected shape (None, None, 68, 21), but input has incompatible shape (32, 68, 21)

Arguments received by Sequential.call():
  • inputs=tf.Tensor(shape=(32, 68, 21), dtype=float32)
  • training=False
  • mask=None
FAIL

Steps to Reproduce

Install from sources, then run unit tests:

$ python setup.py test
DavidDoukhan commented 6 months ago

Dear @frankenjoe , I currently don't manage to reproduce the bug using python 3.8.10 and tensorflow 2.13.1 Before deeper investigations, could you try to reproduce this bug downgrading tensorflow to version 2.13.1 ?

DavidDoukhan commented 6 months ago

I just managed to reproduce the bug using tensorflow==2.16.1 and python==3.9.5 So it seems the bug is related with tensorflow recent changes Some time may be required to fix it : python 3.8.10 do not provide tensorflow > 2.13.1 in its default pip packages and I will need to find a fix working correctly for these different configurations. Pull request are welcome for helping me fixing this issue :-)

frankenjoe commented 6 months ago

Thanks for the quick reply. I can confirm that downgrading tensorflow to 2.13.1 solves the issues.

DavidDoukhan commented 6 months ago

The code has been updated to work with tensorflow 2.16.1 The package has also been updated on pypi (version 0.7.8) Please let me know if this new package works fine on your computer. Kind regards,

frankenjoe commented 6 months ago

Yes, I can confirm that it works now as expected. Thanks a lot for your support.