From 8a45b5e08cd87f93f29ca643551a05550f781430 Mon Sep 17 00:00:00 2001 From: topduke <784990967@qq.com> Date: Tue, 7 Feb 2023 13:57:24 +0800 Subject: [PATCH] Fix piecewise boundaries and droppath dtype (#8988) * fix piecewise boundaries and droppath dtype * fix tipc piecewise boundaries and droppath dtype --- configs/rec/PP-OCRv3/ch_PP-OCRv3_rec_distillation.yml | 2 +- configs/rec/ch_PP-OCRv2/ch_PP-OCRv2_rec.yml | 2 +- configs/rec/ch_PP-OCRv2/ch_PP-OCRv2_rec_distillation.yml | 2 +- configs/rec/ch_PP-OCRv2/ch_PP-OCRv2_rec_enhanced_ctc_loss.yml | 2 +- configs/rec/rec_resnet_stn_bilstm_att.yml | 4 ++-- ppocr/modeling/backbones/rec_svtrnet.py | 2 +- .../configs/ch_PP-OCRv2_rec/ch_PP-OCRv2_rec_distillation.yml | 2 +- .../configs/ch_PP-OCRv3_rec/ch_PP-OCRv3_rec_distillation.yml | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/configs/rec/PP-OCRv3/ch_PP-OCRv3_rec_distillation.yml b/configs/rec/PP-OCRv3/ch_PP-OCRv3_rec_distillation.yml index 42725573..afa012b6 100644 --- a/configs/rec/PP-OCRv3/ch_PP-OCRv3_rec_distillation.yml +++ b/configs/rec/PP-OCRv3/ch_PP-OCRv3_rec_distillation.yml @@ -27,7 +27,7 @@ Optimizer: beta2: 0.999 lr: name: Piecewise - decay_epochs : [700, 800] + decay_epochs : [700] values : [0.0005, 0.00005] warmup_epoch: 5 regularizer: diff --git a/configs/rec/ch_PP-OCRv2/ch_PP-OCRv2_rec.yml b/configs/rec/ch_PP-OCRv2/ch_PP-OCRv2_rec.yml index e2aa5010..793bb5c9 100644 --- a/configs/rec/ch_PP-OCRv2/ch_PP-OCRv2_rec.yml +++ b/configs/rec/ch_PP-OCRv2/ch_PP-OCRv2_rec.yml @@ -27,7 +27,7 @@ Optimizer: beta2: 0.999 lr: name: Piecewise - decay_epochs : [700, 800] + decay_epochs : [700] values : [0.001, 0.0001] warmup_epoch: 5 regularizer: diff --git a/configs/rec/ch_PP-OCRv2/ch_PP-OCRv2_rec_distillation.yml b/configs/rec/ch_PP-OCRv2/ch_PP-OCRv2_rec_distillation.yml index 9bddcb29..3855005c 100644 --- a/configs/rec/ch_PP-OCRv2/ch_PP-OCRv2_rec_distillation.yml +++ b/configs/rec/ch_PP-OCRv2/ch_PP-OCRv2_rec_distillation.yml @@ -28,7 +28,7 @@ Optimizer: beta2: 0.999 lr: name: Piecewise - decay_epochs : [700, 800] + decay_epochs : [700] values : [0.001, 0.0001] warmup_epoch: 5 regularizer: diff --git a/configs/rec/ch_PP-OCRv2/ch_PP-OCRv2_rec_enhanced_ctc_loss.yml b/configs/rec/ch_PP-OCRv2/ch_PP-OCRv2_rec_enhanced_ctc_loss.yml index 5be96969..ef0e893f 100644 --- a/configs/rec/ch_PP-OCRv2/ch_PP-OCRv2_rec_enhanced_ctc_loss.yml +++ b/configs/rec/ch_PP-OCRv2/ch_PP-OCRv2_rec_enhanced_ctc_loss.yml @@ -27,7 +27,7 @@ Optimizer: beta2: 0.999 lr: name: Piecewise - decay_epochs : [700, 800] + decay_epochs : [700] values : [0.001, 0.0001] warmup_epoch: 5 regularizer: diff --git a/configs/rec/rec_resnet_stn_bilstm_att.yml b/configs/rec/rec_resnet_stn_bilstm_att.yml index 0bb90b35..20ed9533 100644 --- a/configs/rec/rec_resnet_stn_bilstm_att.yml +++ b/configs/rec/rec_resnet_stn_bilstm_att.yml @@ -1,6 +1,6 @@ Global: use_gpu: True - epoch_num: 400 + epoch_num: 6 log_smooth_window: 20 print_batch_step: 10 save_model_dir: ./output/rec/seed @@ -27,7 +27,7 @@ Optimizer: momentum: 0.9 lr: name: Piecewise - decay_epochs: [4,5,8] + decay_epochs: [4, 5] values: [1.0, 0.1, 0.01] regularizer: name: 'L2' diff --git a/ppocr/modeling/backbones/rec_svtrnet.py b/ppocr/modeling/backbones/rec_svtrnet.py index c2c07f44..de5920c6 100644 --- a/ppocr/modeling/backbones/rec_svtrnet.py +++ b/ppocr/modeling/backbones/rec_svtrnet.py @@ -32,7 +32,7 @@ def drop_path(x, drop_prob=0., training=False): """ if drop_prob == 0. or not training: return x - keep_prob = paddle.to_tensor(1 - drop_prob) + keep_prob = paddle.to_tensor(1 - drop_prob, dtype=x.dtype) shape = (paddle.shape(x)[0], ) + (1, ) * (x.ndim - 1) random_tensor = keep_prob + paddle.rand(shape, dtype=x.dtype) random_tensor = paddle.floor(random_tensor) # binarize diff --git a/test_tipc/configs/ch_PP-OCRv2_rec/ch_PP-OCRv2_rec_distillation.yml b/test_tipc/configs/ch_PP-OCRv2_rec/ch_PP-OCRv2_rec_distillation.yml index 3eb82d42..43e14b84 100644 --- a/test_tipc/configs/ch_PP-OCRv2_rec/ch_PP-OCRv2_rec_distillation.yml +++ b/test_tipc/configs/ch_PP-OCRv2_rec/ch_PP-OCRv2_rec_distillation.yml @@ -27,7 +27,7 @@ Optimizer: beta2: 0.999 lr: name: Piecewise - decay_epochs : [700, 800] + decay_epochs : [700] values : [0.001, 0.0001] warmup_epoch: 5 regularizer: diff --git a/test_tipc/configs/ch_PP-OCRv3_rec/ch_PP-OCRv3_rec_distillation.yml b/test_tipc/configs/ch_PP-OCRv3_rec/ch_PP-OCRv3_rec_distillation.yml index 4c8ba0a6..8150d95e 100644 --- a/test_tipc/configs/ch_PP-OCRv3_rec/ch_PP-OCRv3_rec_distillation.yml +++ b/test_tipc/configs/ch_PP-OCRv3_rec/ch_PP-OCRv3_rec_distillation.yml @@ -27,7 +27,7 @@ Optimizer: beta2: 0.999 lr: name: Piecewise - decay_epochs : [700, 800] + decay_epochs : [700] values : [0.0005, 0.00005] warmup_epoch: 5 regularizer: -- GitLab