SDM
SDM copied to clipboard
TypeError: slice indices must be integers or None or have an __index__ method
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
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.
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!