madebyollin / acapellabot

Acapella Extraction with a ConvNet
http://madebyoll.in/posts/cnn_acapella_extraction/
205 stars 44 forks source link

Indexing elements must be in increasing order #1

Open minghigh opened 7 years ago

minghigh commented 7 years ago

when I run the following code (demo.mp3 is my example music)

python acapellabot.py demo.mp3

got errors :

Traceback (most recent call last):
  File "C:\Program Files\Anaconda3\lib\site-packages\h5py\_hl\selections.py", line 85, in select
    int(a)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'list'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "acapellabot.py", line 148, in <module>
    acapellabot.loadWeights(args.weights)
  File "acapellabot.py", line 88, in loadWeights
    self.model.load_weights(path)
  File "C:\Program Files\Anaconda3\lib\site-packages\keras\engine\topology.py", line 2500, in load_weights
    load_weights_from_hdf5_group(f, self.layers)
  File "C:\Program Files\Anaconda3\lib\site-packages\keras\engine\topology.py", line 2900, in load_weights_from_hdf5_group
    original_backend)
  File "C:\Program Files\Anaconda3\lib\site-packages\keras\engine\topology.py", line 2841, in preprocess_weights_for_loading
    weights[0] = conv_utils.convert_kernel(weights[0])
  File "C:\Program Files\Anaconda3\lib\site-packages\keras\utils\conv_utils.py", line 86, in convert_kernel
    return np.copy(kernel[slices])
  File "h5py\_objects.pyx", line 54, in h5py._objects.with_phil.wrapper (C:\Minonda\conda-bld\h5py_1474482825505\work\h5py\_objects.c:2705)
  File "h5py\_objects.pyx", line 55, in h5py._objects.with_phil.wrapper (C:\Minonda\conda-bld\h5py_1474482825505\work\h5py\_objects.c:2663)
  File "C:\Program Files\Anaconda3\lib\site-packages\h5py\_hl\dataset.py", line 462, in __getitem__
    selection = sel.select(self.shape, args, dsid=self.id)
  File "C:\Program Files\Anaconda3\lib\site-packages\h5py\_hl\selections.py", line 88, in select
    sel[args]
  File "C:\Program Files\Anaconda3\lib\site-packages\h5py\_hl\selections.py", line 356, in __getitem__
    if sorted(arg) != list(arg):
TypeError: unorderable types: NoneType() < int()

My environment as following:

  1. python : 3.5.2
  2. Tensorflow : 1.1.0
  3. Keras : 2.0.3
  4. librosa : 0.50
  5. h5py : 2.6.0

In Window 10.

pedrohml commented 7 years ago

Hi there, I am facing a similar problem when loading weights file: TypeError: Indexing elements must be in increasing order

This error seems to have the same cause as above. I am using same libraries set of @minghigh, but running on mac.

madebyollin commented 7 years ago

Thanks for pointing this out!

The weights were saved from Theano 0.9.0 using the 'tf' dim ordering–it looks like they don't work with the TensorFlow backend (tested on CentOS 7.3 with both TF/Theano installed and the packages you listed; tf backend gives the same unorderable types error, but Theano works).

I'll see if I can figure out a way to make the weights interoperable (assuming that this is some sort of configuration mistake on my end). In the meantime, switching to Theano should hopefully resolve the issue (don't forget to change ~/.keras/keras.json):

{
    "backend": "theano",
    "image_dim_ordering": "tf"
}
arlose commented 7 years ago

I have the same problem $ python acapellabot.py test.mp3 Using TensorFlow backend. ('\x1b[33m', 'Model has 668225 params', '\x1b[0m') ('\x1b[33m', "Weights provided; performing inference on ['test.mp3']...", '\x1b[0m') ('\x1b[1m', 'Loading weights', '\x1b[0m') Traceback (most recent call last): File "acapellabot.py", line 145, in acapellabot.loadWeights(args.weights) File "acapellabot.py", line 88, in loadWeights self.model.load_weights(path) File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 2500, in load_weights load_weights_from_hdf5_group(f, self.layers) File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 2900, in load_weights_from_hdf5_group original_backend) File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 2841, in preprocess_weights_for_loading weights[0] = conv_utils.convert_kernel(weights[0]) File "/usr/local/lib/python2.7/dist-packages/keras/utils/conv_utils.py", line 86, in convert_kernel return np.copy(kernel[slices]) File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper (/tmp/pip_build_root/h5py/h5py/_objects.c:2840) File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper (/tmp/pip_build_root/h5py/h5py/_objects.c:2798) File "/usr/local/lib/python2.7/dist-packages/h5py/_hl/dataset.py", line 474, in getitem selection = sel.select(self.shape, args, dsid=self.id) File "/usr/local/lib/python2.7/dist-packages/h5py/_hl/selections.py", line 90, in select sel[args] File "/usr/local/lib/python2.7/dist-packages/h5py/_hl/selections.py", line 361, in getitem raise TypeError("Indexing elements must be in increasing order") TypeError: Indexing elements must be in increasing order

My environment as following: ubuntu 14.04 Python 2.7.6 tensorflow (1.0.1) tensorflow-gpu (1.0.1) Keras (2.0.3) h5py (2.7.0) librosa (0.5.0)

I change the backend to theano but have the new problem:

File "acapellabot.py", line 130, in acapellabot = AcapellaBot() File "acapellabot.py", line 30, in init convA = Conv2D(64, 3, activation='relu', padding='same')(mashup) File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 551, in call self.build(input_shapes[0]) File "/usr/local/lib/python2.7/dist-packages/keras/layers/convolutional.py", line 125, in build raise ValueError('The channel dimension of the inputs ' ValueError: The channel dimension of the inputs should be defined. Found None.

madebyollin commented 7 years ago

@arlose Regarding the "channel dimension of the inputs should be defined. Found None." issue–You're probably using the th dimension ordering; the trained weights were saved in tf ordering. Could you try opening ~/keras/keras.json and specifying tf ordering:

{
    "backend": "theano",
    "image_dim_ordering": "tf"
}

I think there's a way to set the ordering in the script itself, so I'll see if I can do that to save people some trouble in the future.

madebyollin commented 7 years ago

@arlose Also, are you running python 3? From the printout it looks like you're using python 2, but it won't work in python 2 without some adjustments (the issue you're getting there is because of the change in behavior of the division operator, you could probably fix it with some calls to round())

arlose commented 7 years ago

@madebyollin thanks i just resolved it

mktanguturi commented 7 years ago

Hi @madebyollin , Is this issue resolved with Tensorflow backend? Or still we need to use Theano backend?

Kindly confirm.

Thanks