PSENet踩坑记录

使用的代码为PSENet的pytorch版,代码地址:https://github.com/whai362/PSENet

报错:ModuleNotFoundError: No module named 'cPickle'    打开/PSENet-master/util/io_.py,将import cPickle as pkl的CPickle改为pickle

报错:ModuleNotFoundError: No module named 'commands'     commands是python2版本里的,在python3.0以上已经没有commands模块了,使用subprocess代替commands

报错:

File "XXX/PSENet-master/dataset/icdar2015_loader.py", line 12, in   import Polygon as plg

ModuleNotFoundError: No module named 'Polygon'     

安装polygon  :pip install Polygon3

报错:ValueError: invalid literal for int() with base 10: '\ufeff232'     打开PSENet-master/util/io_.py,找到read_lines函数,将f = open(p,'r')改为f = open(p,'r',encoding='utf-8-sig')

报错:

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "/home/zhangmingzhou1/anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/utils/data/_utils/worker.py", line 178, in _worker_loop

    data = fetcher.fetch(index)

  File "/home/zhangmingzhou1/anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch

    data = [self.dataset[idx] for idx in possibly_batched_index]

  File "/home/zhangmingzhou1/anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in

    data = [self.dataset[idx] for idx in possibly_batched_index]

  File "/home/zhangmingzhou1/PSENet-master/dataset/icdar2015_loader.py", line 196, in __getitem__

    bboxes = np.reshape(bboxes * ([img.shape[1], img.shape[0]] * 4), (bboxes.shape[0], bboxes.shape[1] / 2, 2)).astype('int32')

  File "<__array_function__ internals>", line 6, in reshape

  File "/home/zhangmingzhou1/anaconda3/envs/pytorch/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 299, in reshape

    return _wrapfunc(a, 'reshape', newshape, order=order)

  File "/home/zhangmingzhou1/anaconda3/envs/pytorch/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 67, in _wrapfunc

    return _wrapit(obj, method, *args, **kwds)

  File "/home/zhangmingzhou1/anaconda3/envs/pytorch/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 44, in _wrapit

    result = getattr(asarray(obj), method)(*args, **kwds)

TypeError: 'float' object cannot be interpreted as an integer

找到代码icdar2015_loader.py中的下段,“/”改为“//”,如下所示:

bboxes = np.reshape(bboxes * ([img.shape[1], img.shape[0]] * 4), (bboxes.shape[0], bboxes.shape[1] // 2, 2)).astype('int32')

你可能感兴趣的:(PSENet踩坑记录)