From d0bb19f66bc55385389ca0e8b0067ec998af7799 Mon Sep 17 00:00:00 2001 From: Wang Huan Date: Tue, 29 Aug 2023 06:53:43 +0000 Subject: [PATCH] fix numpy speed --- ppocr/losses/distillation_loss.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ppocr/losses/distillation_loss.py b/ppocr/losses/distillation_loss.py index 5812544e91..97a3373300 100644 --- a/ppocr/losses/distillation_loss.py +++ b/ppocr/losses/distillation_loss.py @@ -745,6 +745,8 @@ def forward(self, predicts, batch): # dilation to teacher prediction dilation_w = np.array([[1, 1], [1, 1]]) th_shrink_maps = tch_preds[:, 0, :, :] + if hasattr(paddle.Tensor, "contiguous"): + th_shrink_maps = th_shrink_maps.contiguous() th_shrink_maps = th_shrink_maps.numpy() > 0.3 # thresh = 0.3 dilate_maps = np.zeros_like(th_shrink_maps).astype(np.float32) for i in range(th_shrink_maps.shape[0]):