worldveil / dejavu

Audio fingerprinting and recognition in Python
MIT License
6.36k stars 1.43k forks source link

TypeError: numpy boolean subtract, the `-` operator, is deprecated, use the bitwise_xor, the `^` operator, or the logical_xor function instead. #192

Closed zockerwurf closed 5 years ago

zockerwurf commented 5 years ago

Hi guys

When i run "python example.py" i get the following errors:

edward@edward-virtual-machine:~/dejavu$ python example.py
Fingerprinting channel 1/2 for mp3/Sean-Fournier--Falling-For-You.mp3
Fingerprinting channel 1/2 for mp3/The-Lights-Galaxia--While-She-Sleeps.mp3
Fingerprinting channel 1/2 for mp3/Brad-Sucks--Total-Breakdown.mp3
Failed fingerprinting
Traceback (most recent call last):
  File "/home/edward/dejavu/dejavu/__init__.py", line 77, in fingerprint_directory
    song_name, hashes, file_hash = iterator.next()
  File "/usr/lib/python2.7/multiprocessing/pool.py", line 673, in next
    raise value
TypeError: numpy boolean subtract, the `-` operator, is deprecated, use the bitwise_xor, the `^` operator, or the logical_xor function instead.
Fingerprinting channel 1/2 for mp3/Choc--Eigenvalue-Subspace-Decomposition.mp3
Failed fingerprinting
Traceback (most recent call last):
  File "/home/edward/dejavu/dejavu/__init__.py", line 77, in fingerprint_directory
    song_name, hashes, file_hash = iterator.next()
  File "/usr/lib/python2.7/multiprocessing/pool.py", line 673, in next
    raise value
MemoryError
Failed fingerprinting
Traceback (most recent call last):
  File "/home/edward/dejavu/dejavu/__init__.py", line 77, in fingerprint_directory
    song_name, hashes, file_hash = iterator.next()
  File "/usr/lib/python2.7/multiprocessing/pool.py", line 673, in next
    raise value
OSError: [Errno 12] Cannot allocate memory
Failed fingerprinting
Traceback (most recent call last):
  File "/home/edward/dejavu/dejavu/__init__.py", line 77, in fingerprint_directory
    song_name, hashes, file_hash = iterator.next()
  File "/usr/lib/python2.7/multiprocessing/pool.py", line 673, in next
    raise value
TypeError: numpy boolean subtract, the `-` operator, is deprecated, use the bitwise_xor, the `^` operator, or the logical_xor function instead.

What's wrong here?

NathanielCustom commented 5 years ago

The OSError tends to point toward not enough system memory. What are you running Dejavu on? You can try telling Dejavu to only run one process to limit the amount of memory it tries to use.

zockerwurf commented 5 years ago

The OSError tends to point toward not enough system memory. What are you running Dejavu on? You can try telling Dejavu to only run one process to limit the amount of memory it tries to use.

Thanks for your message. I'm running it on Ubuntu.

How to tell Dejavu to run only one process?

NathanielCustom commented 5 years ago

Sorry. I mean "what machine?" How much RAM does your system have? I run Dejavu on a Raspberry Pi and will run out of memory sometimes.

Multiprocessing is a supported keyword argument when calling the fingerprintdirectory function. I think you should find the function in the init _.py file.

WillPastor commented 5 years ago

@zockerwurf @NathanielCustom I fixed this problem by changing a single character in dejavu/fingerprint.py and it worked fine on my Ubuntu VirtualBox VM with about 8 GB memory. The code that needs to be changed is on line 104 of fingerprint.py ...

    # Boolean mask of arr2D with True at peaks
    detected_peaks = local_max - eroded_background

Needs to be changed to:

    # Boolean mask of arr2D with True at peaks
    detected_peaks = local_max ^ eroded_background

Side Note: I'm pretty new to Github, and this is my first contribution to someone else's repo, so I wasn't sure if I should push to a fork and submit a merge request with the fixed code, or if for such a small change a comment like this would be enough. I'd be interested to get an opinion on this since I'm still learning.

NathanielCustom commented 5 years ago

@WillPastor I never messed around with correcting the TypeError, maybe my fork has that already corrected. Good to know. I note that you actually addressed Zockerwurf's topic question...

What stood out to me was the OSError, Failed Fingerprinting as I believe that to be what is stopping him from successfully using Dejavu.

WillPastor commented 5 years ago

What stood out to me was the OSError, Failed Fingerprinting as I believe that to be what is stopping him from successfully using Dejavu.

@NathanielCustom This may also be a problem, although for me atleast, Dejavu could not successfully fingerprint anything until I replaced the deprecated operator, which allowed it to work, even though the error message I was getting prior to that mentioned other files, issues, etc. That said, RAM could still be an issue for him, although I would expect this to resolve everything else in his error message (I hope, at least), as it did for me. I'll try checking if it mentioned the OSError when I ran into this...