Win10下mmpose中test.py出现OverflowError: Python int too large to convert to C long

在win10下想测试mmpose的环境,选择Res50在coco上跑。结果出现了如下bug

OverflowError: Python int too large to convert to C long
. . .
[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 104125/104125, 222.9 task/s, elapsed: 467s, ETA: 0sLoading and preparing results...
DONE (t=3.13s)
creating index...
index created!
Running per image evaluation...
Evaluate annotation type keypoints
Traceback (most recent call last):
File "tools\test.py", line 184, in
main()
File "tools\test.py", line 178, in main
results = dataset.evaluate(outputs, cfg.work_dir, **eval_config)
File "C:\Users\MyPC\Anaconda3\envs\mm\lib\site-packages\mmcv\utils\misc.py", line 330, in new_func
output = old_func(*args, **kwargs)
File "d:\mm\mmpose\mmpose\datasets\datasets\top_down\topdown_coco_dataset.py", line 326, in evaluate
info_str = self._do_python_keypoint_eval(res_file)
File "d:\mm\mmpose\mmpose\datasets\datasets\top_down\topdown_coco_dataset.py", line 389, in _do_python_keypoint_eval
coco_eval.evaluate()
File "C:\Users\MyPC\Anaconda3\envs\mm\lib\site-packages\xtcocotools\cocoeval.py", line 262, in evaluate
self.evalImgs = [evaluateImg(imgId, catId, areaRng, maxDet)
File "C:\Users\MyPC\Anaconda3\envs\mm\lib\site-packages\xtcocotools\cocoeval.py", line 262, in
self.evalImgs = [evaluateImg(imgId, catId, areaRng, maxDet)
File "C:\Users\MyPC\Anaconda3\envs\mm\lib\site-packages\xtcocotools\cocoeval.py", line 456, in evaluateImg
dtm[tind, dind] = gt[m]['id']
OverflowError: Python int too large to convert to C long

根据报错知道应该是python里变量转换到C出现溢出,然而尝试看了两天的cocoeval.py无奈不知道如何debug。

于是试图重装环境以及更换mmcv-full版本修复,无果后上gayhub提了issue得到了liqikai9的帮助。

问题出现的原因:应该是不同平台下(linux、win)dtype精度有差异,应该是在linux中测试正常,windows下会有bug。

解决办法:进入对应路径的cocoeval.py文件,在第428行左右如下修改:

#此处代码大约在428行,要修改的是下面的注释两行改为新的两行
        T = len(p.iouThrs)
        G = len(gt)
        D = len(dt)
        # gtm = np.ones((T, G), dtype=int) * -1 #win下有bug
        # dtm = np.ones((T, D), dtype=int) * -1 #win下有bug
        gtm = np.ones((T, G), dtype=np.int64) * -1 #适合windows版本
        dtm = np.ones((T, D), dtype=np.int64) * -1 #适合windows版本
        gtIg = np.array([g['_ignore'] for g in gt])
        dtIg = np.zeros((T,D))
        if len(ious):

即可修复此error

 

posted @ 2022-08-12 15:42  llllrj  阅读(570)  评论(0编辑  收藏  举报