From 41b33c9e9ceb9eaf4bded26b5313ef903147c07e Mon Sep 17 00:00:00 2001 From: WenmuZhou Date: Thu, 5 Nov 2020 20:45:19 +0800 Subject: [PATCH 01/16] change KaimingNormal to KaimingUniform --- ppocr/modeling/heads/det_db_head.py | 4 ++-- ppocr/modeling/necks/db_fpn.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ppocr/modeling/heads/det_db_head.py b/ppocr/modeling/heads/det_db_head.py index 23789910..49c50ffd 100644 --- a/ppocr/modeling/heads/det_db_head.py +++ b/ppocr/modeling/heads/det_db_head.py @@ -58,7 +58,7 @@ class Head(nn.Layer): stride=2, weight_attr=ParamAttr( name=name_list[2] + '.w_0', - initializer=paddle.nn.initializer.KaimingNormal()), + initializer=paddle.nn.initializer.KaimingUniform()), bias_attr=get_bias_attr(in_channels // 4, name_list[-1] + "conv2")) self.conv_bn2 = nn.BatchNorm( num_channels=in_channels // 4, @@ -78,7 +78,7 @@ class Head(nn.Layer): stride=2, weight_attr=ParamAttr( name=name_list[4] + '.w_0', - initializer=paddle.nn.initializer.KaimingNormal()), + initializer=paddle.nn.initializer.KaimingUniform()), bias_attr=get_bias_attr(in_channels // 4, name_list[-1] + "conv3"), ) diff --git a/ppocr/modeling/necks/db_fpn.py b/ppocr/modeling/necks/db_fpn.py index dbe482b4..02669e8a 100644 --- a/ppocr/modeling/necks/db_fpn.py +++ b/ppocr/modeling/necks/db_fpn.py @@ -26,7 +26,7 @@ class DBFPN(nn.Layer): def __init__(self, in_channels, out_channels, **kwargs): super(DBFPN, self).__init__() self.out_channels = out_channels - weight_attr = paddle.nn.initializer.KaimingNormal() + weight_attr = paddle.nn.initializer.KaimingUniform() self.in2_conv = nn.Conv2D( in_channels=in_channels[0], From d092a5a22f177823b898d44ebf0dec827b91d3f7 Mon Sep 17 00:00:00 2001 From: WenmuZhou Date: Thu, 5 Nov 2020 20:47:16 +0800 Subject: [PATCH 02/16] switch learning_rate and lr --- configs/det/det_mv3_db.yml | 4 ++-- configs/rec/rec_mv3_none_bilstm_ctc.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/configs/det/det_mv3_db.yml b/configs/det/det_mv3_db.yml index a165b426..b55ff99b 100644 --- a/configs/det/det_mv3_db.yml +++ b/configs/det/det_mv3_db.yml @@ -44,9 +44,9 @@ Optimizer: name: Adam beta1: 0.9 beta2: 0.999 - learning_rate: + lr: # name: Cosine - lr: 0.001 + learning_rate: 0.001 # warmup_epoch: 0 regularizer: name: 'L2' diff --git a/configs/rec/rec_mv3_none_bilstm_ctc.yml b/configs/rec/rec_mv3_none_bilstm_ctc.yml index c6c07141..8e89c64f 100644 --- a/configs/rec/rec_mv3_none_bilstm_ctc.yml +++ b/configs/rec/rec_mv3_none_bilstm_ctc.yml @@ -29,8 +29,8 @@ Optimizer: name: Adam beta1: 0.9 beta2: 0.999 - learning_rate: - lr: 0.0005 + lr: + learning_rate: 0.0005 regularizer: name: 'L2' factor: 0.00001 From 695c4db7ea237af68721bc9544c0ef7696bad422 Mon Sep 17 00:00:00 2001 From: WenmuZhou Date: Thu, 5 Nov 2020 20:49:44 +0800 Subject: [PATCH 03/16] switch learning_rate and lr --- ppocr/optimizer/learning_rate.py | 44 +++++++++++++++++--------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/ppocr/optimizer/learning_rate.py b/ppocr/optimizer/learning_rate.py index 518e0eef..8f303e83 100644 --- a/ppocr/optimizer/learning_rate.py +++ b/ppocr/optimizer/learning_rate.py @@ -17,7 +17,7 @@ from __future__ import division from __future__ import print_function from __future__ import unicode_literals -from paddle.optimizer import lr as lr_scheduler +from paddle.optimizer import lr class Linear(object): @@ -32,7 +32,7 @@ class Linear(object): """ def __init__(self, - lr, + learning_rate, epochs, step_each_epoch, end_lr=0.0, @@ -41,7 +41,7 @@ class Linear(object): last_epoch=-1, **kwargs): super(Linear, self).__init__() - self.lr = lr + self.learning_rate = learning_rate self.epochs = epochs * step_each_epoch self.end_lr = end_lr self.power = power @@ -49,18 +49,18 @@ class Linear(object): self.warmup_epoch = warmup_epoch * step_each_epoch def __call__(self): - learning_rate = lr_scheduler.PolynomialLR( - learning_rate=self.lr, + learning_rate = lr.PolynomialDecay( + learning_rate=self.learning_rate, decay_steps=self.epochs, end_lr=self.end_lr, power=self.power, last_epoch=self.last_epoch) if self.warmup_epoch > 0: - learning_rate = lr_scheduler.LinearLrWarmup( + learning_rate = lr.LinearWarmup( learning_rate=learning_rate, warmup_steps=self.warmup_epoch, start_lr=0.0, - end_lr=self.lr, + end_lr=self.learning_rate, last_epoch=self.last_epoch) return learning_rate @@ -77,27 +77,29 @@ class Cosine(object): """ def __init__(self, - lr, + learning_rate, step_each_epoch, epochs, warmup_epoch=0, last_epoch=-1, **kwargs): super(Cosine, self).__init__() - self.lr = lr + self.learning_rate = learning_rate self.T_max = step_each_epoch * epochs self.last_epoch = last_epoch self.warmup_epoch = warmup_epoch * step_each_epoch def __call__(self): - learning_rate = lr_scheduler.CosineAnnealingLR( - learning_rate=self.lr, T_max=self.T_max, last_epoch=self.last_epoch) + learning_rate = lr.CosineAnnealingDecay( + learning_rate=self.learning_rate, + T_max=self.T_max, + last_epoch=self.last_epoch) if self.warmup_epoch > 0: - learning_rate = lr_scheduler.LinearLrWarmup( + learning_rate = lr.LinearWarmup( learning_rate=learning_rate, warmup_steps=self.warmup_epoch, start_lr=0.0, - end_lr=self.lr, + end_lr=self.learning_rate, last_epoch=self.last_epoch) return learning_rate @@ -115,7 +117,7 @@ class Step(object): """ def __init__(self, - lr, + learning_rate, step_size, step_each_epoch, gamma, @@ -124,23 +126,23 @@ class Step(object): **kwargs): super(Step, self).__init__() self.step_size = step_each_epoch * step_size - self.lr = lr + self.learning_rate = learning_rate self.gamma = gamma self.last_epoch = last_epoch self.warmup_epoch = warmup_epoch * step_each_epoch def __call__(self): - learning_rate = lr_scheduler.StepLR( - learning_rate=self.lr, + learning_rate = lr.StepDecay( + learning_rate=self.learning_rate, step_size=self.step_size, gamma=self.gamma, last_epoch=self.last_epoch) if self.warmup_epoch > 0: - learning_rate = lr_scheduler.LinearLrWarmup( + learning_rate = lr.LinearWarmup( learning_rate=learning_rate, warmup_steps=self.warmup_epoch, start_lr=0.0, - end_lr=self.lr, + end_lr=self.learning_rate, last_epoch=self.last_epoch) return learning_rate @@ -169,12 +171,12 @@ class Piecewise(object): self.warmup_epoch = warmup_epoch * step_each_epoch def __call__(self): - learning_rate = lr_scheduler.PiecewiseLR( + learning_rate = lr.PiecewiseDecay( boundaries=self.boundaries, values=self.values, last_epoch=self.last_epoch) if self.warmup_epoch > 0: - learning_rate = lr_scheduler.LinearLrWarmup( + learning_rate = lr.LinearWarmup( learning_rate=learning_rate, warmup_steps=self.warmup_epoch, start_lr=0.0, From 8f81956fc4f7cbd79c508cbbff4cdfe04a3ad03a Mon Sep 17 00:00:00 2001 From: WenmuZhou Date: Fri, 6 Nov 2020 15:43:04 +0800 Subject: [PATCH 04/16] rename metric --- ppocr/metrics/__init__.py | 4 ++-- ppocr/metrics/{DetMetric.py => det_metric.py} | 0 ppocr/metrics/{RecMetric.py => rec_metric.py} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename ppocr/metrics/{DetMetric.py => det_metric.py} (100%) rename ppocr/metrics/{RecMetric.py => rec_metric.py} (100%) diff --git a/ppocr/metrics/__init__.py b/ppocr/metrics/__init__.py index 3fddac17..5d668cd8 100644 --- a/ppocr/metrics/__init__.py +++ b/ppocr/metrics/__init__.py @@ -23,8 +23,8 @@ __all__ = ['build_metric'] def build_metric(config): - from .DetMetric import DetMetric - from .RecMetric import RecMetric + from .det_metric import DetMetric + from .rec_metric import RecMetric support_dict = ['DetMetric', 'RecMetric'] diff --git a/ppocr/metrics/DetMetric.py b/ppocr/metrics/det_metric.py similarity index 100% rename from ppocr/metrics/DetMetric.py rename to ppocr/metrics/det_metric.py diff --git a/ppocr/metrics/RecMetric.py b/ppocr/metrics/rec_metric.py similarity index 100% rename from ppocr/metrics/RecMetric.py rename to ppocr/metrics/rec_metric.py From d9e921c74388105518e2ba89e0a7e948b5bc3be9 Mon Sep 17 00:00:00 2001 From: WenmuZhou Date: Fri, 6 Nov 2020 18:15:44 +0800 Subject: [PATCH 05/16] change align_mode to 1 --- ppocr/modeling/necks/db_fpn.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/ppocr/modeling/necks/db_fpn.py b/ppocr/modeling/necks/db_fpn.py index 02669e8a..710023f3 100644 --- a/ppocr/modeling/necks/db_fpn.py +++ b/ppocr/modeling/necks/db_fpn.py @@ -97,17 +97,20 @@ class DBFPN(nn.Layer): in3 = self.in3_conv(c3) in2 = self.in2_conv(c2) - out4 = in4 + F.upsample(in5, scale_factor=2, mode="nearest") # 1/16 - out3 = in3 + F.upsample(out4, scale_factor=2, mode="nearest") # 1/8 - out2 = in2 + F.upsample(out3, scale_factor=2, mode="nearest") # 1/4 + out4 = in4 + F.upsample( + in5, scale_factor=2, mode="nearest", align_mode=1) # 1/16 + out3 = in3 + F.upsample( + out4, scale_factor=2, mode="nearest", align_mode=1) # 1/8 + out2 = in2 + F.upsample( + out3, scale_factor=2, mode="nearest", align_mode=1) # 1/4 p5 = self.p5_conv(in5) p4 = self.p4_conv(out4) p3 = self.p3_conv(out3) p2 = self.p2_conv(out2) - p5 = F.upsample(p5, scale_factor=8, mode="nearest") - p4 = F.upsample(p4, scale_factor=4, mode="nearest") - p3 = F.upsample(p3, scale_factor=2, mode="nearest") + p5 = F.upsample(p5, scale_factor=8, mode="nearest", align_mode=1) + p4 = F.upsample(p4, scale_factor=4, mode="nearest", align_mode=1) + p3 = F.upsample(p3, scale_factor=2, mode="nearest", align_mode=1) fuse = paddle.concat([p5, p4, p3, p2], axis=1) return fuse From 592bd60fe2cb76c72d00f7724c7e6c306eea840a Mon Sep 17 00:00:00 2001 From: WenmuZhou Date: Fri, 6 Nov 2020 18:22:31 +0800 Subject: [PATCH 06/16] switch learning_rate and lr --- ppocr/optimizer/__init__.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ppocr/optimizer/__init__.py b/ppocr/optimizer/__init__.py index 72366e50..6413ae95 100644 --- a/ppocr/optimizer/__init__.py +++ b/ppocr/optimizer/__init__.py @@ -29,7 +29,7 @@ def build_lr_scheduler(lr_config, epochs, step_each_epoch): lr_name = lr_config.pop('name') lr = getattr(learning_rate, lr_name)(**lr_config)() else: - lr = lr_config['lr'] + lr = lr_config['learning_rate'] return lr @@ -37,8 +37,7 @@ def build_optimizer(config, epochs, step_each_epoch, parameters): from . import regularizer, optimizer config = copy.deepcopy(config) # step1 build lr - lr = build_lr_scheduler( - config.pop('learning_rate'), epochs, step_each_epoch) + lr = build_lr_scheduler(config.pop('lr'), epochs, step_each_epoch) # step2 build regularization if 'regularizer' in config and config['regularizer'] is not None: From 9467b754366bf69de5b28f57008c64625e20cf56 Mon Sep 17 00:00:00 2001 From: WenmuZhou Date: Fri, 6 Nov 2020 18:56:05 +0800 Subject: [PATCH 07/16] delete shuffle param --- configs/det/det_mv3_db.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/configs/det/det_mv3_db.yml b/configs/det/det_mv3_db.yml index b55ff99b..216cbf34 100644 --- a/configs/det/det_mv3_db.yml +++ b/configs/det/det_mv3_db.yml @@ -100,7 +100,6 @@ Train: - KeepKeys: keep_keys: ['image', 'threshold_map', 'threshold_mask', 'shrink_map', 'shrink_mask'] # the order of the dataloader list loader: - shuffle: True drop_last: False batch_size_per_card: 4 num_workers: 8 @@ -127,7 +126,6 @@ Eval: - KeepKeys: keep_keys: ['image', 'shape', 'polys', 'ignore_tags'] loader: - shuffle: False drop_last: False batch_size_per_card: 1 # must be 1 num_workers: 2 \ No newline at end of file From 2aa92e6a642a75b058c7571a93db7e58599b8906 Mon Sep 17 00:00:00 2001 From: WenmuZhou Date: Fri, 6 Nov 2020 18:56:53 +0800 Subject: [PATCH 08/16] fix bug --- tools/program.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/tools/program.py b/tools/program.py index 696700c0..33bf1adc 100755 --- a/tools/program.py +++ b/tools/program.py @@ -152,7 +152,6 @@ def train(config, pre_best_model_dict, logger, vdl_writer=None): - cal_metric_during_train = config['Global'].get('cal_metric_during_train', False) log_smooth_window = config['Global']['log_smooth_window'] @@ -185,14 +184,13 @@ def train(config, for epoch in range(start_epoch, epoch_num): if epoch > 0: - train_loader = build_dataloader(config, 'Train', device) + train_dataloader = build_dataloader(config, 'Train', device, logger) for idx, batch in enumerate(train_dataloader): if idx >= len(train_dataloader): break lr = optimizer.get_lr() t1 = time.time() - batch = [paddle.to_tensor(x) for x in batch] images = batch[0] preds = model(images) loss = loss_class(preds, batch) @@ -301,11 +299,11 @@ def eval(model, valid_dataloader, post_process_class, eval_class, logger, with paddle.no_grad(): total_frame = 0.0 total_time = 0.0 - # pbar = tqdm(total=len(valid_dataloader), desc='eval model:') + pbar = tqdm(total=len(valid_dataloader), desc='eval model:') for idx, batch in enumerate(valid_dataloader): if idx >= len(valid_dataloader): break - images = paddle.to_tensor(batch[0]) + images = batch[0] start = time.time() preds = model(images) @@ -315,15 +313,15 @@ def eval(model, valid_dataloader, post_process_class, eval_class, logger, total_time += time.time() - start # Evaluate the results of the current batch eval_class(post_result, batch) - # pbar.update(1) + pbar.update(1) total_frame += len(images) - if idx % print_batch_step == 0 and dist.get_rank() == 0: - logger.info('tackling images for eval: {}/{}'.format( - idx, len(valid_dataloader))) + # if idx % print_batch_step == 0 and dist.get_rank() == 0: + # logger.info('tackling images for eval: {}/{}'.format( + # idx, len(valid_dataloader))) # Get final metirc,eg. acc or hmean metirc = eval_class.get_metric() -# pbar.close() + pbar.close() model.train() metirc['fps'] = total_frame / total_time return metirc From 33c66f8ed3b4df2ad17a2fac0c0a01a7e7b3cea9 Mon Sep 17 00:00:00 2001 From: WenmuZhou Date: Fri, 6 Nov 2020 19:02:04 +0800 Subject: [PATCH 09/16] add shuffle param --- configs/det/det_mv3_db.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configs/det/det_mv3_db.yml b/configs/det/det_mv3_db.yml index 216cbf34..b55ff99b 100644 --- a/configs/det/det_mv3_db.yml +++ b/configs/det/det_mv3_db.yml @@ -100,6 +100,7 @@ Train: - KeepKeys: keep_keys: ['image', 'threshold_map', 'threshold_mask', 'shrink_map', 'shrink_mask'] # the order of the dataloader list loader: + shuffle: True drop_last: False batch_size_per_card: 4 num_workers: 8 @@ -126,6 +127,7 @@ Eval: - KeepKeys: keep_keys: ['image', 'shape', 'polys', 'ignore_tags'] loader: + shuffle: False drop_last: False batch_size_per_card: 1 # must be 1 num_workers: 2 \ No newline at end of file From 60f8f1e1812cb6e45f0d54e41bcf8c33e31ea3b1 Mon Sep 17 00:00:00 2001 From: WenmuZhou Date: Fri, 6 Nov 2020 19:09:52 +0800 Subject: [PATCH 10/16] del unuse import --- ppocr/data/lmdb_dataset.py | 4 ---- ppocr/data/simple_dataset.py | 3 --- 2 files changed, 7 deletions(-) diff --git a/ppocr/data/lmdb_dataset.py b/ppocr/data/lmdb_dataset.py index ffa05228..e7bb6dd3 100644 --- a/ppocr/data/lmdb_dataset.py +++ b/ppocr/data/lmdb_dataset.py @@ -11,13 +11,9 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -import copy import numpy as np import os -import random -import paddle from paddle.io import Dataset -import time import lmdb import cv2 diff --git a/ppocr/data/simple_dataset.py b/ppocr/data/simple_dataset.py index e9813cdc..e9a0a2ae 100644 --- a/ppocr/data/simple_dataset.py +++ b/ppocr/data/simple_dataset.py @@ -11,13 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -import copy import numpy as np import os import random -import paddle from paddle.io import Dataset -import time from .imaug import transform, create_operators From 91dee973dac6fbb00fb91c5decc4e390bfa2b2fa Mon Sep 17 00:00:00 2001 From: WenmuZhou Date: Fri, 6 Nov 2020 19:11:35 +0800 Subject: [PATCH 11/16] change log name to root --- tools/program.py | 3 ++- tools/train.py | 9 ++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/program.py b/tools/program.py index 33bf1adc..41acb866 100755 --- a/tools/program.py +++ b/tools/program.py @@ -352,7 +352,8 @@ def preprocess(): with open(os.path.join(save_model_dir, 'config.yml'), 'w') as f: yaml.dump(dict(config), f, default_flow_style=False, sort_keys=False) - logger = get_logger(log_file='{}/train.log'.format(save_model_dir)) + logger = get_logger( + name='root', log_file='{}/train.log'.format(save_model_dir)) if config['Global']['use_visualdl']: from visualdl import LogWriter vdl_writer_path = '{}/vdl/'.format(save_model_dir) diff --git a/tools/train.py b/tools/train.py index bdba7dba..32abe0fc 100755 --- a/tools/train.py +++ b/tools/train.py @@ -36,7 +36,6 @@ from ppocr.optimizer import build_optimizer from ppocr.postprocess import build_post_process from ppocr.metrics import build_metric from ppocr.utils.save_load import init_model -from ppocr.utils.utility import print_dict import tools.program as program dist.get_world_size() @@ -61,7 +60,7 @@ def main(config, device, logger, vdl_writer): global_config) # build model - #for rec algorithm + # for rec algorithm if hasattr(post_process_class, 'character'): char_num = len(getattr(post_process_class, 'character')) config['Architecture']["Head"]['out_channels'] = char_num @@ -81,10 +80,11 @@ def main(config, device, logger, vdl_writer): # build metric eval_class = build_metric(config['Metric']) - # load pretrain model pre_best_model_dict = init_model(config, model, logger, optimizer) + logger.info('train dataloader has {} iter, valid dataloader has {} iter'. + format(len(train_dataloader), len(valid_dataloader))) # start train program.train(config, train_dataloader, valid_dataloader, device, model, loss_class, optimizer, lr_scheduler, post_process_class, @@ -92,8 +92,7 @@ def main(config, device, logger, vdl_writer): def test_reader(config, device, logger): - loader = build_dataloader(config, 'Train', device) - # loader = build_dataloader(config, 'Eval', device) + loader = build_dataloader(config, 'Train', device, logger) import time starttime = time.time() count = 0 From cafb2df8a69841041a77da746c103254e6d80fcf Mon Sep 17 00:00:00 2001 From: WenmuZhou Date: Fri, 6 Nov 2020 19:11:42 +0800 Subject: [PATCH 12/16] change log name to root --- ppocr/utils/logging.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ppocr/utils/logging.py b/ppocr/utils/logging.py index e3fa6b23..951141db 100644 --- a/ppocr/utils/logging.py +++ b/ppocr/utils/logging.py @@ -22,7 +22,7 @@ logger_initialized = {} @functools.lru_cache() -def get_logger(name='ppocr', log_file=None, log_level=logging.INFO): +def get_logger(name='root', log_file=None, log_level=logging.INFO): """Initialize and get a logger by name. If the logger has not been initialized, this method will initialize the logger by adding one or two handlers, otherwise the initialized logger will From 0c183d25d86509d8d28d4c543d4a0f1cd2ad5cb6 Mon Sep 17 00:00:00 2001 From: WenmuZhou Date: Fri, 6 Nov 2020 19:12:07 +0800 Subject: [PATCH 13/16] change config to baseline --- configs/rec/rec_mv3_none_bilstm_ctc.yml | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/configs/rec/rec_mv3_none_bilstm_ctc.yml b/configs/rec/rec_mv3_none_bilstm_ctc.yml index 8e89c64f..57a7c049 100644 --- a/configs/rec/rec_mv3_none_bilstm_ctc.yml +++ b/configs/rec/rec_mv3_none_bilstm_ctc.yml @@ -6,7 +6,7 @@ Global: save_model_dir: ./output/rec/mv3_none_bilstm_ctc/ save_epoch_step: 3 # evaluation is run every 5000 iterations after the 4000th iteration - eval_batch_step: [0, 1000] + eval_batch_step: [0, 2000] # if pretrained_model is saved in static mode, load_static_weights must set to True cal_metric_during_train: True pretrained_model: @@ -18,11 +18,8 @@ Global: character_dict_path: character_type: en max_text_length: 25 - loss_type: ctc infer_mode: False -# use_space_char: True - -# use_tps: False + use_space_char: False Optimizer: @@ -33,7 +30,7 @@ Optimizer: learning_rate: 0.0005 regularizer: name: 'L2' - factor: 0.00001 + factor: 0 Architecture: model_type: rec @@ -49,7 +46,7 @@ Architecture: hidden_size: 96 Head: name: CTCHead - fc_decay: 0.0004 + fc_decay: 0 Loss: name: CTCLoss @@ -75,8 +72,8 @@ Train: - KeepKeys: keep_keys: ['image', 'label', 'length'] # dataloader will return list in this order loader: + shuffle: True batch_size_per_card: 256 - shuffle: False drop_last: True num_workers: 8 @@ -97,4 +94,4 @@ Eval: shuffle: False drop_last: False batch_size_per_card: 256 - num_workers: 2 + num_workers: 4 From 6e4249eaf2b342275b73247bfe5fc515b17d7850 Mon Sep 17 00:00:00 2001 From: WenmuZhou Date: Fri, 6 Nov 2020 19:12:34 +0800 Subject: [PATCH 14/16] change python to python3 --- train.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/train.sh b/train.sh index 0e628f92..23182573 100644 --- a/train.sh +++ b/train.sh @@ -1 +1 @@ - python -m paddle.distributed.launch --selected_gpus '0,1,2,3,4,5,6,7' tools/train.py -c configs/det/det_mv3_db.yml \ No newline at end of file + python3 -m paddle.distributed.launch --selected_gpus '0,1,2,3,4,5,6,7' tools/train.py -c configs/rec/rec_mv3_none_bilstm_ctc_lmdb_local.yml \ No newline at end of file From d2435e35bc16e6b0850c2af05b50d28d343f3f1f Mon Sep 17 00:00:00 2001 From: WenmuZhou Date: Fri, 6 Nov 2020 19:13:33 +0800 Subject: [PATCH 15/16] change config path --- train.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/train.sh b/train.sh index 23182573..a0483e4d 100644 --- a/train.sh +++ b/train.sh @@ -1 +1 @@ - python3 -m paddle.distributed.launch --selected_gpus '0,1,2,3,4,5,6,7' tools/train.py -c configs/rec/rec_mv3_none_bilstm_ctc_lmdb_local.yml \ No newline at end of file + python3 -m paddle.distributed.launch --selected_gpus '0,1,2,3,4,5,6,7' tools/train.py -c configs/rec/rec_mv3_none_bilstm_ctc.yml \ No newline at end of file From a414dd864929a37eed26d153a7351d74e2d678ec Mon Sep 17 00:00:00 2001 From: WenmuZhou Date: Fri, 6 Nov 2020 19:15:21 +0800 Subject: [PATCH 16/16] fix write error --- tools/train.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/train.py b/tools/train.py index 32abe0fc..c1622379 100755 --- a/tools/train.py +++ b/tools/train.py @@ -83,7 +83,7 @@ def main(config, device, logger, vdl_writer): # load pretrain model pre_best_model_dict = init_model(config, model, logger, optimizer) - logger.info('train dataloader has {} iter, valid dataloader has {} iter'. + logger.info('train dataloader has {} iters, valid dataloader has {} iters'. format(len(train_dataloader), len(valid_dataloader))) # start train program.train(config, train_dataloader, valid_dataloader, device, model,