From 3380010d9aa1acd0a1889cde8bbff7a12cd988e8 Mon Sep 17 00:00:00 2001 From: andyjpaddle Date: Tue, 9 Aug 2022 01:44:16 +0000 Subject: [PATCH] update dict --- configs/rec/rec_r45_visionlan.yml | 2 +- ppocr/data/imaug/label_ops.py | 5 ++++ ppocr/postprocess/rec_postprocess.py | 2 ++ ppocr/utils/dict36.txt | 36 ---------------------------- 4 files changed, 8 insertions(+), 37 deletions(-) delete mode 100644 ppocr/utils/dict36.txt diff --git a/configs/rec/rec_r45_visionlan.yml b/configs/rec/rec_r45_visionlan.yml index f3a3661f..25017653 100644 --- a/configs/rec/rec_r45_visionlan.yml +++ b/configs/rec/rec_r45_visionlan.yml @@ -14,7 +14,7 @@ Global: use_visualdl: True infer_img: doc/imgs_words/en/word_2.png # for data or label process - character_dict_path: ppocr/utils/dict36.txt + character_dict_path: max_text_length: &max_text_length 25 training_step: &training_step LA infer_mode: False diff --git a/ppocr/data/imaug/label_ops.py b/ppocr/data/imaug/label_ops.py index 8acfd372..0698696a 100644 --- a/ppocr/data/imaug/label_ops.py +++ b/ppocr/data/imaug/label_ops.py @@ -1267,6 +1267,11 @@ class VLLabelEncode(BaseRecLabelEncode): **kwargs): super(VLLabelEncode, self).__init__( max_text_length, character_dict_path, use_space_char, lower) + self.character = self.character[10:] + self.character[ + 1:10] + [self.character[0]] + self.dict = {} + for i, char in enumerate(self.character): + self.dict[char] = i def __call__(self, data): text = data['label'] # original string diff --git a/ppocr/postprocess/rec_postprocess.py b/ppocr/postprocess/rec_postprocess.py index 0a316372..7b994f81 100644 --- a/ppocr/postprocess/rec_postprocess.py +++ b/ppocr/postprocess/rec_postprocess.py @@ -693,6 +693,8 @@ class VLLabelDecode(BaseRecLabelDecode): super(VLLabelDecode, self).__init__(character_dict_path, use_space_char) self.max_text_length = kwargs.get('max_text_length', 25) self.nclass = len(self.character) + 1 + self.character = self.character[10:] + self.character[ + 1:10] + [self.character[0]] def decode(self, text_index, text_prob=None, is_remove_duplicate=False): """ convert text-index into text-label. """ diff --git a/ppocr/utils/dict36.txt b/ppocr/utils/dict36.txt deleted file mode 100644 index 6fe31360..00000000 --- a/ppocr/utils/dict36.txt +++ /dev/null @@ -1,36 +0,0 @@ -a -b -c -d -e -f -g -h -i -j -k -l -m -n -o -p -q -r -s -t -u -v -w -x -y -z -1 -2 -3 -4 -5 -6 -7 -8 -9 -0 \ No newline at end of file -- GitLab