未验证 提交 941869e6 编写于 作者: X xiaoting 提交者: GitHub

Revert "add encoding for open (#10769)" (#10789)

This reverts commit c1b943fb.
上级 c1b943fb
......@@ -118,7 +118,7 @@ class BaseRecLabelEncode(object):
self.lower = True
else:
self.character_str = []
with open(character_dict_path, "rb", encoding="utf-8") as fin:
with open(character_dict_path, "rb") as fin:
lines = fin.readlines()
for line in lines:
line = line.decode('utf-8').strip("\n").strip("\r\n")
......@@ -278,7 +278,7 @@ class KieLabelEncode(object):
char = line.strip()
self.dict[char] = idx
idx += 1
with open(class_path, "r", encoding="utf-8") as fin:
with open(class_path, "r") as fin:
lines = fin.readlines()
for idx, line in enumerate(lines):
line = line.strip("\n")
......@@ -640,7 +640,7 @@ class TableLabelEncode(AttnLabelEncode):
self.replace_empty_cell_token = replace_empty_cell_token
dict_character = []
with open(character_dict_path, "rb", encoding="utf-8") as fin:
with open(character_dict_path, "rb") as fin:
lines = fin.readlines()
for line in lines:
line = line.decode('utf-8').strip("\n").strip("\r\n")
......@@ -1380,7 +1380,7 @@ class SRLabelEncode(BaseRecLabelEncode):
super(SRLabelEncode, self).__init__(max_text_length,
character_dict_path, use_space_char)
self.dic = {}
with open(character_dict_path, 'r', encoding="utf-8") as fin:
with open(character_dict_path, 'r') as fin:
for line in fin.readlines():
line = line.strip()
character, sequence = line.split()
......
......@@ -59,7 +59,7 @@ class PubTabDataSet(Dataset):
file_list = [file_list]
data_lines = []
for idx, file in enumerate(file_list):
with open(file, "rb", encoding="utf-8") as f:
with open(file, "rb") as f:
lines = f.readlines()
if self.mode == "train" or ratio_list[idx] < 1.0:
random.seed(self.seed)
......@@ -112,7 +112,7 @@ class PubTabDataSet(Dataset):
'file_name': file_name
}
with open(data['img_path'], 'rb', encoding="utf-8") as f:
with open(data['img_path'], 'rb') as f:
img = f.read()
data['image'] = img
outs = transform(data, self.ops)
......
......@@ -74,7 +74,7 @@ class SimpleDataSet(Dataset):
file_list = [file_list]
data_lines = []
for idx, file in enumerate(file_list):
with open(file, "rb", encoding="utf-8") as f:
with open(file, "rb") as f:
lines = f.readlines()
if self.mode == "train" or ratio_list[idx] < 1.0:
random.seed(self.seed)
......@@ -120,7 +120,7 @@ class SimpleDataSet(Dataset):
data = {'img_path': img_path, 'label': label}
if not os.path.exists(img_path):
continue
with open(data['img_path'], 'rb', encoding="utf-8") as f:
with open(data['img_path'], 'rb') as f:
img = f.read()
data['image'] = img
data = transform(data, load_data_ops)
......@@ -146,7 +146,7 @@ class SimpleDataSet(Dataset):
data = {'img_path': img_path, 'label': label}
if not os.path.exists(img_path):
raise Exception("{} does not exist!".format(img_path))
with open(data['img_path'], 'rb', encoding="utf-8") as f:
with open(data['img_path'], 'rb') as f:
img = f.read()
data['image'] = img
data['ext_data'] = self.get_ext_data()
......@@ -240,7 +240,7 @@ class MultiScaleDataSet(SimpleDataSet):
data = {'img_path': img_path, 'label': label}
if not os.path.exists(img_path):
raise Exception("{} does not exist!".format(img_path))
with open(data['img_path'], 'rb', encoding="utf-8") as f:
with open(data['img_path'], 'rb') as f:
img = f.read()
data['image'] = img
data['ext_data'] = self.get_ext_data()
......
......@@ -31,7 +31,7 @@ class BaseRecLabelDecode(object):
self.character_str = "0123456789abcdefghijklmnopqrstuvwxyz"
dict_character = list(self.character_str)
else:
with open(character_dict_path, "rb", encoding="utf-8") as fin:
with open(character_dict_path, "rb") as fin:
lines = fin.readlines()
for line in lines:
line = line.decode('utf-8').strip("\n").strip("\r\n")
......
......@@ -26,7 +26,7 @@ class TableLabelDecode(AttnLabelDecode):
merge_no_span_structure=False,
**kwargs):
dict_character = []
with open(character_dict_path, "rb", encoding="utf-8") as fin:
with open(character_dict_path, "rb") as fin:
lines = fin.readlines()
for line in lines:
line = line.decode('utf-8').strip("\n").strip("\r\n")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册