使用的代碼為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以上已經(jīng)沒有commands模塊了,使用subprocess代替commands
報錯:
File "XXX/PSENet-master/dataset/icdar2015_loader.py", line 12, in <module>? 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函數(shù),將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 <listcomp>
? ? 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')