AstarLight / CPS-OCR-Engine

An awesome OCR engine developed by SYSU DeepDriving Lab
1.08k stars 512 forks source link

label_dict = pickle.load(f) 异常退出 #20

Open merria28 opened 6 years ago

merria28 commented 6 years ago

def get_label_dict(): f = open('./chinese_labels', 'r') label_dict = pickle.load(f)

label_dict = str.encode(pickle.load(f))

f.close()
return label_dict

提示下面的错误: Traceback (most recent call last): File "F:/OCR/CPS-OCR-Engine-master/ocr/Chinese_OCR.py", line 411, in tf.app.run() File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\platform\app.py", line 125, in run _sys.exit(main(argv)) File "F:/OCR/CPS-OCR-Engine-master/ocr/Chinese_OCR.py", line 390, in main label_dict = get_label_dict() File "F:/OCR/CPS-OCR-Engine-master/ocr/Chinese_OCR.py", line 335, in get_label_dict label_dict = pickle.load(f) TypeError: a bytes-like object is required, not 'str'

这个该怎么改?

liukboy commented 6 years ago

同问,自己也遇到这个错误,请问您解决了吗

AziCat commented 6 years ago

改成 f = open('./chinese_labels', 'rb') 试试

bigbigxing823 commented 6 years ago

如果用的python3,可以修改如下: f = open('./chinese_labels', 'rb') label_dict = pickle.load(f, encoding=''utf-8'')

liukboy commented 6 years ago

@AziCat @Chen823 谢谢你们,我也是这么做的,非常感谢

wengbenjue commented 5 years ago

我改了是不行的

wengbenjue commented 5 years ago

label_dict = pickle.load(f, encoding="utf-8") EOFError: Ran out of input 这是错误信息

kay226 commented 5 years ago
with open('./chinese_labels', 'r') as data_file:
    label_dict = pickle.load(StrToBytes(data_file))