f90 / Wave-U-Net

Implementation of the Wave-U-Net for audio source separation
MIT License
824 stars 177 forks source link

Error during evaluation: `pad_width` must be of integral type. #19

Closed martin-minovski closed 5 years ago

martin-minovski commented 5 years ago

Great project! Upon model evaluation, I am facing the following issue:

Pre-trained model restored for song prediction
ERROR - Waveunet Prediction - Failed after 0:00:11!
Traceback (most recent calls WITHOUT Sacred internals):
  File "/home/martin/Wave-U-Net/Predict.py", line 17, in main
    Evaluate.produce_source_estimates(model_config, model_path, input_path, output_path)
  File "/home/martin/Wave-U-Net/Evaluate.py", line 193, in produce_source_estimates
    sources_pred = predict(track, model_config, load_model) # Input track to prediction function, get source estimates
  File "/home/martin/Wave-U-Net/Evaluate.py", line 71, in predict
    separator_preds = predict_track(model_config, sess, mix_audio, orig_sr, sep_input_shape, sep_output_shape, separator_sources, mix_context)
  File "/home/martin/Wave-U-Net/Evaluate.py", line 138, in predict_track
    mix_audio_padded = np.pad(mix_audio, [(pad_time_frames, pad_time_frames), (0,0)], mode="constant", constant_values=0.0)
  File "/home/martin/anaconda3/envs/tf-gpu/lib/python3.6/site-packages/numpy/lib/arraypad.py", line 1197, in pad
    raise TypeError('`pad_width` must be of integral type.')
TypeError: `pad_width` must be of integral type.

Any thoughts on what might be the cause?

Thanks!

f90 commented 5 years ago

You are using Python 3.6, but the project requires Python 2.7. Please switch to Python 2.7, then your issue should be resolved.

If you really can't do that for some reason, you can try fixing this particular error by replacing

pad_time_frames = (input_time_frames - output_time_frames) / 2

in Evaluate.py with

pad_time_frames = (input_time_frames - output_time_frames) // 2

since Python 3 handles division differently than Python 2. No guarantees that this will make everything work though since you might encounter more issues along the way

martin-minovski commented 5 years ago

Both solutions worked like a charm - thanks!