diff --git a/ppocr/postprocess/rec_postprocess.py b/ppocr/postprocess/rec_postprocess.py index e6bc07aa98ab2991a77811d7ea0f723ed26f75e2..d353391c9af2b85bd01ba659f541fa1791461f68 100644 --- a/ppocr/postprocess/rec_postprocess.py +++ b/ppocr/postprocess/rec_postprocess.py @@ -218,6 +218,7 @@ class SRNLabelDecode(BaseRecLabelDecode): **kwargs): super(SRNLabelDecode, self).__init__(character_dict_path, character_type, use_space_char) + self.max_text_length = kwargs.get('max_text_length', 25) def __call__(self, preds, label=None, *args, **kwargs): pred = preds['predict'] @@ -229,9 +230,9 @@ class SRNLabelDecode(BaseRecLabelDecode): preds_idx = np.argmax(pred, axis=1) preds_prob = np.max(pred, axis=1) - preds_idx = np.reshape(preds_idx, [-1, 25]) + preds_idx = np.reshape(preds_idx, [-1, self.max_text_length]) - preds_prob = np.reshape(preds_prob, [-1, 25]) + preds_prob = np.reshape(preds_prob, [-1, self.max_text_length]) text = self.decode(preds_idx, preds_prob)