CosFace_pytorch icon indicating copy to clipboard operation
CosFace_pytorch copied to clipboard

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

Open zhoufengfan opened this issue 3 years ago • 3 comments

After I run lfw_eval.py, there occurred this error:

Traceback (most recent call last):
  File "lfw_eval.py", line 122, in <module>
    _, result = eval(net.sphere().to('cuda'), model_path='checkpoint/CosFace_24_checkpoint.pth')
  File "lfw_eval.py", line 109, in eval
    folds = KFold(n=6000, n_folds=10)
  File "lfw_eval.py", line 38, in KFold
    test = base[i * n / n_folds:(i + 1) * n / n_folds]
TypeError: slice indices must be integers or None or have an __index__ method

I found that if I run the KFold() solely, there still occurs this error.

zhoufengfan avatar Dec 25 '21 09:12 zhoufengfan

This error may due to the difference of python 2 and 3. Please modify test = base[i * n / n_folds:(i + 1) * n / n_folds] to test = base[int(i * n / n_folds) : int((i + 1) * n / n_folds)]

In addition, you might come accross the 'best_thresh = find_best_threshold(thresholds, predicts[train]) IndexError: too many indices for array' error. In this situation, please refer predicts[train] Error .

jingyig01 avatar Dec 29 '21 07:12 jingyig01

test = base[int(i * n / n_folds):int((i + 1) * n / n_folds)]改成这样可以

wy321-wh48 avatar Jan 06 '22 01:01 wy321-wh48

After I run lfw_eval.py, there occurred this error:

Traceback (most recent call last):
  File "lfw_eval.py", line 122, in <module>
    _, result = eval(net.sphere().to('cuda'), model_path='checkpoint/CosFace_24_checkpoint.pth')
  File "lfw_eval.py", line 109, in eval
    folds = KFold(n=6000, n_folds=10)
  File "lfw_eval.py", line 38, in KFold
    test = base[i * n / n_folds:(i + 1) * n / n_folds]
TypeError: slice indices must be integers or None or have an __index__ method

I found that if I run the KFold() solely, there still occurs this error.

Hi, I just found the ACC99.2.pth for pretrained model, but got bad performance. Can you share the download link of the CosFace_24_checkpoint.pth?

tyrink avatar Jun 07 '22 08:06 tyrink