label_dict = pickle.load(f) 异常退出
merria28 opened this issue · 7 comments
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'
这个该怎么改?
同问,自己也遇到这个错误,请问您解决了吗
改成 f = open('./chinese_labels', 'rb') 试试
如果用的python3,可以修改如下:
f = open('./chinese_labels', 'rb')
label_dict = pickle.load(f, encoding=''utf-8'')
我改了是不行的
label_dict = pickle.load(f, encoding="utf-8")
EOFError: Ran out of input
这是错误信息
with open('./chinese_labels', 'r') as data_file:
label_dict = pickle.load(StrToBytes(data_file))