diff --git a/ppocr/data/imaug/label_ops.py b/ppocr/data/imaug/label_ops.py index 344f596d9d7c435ec98074de6d8cc08a420d27e8..58d06fd4f28c9b1a68e37ae5b316a45896d4cdc5 100644 --- a/ppocr/data/imaug/label_ops.py +++ b/ppocr/data/imaug/label_ops.py @@ -291,7 +291,7 @@ class KieLabelEncode(object): def __init__(self, character_dict_path, norm=10, directed=False, **kwargs): super(KieLabelEncode, self).__init__() self.dict = dict({'': 0}) - with open(character_dict_path, 'r') as fr: + with open(character_dict_path, 'r', encoding='utf-8') as fr: idx = 1 for line in fr: char = line.strip() diff --git a/ppocr/metrics/rec_metric.py b/ppocr/metrics/rec_metric.py index db2f41c3a140ecebc42b71ee03f0ecb5cf50ca80..b0ccd974f24f1c7e0c9a8e1d414373021c4288e6 100644 --- a/ppocr/metrics/rec_metric.py +++ b/ppocr/metrics/rec_metric.py @@ -48,7 +48,7 @@ class RecMetric(object): self.norm_edit_dis += norm_edit_dis return { 'acc': correct_num / all_num, - 'norm_edit_dis': 1 - norm_edit_dis / all_num + 'norm_edit_dis': 1 - norm_edit_dis / (all_num + 1e-3) } def get_metric(self): @@ -58,8 +58,8 @@ class RecMetric(object): 'norm_edit_dis': 0, } """ - acc = 1.0 * self.correct_num / self.all_num - norm_edit_dis = 1 - self.norm_edit_dis / self.all_num + acc = 1.0 * self.correct_num / (self.all_num + 1e-3) + norm_edit_dis = 1 - self.norm_edit_dis / (self.all_num + 1e-3) self.reset() return {'acc': acc, 'norm_edit_dis': norm_edit_dis}