SDM icon indicating copy to clipboard operation
SDM copied to clipboard

TypeError: slice indices must be integers or None or have an __index__ method

Open Quevi opened this issue 4 years ago • 2 comments

Here is what I got. Anyone encountered the same problem?

Traceback (most recent call last):
  File "/Users/quqi/SDM/main.py", line 424, in <module>
    R,B,I = train(parameters)
  File "/Users/quqi/SDM/main.py", line 88, in train
    hog_list.append(hog(grey,mark,parameters))
  File "/Users/quqi/SDM/main.py", line 390, in hog
    orientation_histogram[j,:,:,i] = uniform_filter(temp_mag, size=pc)[x-r+pc/2:x+r:pc, y-r+pc/2:y+r:pc].T
TypeError: slice indices must be integers or None or have an __index__ method

Quevi avatar May 07 '20 03:05 Quevi

It turns out that within the line orientation_histogram[j,:,:,i] = uniform_filter(temp_mag, size=pc)[x-r+pc/2:x+r:pc, y-r+pc/2:y+r:pc].T, indices x-r+pc/2 and y-r+pc/2 are float number rather than integer. But I wonder why the author Ning-Ding didn't encounter this bug.

Quevi avatar May 07 '20 07:05 Quevi

I encounter this bug a minute ago. I found the difference between python2 and python3 when it comes to integer division.Do as what I do if you use python3 too! image

2226415223 avatar Oct 09 '22 13:10 2226415223