AlpacaTechJP/selectivesearch

will there be a new version for Python 3

darotchou opened this issue · 2 comments

Hi, I tried to use your code on Win10 Python 3 environment.
But it returned

Traceback (most recent call last):
File "sstest.py", line 43, in
main()
File "sstest.py", line 15, in main
img, scale=500, sigma=0.9, min_size=10)
File "D:\TFCNN\selectivesearch.py", line 274, in selective_search
neighbours = _extract_neighbours(R)
File "D:\TFCNN\selectivesearch.py", line 208, in _extract_neighbours
for cur, a in enumerate(R[:-1]):

in python 3, it seems I have to convert some region data to list and for sorted() function, cmp is no longer used in python 3.
Will there be a python 3 version selective search in near days?

Hey bro, you can change the file like this:
1、locate directory to your package: C:\Anaconda3\Lib\site-packages\selectivesearch
2、then open the file:"_init.py" and add "." behand selectivesearch like this: from .selectivesearch import selective_search # NOQA
3、open the file named "selectivesearch.py", and then import header: from functools import cmp_to_key
4、change the 206 lines like this: R = list(regions.items())
5、change the 289 lines like this: i, j = sorted(S.items(), key=cmp_to_key(lambda a, b: a[1]-b[1]))[-1][0]
Last: enjoy your work now!