From 4eb351866c1bda9db33c77c93e6fdc0164c9ee3a Mon Sep 17 00:00:00 2001 From: WenmuZhou Date: Mon, 8 Feb 2021 14:05:48 +0800 Subject: [PATCH 1/2] predict_rec support rare --- tools/infer/predict_rec.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/infer/predict_rec.py b/tools/infer/predict_rec.py index fd895e5071..b3d9d4907b 100755 --- a/tools/infer/predict_rec.py +++ b/tools/infer/predict_rec.py @@ -54,6 +54,13 @@ class TextRecognizer(object): "character_dict_path": args.rec_char_dict_path, "use_space_char": args.use_space_char } + elif self.rec_algorithm == "RARE": + postprocess_params = { + 'name': 'AttnLabelDecode', + "character_type": args.rec_char_type, + "character_dict_path": args.rec_char_dict_path, + "use_space_char": args.use_space_char + } self.postprocess_op = build_post_process(postprocess_params) self.predictor, self.input_tensor, self.output_tensors = \ utility.create_predictor(args, 'rec', logger) From ed2b527c9ff185425b7ea42a6f88926294899e52 Mon Sep 17 00:00:00 2001 From: WenmuZhou Date: Mon, 8 Feb 2021 14:06:10 +0800 Subject: [PATCH 2/2] fix rare export error --- ppocr/modeling/heads/rec_att_head.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ppocr/modeling/heads/rec_att_head.py b/ppocr/modeling/heads/rec_att_head.py index a7cfe12821..59e26c1e20 100644 --- a/ppocr/modeling/heads/rec_att_head.py +++ b/ppocr/modeling/heads/rec_att_head.py @@ -146,6 +146,9 @@ class AttentionLSTM(nn.Layer): else: targets = paddle.zeros(shape=[batch_size], dtype="int32") probs = None + char_onehots = None + outputs = None + alpha = None for i in range(num_steps): char_onehots = self._char_to_onehot(