MuggleWang / CosFace_pytorch

Pytorch implementation of CosFace
MIT License
242 stars 52 forks source link

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

Open zhoufengfan opened 2 years ago

zhoufengfan commented 2 years ago

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.

jingyig01 commented 2 years ago

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 .

wy321-wh48 commented 2 years ago

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

tyrink commented 2 years ago

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?