From 4cdad758bde05d0657d12ccb8049b2468cb860bd Mon Sep 17 00:00:00 2001 From: andyjpaddle Date: Fri, 6 May 2022 09:24:27 +0000 Subject: [PATCH] fix sar training on windows --- ppocr/modeling/heads/rec_sar_head.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ppocr/modeling/heads/rec_sar_head.py b/ppocr/modeling/heads/rec_sar_head.py index 27693ebc..0e6b3440 100644 --- a/ppocr/modeling/heads/rec_sar_head.py +++ b/ppocr/modeling/heads/rec_sar_head.py @@ -99,8 +99,8 @@ class SAREncoder(nn.Layer): if valid_ratios is not None: valid_hf = [] T = holistic_feat.shape[1] - for i, valid_ratio in enumerate(valid_ratios): - valid_step = min(T, math.ceil(T * valid_ratio)) - 1 + for i in range(len(valid_ratios)): + valid_step = min(T, math.ceil(T * valid_ratios[i])) - 1 valid_hf.append(holistic_feat[i, valid_step, :]) valid_hf = paddle.stack(valid_hf, axis=0) else: @@ -252,8 +252,8 @@ class ParallelSARDecoder(BaseDecoder): if valid_ratios is not None: # cal mask of attention weight - for i, valid_ratio in enumerate(valid_ratios): - valid_width = min(w, math.ceil(w * valid_ratio)) + for i in range(len(valid_ratios)): + valid_width = min(w, math.ceil(w * valid_ratios[i])) if valid_width < w: attn_weight[i, :, :, valid_width:, :] = float('-inf') -- GitLab