From 1046c239cc89ec983ab0f1f3f323a7e23abb4bc2 Mon Sep 17 00:00:00 2001 From: wanghuancoder Date: Tue, 29 Aug 2023 15:33:55 +0800 Subject: [PATCH] fix numpy speed (#10773) --- 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 5812544e..97a33733 100644 --- a/ppocr/losses/distillation_loss.py +++ b/ppocr/losses/distillation_loss.py @@ -745,6 +745,8 @@ class DistillationDilaDBLoss(DBLoss): # 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]): -- GitLab