"examples/vscode:/vscode.git/clone" did not exist on "59433ca1ae76445908e63fe4e2f9aceaf95baf0c"
Unverified Commit 159b3a26 authored by xiaoting's avatar xiaoting Committed by GitHub
Browse files

Merge pull request #2661 from WenmuZhou/fix_srn_post_process

add max_text_length to SRNLabelDecode
parents 6335ee9a 38fc1fae
...@@ -218,6 +218,7 @@ class SRNLabelDecode(BaseRecLabelDecode): ...@@ -218,6 +218,7 @@ class SRNLabelDecode(BaseRecLabelDecode):
**kwargs): **kwargs):
super(SRNLabelDecode, self).__init__(character_dict_path, super(SRNLabelDecode, self).__init__(character_dict_path,
character_type, use_space_char) character_type, use_space_char)
self.max_text_length = kwargs.get('max_text_length', 25)
def __call__(self, preds, label=None, *args, **kwargs): def __call__(self, preds, label=None, *args, **kwargs):
pred = preds['predict'] pred = preds['predict']
...@@ -229,9 +230,9 @@ class SRNLabelDecode(BaseRecLabelDecode): ...@@ -229,9 +230,9 @@ class SRNLabelDecode(BaseRecLabelDecode):
preds_idx = np.argmax(pred, axis=1) preds_idx = np.argmax(pred, axis=1)
preds_prob = np.max(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) text = self.decode(preds_idx, preds_prob)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment