MTG / DeepConvSep

Deep Convolutional Neural Networks for Musical Source Separation
GNU Affero General Public License v3.0
472 stars 110 forks source link

Trying to get a version of DeepConvSep in Python3 #19

Closed sd12832 closed 6 years ago

sd12832 commented 6 years ago

Trying to make DeepConvSep work for Python3, on my mac, seemed like a pretty simple task at the beginning. However, I reached an impasse at the point described below:

When I run the program with this command...

python3 separate_dsd.py -i ./../../Ricotti\ \&\ Alburquerque\ -\ Dont\ You\ Believe\ Me.mp3 -o ./ -m ./../../model1.pkl

...I get the error NameError: name 'file' is not defined. file has been replaced with open within Python3.

Then I changed my code to:

def load_model(filename):
    with open(filename, 'rb') as f:
        return pickle.load(f)

However, I got the error:

Traceback (most recent call last):
  File "separate_dsd.py", line 336, in <module>
    main(sys.argv[1:])
  File "separate_dsd.py", line 333, in main
    train_auto(inputfile,outdir,model,0.3,30,25,32,513)
  File "separate_dsd.py", line 250, in train_auto
    params=load_model(model)
  File "separate_dsd.py", line 19, in load_model
    params=pickle.load(f)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xbb in position 2: ordinal not in range(128)

Is there something up with your pickler? Can you please take a look at this? I want to help make a Python3 version of this code. I would be glad to help you along with this task.

nkundiushuti commented 6 years ago

it's a known python3 pickle issue when loading pickled python2 files https://stackoverflow.com/questions/11305790/pickle-incompatibility-of-numpy-arrays-between-python-2-and-3

sd12832 commented 6 years ago
        u = pickle._Unpickler(f)
        u.encoding = 'latin1'
        p = u.load()
        return p

This is what I replaced the relevant code with.

I still got the error below:

Traceback (most recent call last):
  File "separate_dsd.py", line 336, in <module>
    main(sys.argv[1:])
  File "separate_dsd.py", line 333, in main
    train_auto(inputfile,outdir,model,0.3,30,25,32,513)
  File "separate_dsd.py", line 276, in train_auto
    sampleRate, audioObj = scipy.io.wavfile.read(filein)
  File "/usr/local/lib/python3.6/site-packages/scipy/io/wavfile.py", line 236, in read
    file_size, is_big_endian = _read_riff_chunk(fid)
  File "/usr/local/lib/python3.6/site-packages/scipy/io/wavfile.py", line 168, in _read_riff_chunk
    "understood.".format(repr(str1)))
ValueError: File format b'ID3\x04'... not understood.
sd12832 commented 6 years ago

I believe it's something to do with your encoding. What should I change the encoding to?

sd12832 commented 6 years ago

Wait a minute, the encoding was most definitely latin1. But I guess the extra mp3 tags are making the system fail. How would I solve this?

nkundiushuti commented 6 years ago

you can't use it with mp3. must be wav. otherwise you have to change the file loader to something that supports mp3 like soundfile

sd12832 commented 6 years ago

Yeah, it all works now! Thank you for all your help.

radkoff commented 6 years ago

Hey Sharan, if you could push the python3 changes to your fork (or submit it as a PR for a python3 branch of DeepConvSep), that would be awesome!

nkundiushuti commented 6 years ago

Yes! We can have a python3 branch maybe? You can do a pull request.

On Sat, Nov 17, 2018, 01:40 Evan Radkoff <notifications@github.com wrote:

Hey Sharan, if you could push the python3 changes to your fork (or submit it as a PR for a python3 branch of DeepConvSep), that would be awesome!

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/MTG/DeepConvSep/issues/19#issuecomment-439577004, or mute the thread https://github.com/notifications/unsubscribe-auth/ABJva1t0JKubwdZ2ZZ11wVS-VLLD6xLmks5uv2kQgaJpZM4SmJuj .

sd12832 commented 6 years ago

I'll get a Python3 branch up and running tomorrow or day after!

jcthink commented 5 years ago

loading pickle error is solved by this line params=pickle.load(f,encoding="latin1")

jcthink commented 5 years ago

Not able to read the wav file using scipy I am getting the error as ValueError: File format b'<!DO'... not understood.