From 09c5cd6e120ca56170a20262fdcdf4ef4ca5416f Mon Sep 17 00:00:00 2001 From: LDOUBLEV Date: Thu, 10 Feb 2022 10:02:33 +0800 Subject: [PATCH 1/6] add pse to benchmark --- .../det_r50_vd_pse_v2.0/det_r50_vd_pse.yml | 134 ------------------ .../train_infer_python.txt | 51 ------- test_tipc/prepare.sh | 2 +- 3 files changed, 1 insertion(+), 186 deletions(-) delete mode 100644 test_tipc/configs/det_r50_vd_pse_v2.0/det_r50_vd_pse.yml delete mode 100644 test_tipc/configs/det_r50_vd_pse_v2.0/train_infer_python.txt diff --git a/test_tipc/configs/det_r50_vd_pse_v2.0/det_r50_vd_pse.yml b/test_tipc/configs/det_r50_vd_pse_v2.0/det_r50_vd_pse.yml deleted file mode 100644 index 5ebc42527..000000000 --- a/test_tipc/configs/det_r50_vd_pse_v2.0/det_r50_vd_pse.yml +++ /dev/null @@ -1,134 +0,0 @@ -Global: - use_gpu: true - epoch_num: 600 - log_smooth_window: 20 - print_batch_step: 10 - save_model_dir: ./output/det_r50_vd_pse/ - save_epoch_step: 600 - # evaluation is run every 125 iterations - eval_batch_step: [ 0,1000 ] - cal_metric_during_train: False - pretrained_model: - checkpoints: #./output/det_r50_vd_pse_batch8_ColorJitter/best_accuracy - save_inference_dir: - use_visualdl: False - infer_img: doc/imgs_en/img_10.jpg - save_res_path: ./output/det_pse/predicts_pse.txt - -Architecture: - model_type: det - algorithm: PSE - Transform: - Backbone: - name: ResNet - layers: 50 - Neck: - name: FPN - out_channels: 256 - Head: - name: PSEHead - hidden_dim: 256 - out_channels: 7 - -Loss: - name: PSELoss - alpha: 0.7 - ohem_ratio: 3 - kernel_sample_mask: pred - reduction: none - -Optimizer: - name: Adam - beta1: 0.9 - beta2: 0.999 - lr: - name: Step - learning_rate: 0.0001 - step_size: 200 - gamma: 0.1 - regularizer: - name: 'L2' - factor: 0.0005 - -PostProcess: - name: PSEPostProcess - thresh: 0 - box_thresh: 0.85 - min_area: 16 - box_type: box # 'box' or 'poly' - scale: 1 - -Metric: - name: DetMetric - main_indicator: hmean - -Train: - dataset: - name: SimpleDataSet - data_dir: ./train_data/icdar2015/text_localization/ - label_file_list: - - ./train_data/icdar2015/text_localization/train_icdar2015_label.txt - ratio_list: [ 1.0 ] - transforms: - - DecodeImage: # load image - img_mode: BGR - channel_first: False - - DetLabelEncode: # Class handling label - - ColorJitter: - brightness: 0.12549019607843137 - saturation: 0.5 - - IaaAugment: - augmenter_args: - - { 'type': Resize, 'args': { 'size': [ 0.5, 3 ] } } - - { 'type': Fliplr, 'args': { 'p': 0.5 } } - - { 'type': Affine, 'args': { 'rotate': [ -10, 10 ] } } - - MakePseGt: - kernel_num: 7 - min_shrink_ratio: 0.4 - size: 640 - - RandomCropImgMask: - size: [ 640,640 ] - main_key: gt_text - crop_keys: [ 'image', 'gt_text', 'gt_kernels', 'mask' ] - - NormalizeImage: - scale: 1./255. - mean: [ 0.485, 0.456, 0.406 ] - std: [ 0.229, 0.224, 0.225 ] - order: 'hwc' - - ToCHWImage: - - KeepKeys: - keep_keys: [ 'image', 'gt_text', 'gt_kernels', 'mask' ] # the order of the dataloader list - loader: - shuffle: True - drop_last: False - batch_size_per_card: 8 - num_workers: 8 - -Eval: - dataset: - name: SimpleDataSet - data_dir: ./train_data/icdar2015/text_localization/ - label_file_list: - - ./train_data/icdar2015/text_localization/test_icdar2015_label.txt - ratio_list: [ 1.0 ] - transforms: - - DecodeImage: # load image - img_mode: BGR - channel_first: False - - DetLabelEncode: # Class handling label - - DetResizeForTest: - limit_side_len: 736 - limit_type: min - - NormalizeImage: - scale: 1./255. - mean: [ 0.485, 0.456, 0.406 ] - std: [ 0.229, 0.224, 0.225 ] - order: 'hwc' - - ToCHWImage: - - KeepKeys: - keep_keys: [ 'image', 'shape', 'polys', 'ignore_tags' ] - loader: - shuffle: False - drop_last: False - batch_size_per_card: 1 # must be 1 - num_workers: 8 \ No newline at end of file diff --git a/test_tipc/configs/det_r50_vd_pse_v2.0/train_infer_python.txt b/test_tipc/configs/det_r50_vd_pse_v2.0/train_infer_python.txt deleted file mode 100644 index 6eb351e03..000000000 --- a/test_tipc/configs/det_r50_vd_pse_v2.0/train_infer_python.txt +++ /dev/null @@ -1,51 +0,0 @@ -===========================train_params=========================== -model_name:det_r50_vd_pse_v2.0 -python:python3.7 -gpu_list:0 -Global.use_gpu:True|True -Global.auto_cast:fp32 -Global.epoch_num:lite_train_lite_infer=1|whole_train_whole_infer=500 -Global.save_model_dir:./output/ -Train.loader.batch_size_per_card:lite_train_lite_infer=2|whole_train_whole_infer=4 -Global.pretrained_model:null -train_model_name:latest -train_infer_img_dir:./train_data/icdar2015/text_localization/ch4_test_images/ -null:null -## -trainer:norm_train -norm_train:tools/train.py -c test_tipc/configs/det_r50_vd_pse_v2.0/det_r50_vd_pse.yml -o -pact_train:null -fpgm_train:null -distill_train:null -null:null -null:null -## -===========================eval_params=========================== -eval:null -null:null -## -===========================infer_params=========================== -Global.save_inference_dir:./output/ -Global.checkpoints: -norm_export:tools/export_model.py -c test_tipc/configs/det_r50_vd_pse_v2.0/det_r50_vd_pse.yml -o -quant_export:null -fpgm_export:null -distill_export:null -export1:null -export2:null -## -train_model:./inference/det_r50_vd_pse_v2.0_train/best_accuracy -infer_export:tools/export_model.py -c test_tipc/configs/det_r50_vd_pse_v2.0/det_r50_vd_pse.yml -o -infer_quant:False -inference:tools/infer/predict_det.py ---use_gpu:True|False ---enable_mkldnn:True|False ---cpu_threads:1|6 ---rec_batch_num:1 ---use_tensorrt:False ---precision:fp32|fp16|int8 ---det_model_dir: ---image_dir:./inference/ch_det_data_50/all-sum-510/ ---save_log_path:null ---benchmark:True ---det_algorithm:PSE diff --git a/test_tipc/prepare.sh b/test_tipc/prepare.sh index 570c6832e..ea114697d 100644 --- a/test_tipc/prepare.sh +++ b/test_tipc/prepare.sh @@ -223,7 +223,7 @@ elif [ ${MODE} = "whole_infer" ];then wget -nc -P ./inference/ https://paddleocr.bj.bcebos.com/dygraph_v2.1/en_det/det_mv3_pse_v2.0_train.tar --no-check-certificate cd ./inference/ && tar xf det_mv3_pse_v2.0_train.tar & cd ../ fi - if [ ${model_name} == "det_r50_vd_pse_v2.0" ]; then + if [ ${model_name} == "det_r50_vd_pse_v2_0" ]; then wget -nc -P ./inference/ https://paddleocr.bj.bcebos.com/dygraph_v2.1/en_det/det_r50_vd_pse_v2.0_train.tar --no-check-certificate cd ./inference/ && tar xf det_r50_vd_pse_v2.0_train.tar & cd ../ fi From d5abf2a4ccb5a6ee6b7f54e8e97daa405d3ba53c Mon Sep 17 00:00:00 2001 From: LDOUBLEV Date: Thu, 10 Feb 2022 10:04:17 +0800 Subject: [PATCH 2/6] add pse to benchmark --- .../det_r50_vd_pse_v2_0/det_r50_vd_pse.yml | 134 ++++++++++++++++++ .../train_infer_python.txt | 56 ++++++++ 2 files changed, 190 insertions(+) create mode 100644 test_tipc/configs/det_r50_vd_pse_v2_0/det_r50_vd_pse.yml create mode 100644 test_tipc/configs/det_r50_vd_pse_v2_0/train_infer_python.txt diff --git a/test_tipc/configs/det_r50_vd_pse_v2_0/det_r50_vd_pse.yml b/test_tipc/configs/det_r50_vd_pse_v2_0/det_r50_vd_pse.yml new file mode 100644 index 000000000..5ebc42527 --- /dev/null +++ b/test_tipc/configs/det_r50_vd_pse_v2_0/det_r50_vd_pse.yml @@ -0,0 +1,134 @@ +Global: + use_gpu: true + epoch_num: 600 + log_smooth_window: 20 + print_batch_step: 10 + save_model_dir: ./output/det_r50_vd_pse/ + save_epoch_step: 600 + # evaluation is run every 125 iterations + eval_batch_step: [ 0,1000 ] + cal_metric_during_train: False + pretrained_model: + checkpoints: #./output/det_r50_vd_pse_batch8_ColorJitter/best_accuracy + save_inference_dir: + use_visualdl: False + infer_img: doc/imgs_en/img_10.jpg + save_res_path: ./output/det_pse/predicts_pse.txt + +Architecture: + model_type: det + algorithm: PSE + Transform: + Backbone: + name: ResNet + layers: 50 + Neck: + name: FPN + out_channels: 256 + Head: + name: PSEHead + hidden_dim: 256 + out_channels: 7 + +Loss: + name: PSELoss + alpha: 0.7 + ohem_ratio: 3 + kernel_sample_mask: pred + reduction: none + +Optimizer: + name: Adam + beta1: 0.9 + beta2: 0.999 + lr: + name: Step + learning_rate: 0.0001 + step_size: 200 + gamma: 0.1 + regularizer: + name: 'L2' + factor: 0.0005 + +PostProcess: + name: PSEPostProcess + thresh: 0 + box_thresh: 0.85 + min_area: 16 + box_type: box # 'box' or 'poly' + scale: 1 + +Metric: + name: DetMetric + main_indicator: hmean + +Train: + dataset: + name: SimpleDataSet + data_dir: ./train_data/icdar2015/text_localization/ + label_file_list: + - ./train_data/icdar2015/text_localization/train_icdar2015_label.txt + ratio_list: [ 1.0 ] + transforms: + - DecodeImage: # load image + img_mode: BGR + channel_first: False + - DetLabelEncode: # Class handling label + - ColorJitter: + brightness: 0.12549019607843137 + saturation: 0.5 + - IaaAugment: + augmenter_args: + - { 'type': Resize, 'args': { 'size': [ 0.5, 3 ] } } + - { 'type': Fliplr, 'args': { 'p': 0.5 } } + - { 'type': Affine, 'args': { 'rotate': [ -10, 10 ] } } + - MakePseGt: + kernel_num: 7 + min_shrink_ratio: 0.4 + size: 640 + - RandomCropImgMask: + size: [ 640,640 ] + main_key: gt_text + crop_keys: [ 'image', 'gt_text', 'gt_kernels', 'mask' ] + - NormalizeImage: + scale: 1./255. + mean: [ 0.485, 0.456, 0.406 ] + std: [ 0.229, 0.224, 0.225 ] + order: 'hwc' + - ToCHWImage: + - KeepKeys: + keep_keys: [ 'image', 'gt_text', 'gt_kernels', 'mask' ] # the order of the dataloader list + loader: + shuffle: True + drop_last: False + batch_size_per_card: 8 + num_workers: 8 + +Eval: + dataset: + name: SimpleDataSet + data_dir: ./train_data/icdar2015/text_localization/ + label_file_list: + - ./train_data/icdar2015/text_localization/test_icdar2015_label.txt + ratio_list: [ 1.0 ] + transforms: + - DecodeImage: # load image + img_mode: BGR + channel_first: False + - DetLabelEncode: # Class handling label + - DetResizeForTest: + limit_side_len: 736 + limit_type: min + - NormalizeImage: + scale: 1./255. + mean: [ 0.485, 0.456, 0.406 ] + std: [ 0.229, 0.224, 0.225 ] + order: 'hwc' + - ToCHWImage: + - KeepKeys: + keep_keys: [ 'image', 'shape', 'polys', 'ignore_tags' ] + loader: + shuffle: False + drop_last: False + batch_size_per_card: 1 # must be 1 + num_workers: 8 \ No newline at end of file diff --git a/test_tipc/configs/det_r50_vd_pse_v2_0/train_infer_python.txt b/test_tipc/configs/det_r50_vd_pse_v2_0/train_infer_python.txt new file mode 100644 index 000000000..47e0d0e49 --- /dev/null +++ b/test_tipc/configs/det_r50_vd_pse_v2_0/train_infer_python.txt @@ -0,0 +1,56 @@ +===========================train_params=========================== +model_name:det_r50_vd_pse_v2_0 +python:python3.7 +gpu_list:0 +Global.use_gpu:True|True +Global.auto_cast:fp32 +Global.epoch_num:lite_train_lite_infer=1|whole_train_whole_infer=500 +Global.save_model_dir:./output/ +Train.loader.batch_size_per_card:lite_train_lite_infer=2|whole_train_whole_infer=4 +Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./train_data/icdar2015/text_localization/ch4_test_images/ +null:null +## +trainer:norm_train +norm_train:tools/train.py -c test_tipc/configs/det_r50_vd_pse_v2_0/det_r50_vd_pse.yml -o +pact_train:null +fpgm_train:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:null +null:null +## +===========================infer_params=========================== +Global.save_inference_dir:./output/ +Global.checkpoints: +norm_export:tools/export_model.py -c test_tipc/configs/det_r50_vd_pse_v2_0/det_r50_vd_pse.yml -o +quant_export:null +fpgm_export:null +distill_export:null +export1:null +export2:null +## +train_model:./inference/det_r50_vd_pse_v2.0_train/best_accuracy +infer_export:tools/export_model.py -c test_tipc/configs/det_r50_vd_pse_v2_0/det_r50_vd_pse.yml -o +infer_quant:False +inference:tools/infer/predict_det.py +--use_gpu:True|False +--enable_mkldnn:True|False +--cpu_threads:1|6 +--rec_batch_num:1 +--use_tensorrt:False +--precision:fp32|fp16|int8 +--det_model_dir: +--image_dir:./inference/ch_det_data_50/all-sum-510/ +--save_log_path:null +--benchmark:True +--det_algorithm:PSE +===========================train_benchmark_params========================== +batch_size:8 +fp_items:fp32|fp16 +epoch:2 +--profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile From cdabce67bdd79d61679659f480a26e96891b426b Mon Sep 17 00:00:00 2001 From: LDOUBLEV Date: Thu, 10 Feb 2022 10:07:02 +0800 Subject: [PATCH 3/6] add east --- .../det_r50_vd_east.yml | 0 .../train_infer_python.txt | 13 +++++++++---- test_tipc/prepare.sh | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) rename test_tipc/configs/{det_r50_vd_east_v2.0 => det_r50_vd_east_v2_0}/det_r50_vd_east.yml (100%) rename test_tipc/configs/{det_r50_vd_east_v2.0 => det_r50_vd_east_v2_0}/train_infer_python.txt (80%) diff --git a/test_tipc/configs/det_r50_vd_east_v2.0/det_r50_vd_east.yml b/test_tipc/configs/det_r50_vd_east_v2_0/det_r50_vd_east.yml similarity index 100% rename from test_tipc/configs/det_r50_vd_east_v2.0/det_r50_vd_east.yml rename to test_tipc/configs/det_r50_vd_east_v2_0/det_r50_vd_east.yml diff --git a/test_tipc/configs/det_r50_vd_east_v2.0/train_infer_python.txt b/test_tipc/configs/det_r50_vd_east_v2_0/train_infer_python.txt similarity index 80% rename from test_tipc/configs/det_r50_vd_east_v2.0/train_infer_python.txt rename to test_tipc/configs/det_r50_vd_east_v2_0/train_infer_python.txt index c7c8d0891..bc149ac8c 100644 --- a/test_tipc/configs/det_r50_vd_east_v2.0/train_infer_python.txt +++ b/test_tipc/configs/det_r50_vd_east_v2_0/train_infer_python.txt @@ -1,5 +1,5 @@ ===========================train_params=========================== -model_name:det_r50_vd_east_v2.0 +model_name:det_r50_vd_east_v2_0 python:python3.7 gpu_list:0 Global.use_gpu:True|True @@ -13,7 +13,7 @@ train_infer_img_dir:./train_data/icdar2015/text_localization/ch4_test_images/ null:null ## trainer:norm_train -norm_train:tools/train.py -c test_tipc/configs/det_r50_vd_east_v2.0/det_r50_vd_east.yml -o +norm_train:tools/train.py -c test_tipc/configs/det_r50_vd_east_v2_0/det_r50_vd_east.yml -o pact_train:null fpgm_train:null distill_train:null @@ -27,7 +27,7 @@ null:null ===========================infer_params=========================== Global.save_inference_dir:./output/ Global.checkpoints: -norm_export:tools/export_model.py -c test_tipc/configs/det_r50_vd_east_v2.0/det_r50_vd_east.yml -o +norm_export:tools/export_model.py -c test_tipc/configs/det_r50_vd_east_v2_0/det_r50_vd_east.yml -o quant_export:null fpgm_export:null distill_export:null @@ -35,7 +35,7 @@ export1:null export2:null ## train_model:./inference/det_r50_vd_east_v2.0_train/best_accuracy -infer_export:tools/export_model.py -c test_tipc/configs/det_r50_vd_east_v2.0/det_r50_vd_east.yml -o +infer_export:tools/export_model.py -c test_tipc/configs/det_r50_vd_east_v2_0/det_r50_vd_east.yml -o infer_quant:False inference:tools/infer/predict_det.py --use_gpu:True|False @@ -49,3 +49,8 @@ inference:tools/infer/predict_det.py --save_log_path:null --benchmark:True --det_algorithm:EAST +===========================train_benchmark_params========================== +batch_size:8 +fp_items:fp32|fp16 +epoch:2 +--profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile \ No newline at end of file diff --git a/test_tipc/prepare.sh b/test_tipc/prepare.sh index ea114697d..c78c321c3 100644 --- a/test_tipc/prepare.sh +++ b/test_tipc/prepare.sh @@ -231,7 +231,7 @@ elif [ ${MODE} = "whole_infer" ];then wget -nc -P ./inference/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/det_mv3_east_v2.0_train.tar --no-check-certificate cd ./inference/ && tar xf det_mv3_east_v2.0_train.tar & cd ../ fi - if [ ${model_name} == "det_r50_vd_east_v2.0" ]; then + if [ ${model_name} == "det_r50_vd_east_v2_0" ]; then wget -nc -P ./inference/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/det_r50_vd_east_v2.0_train.tar --no-check-certificate cd ./inference/ && tar xf det_r50_vd_east_v2.0_train.tar & cd ../ fi From 84da1a384d7f3a5bf9d3df07b92895cab55d2660 Mon Sep 17 00:00:00 2001 From: LDOUBLEV Date: Thu, 10 Feb 2022 10:23:44 +0800 Subject: [PATCH 4/6] add db r18 --- .../det_res18_vd_v2_0/train_infer_python.txt | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 test_tipc/configs/det_res18_vd_v2_0/train_infer_python.txt diff --git a/test_tipc/configs/det_res18_vd_v2_0/train_infer_python.txt b/test_tipc/configs/det_res18_vd_v2_0/train_infer_python.txt new file mode 100644 index 000000000..2b96d8438 --- /dev/null +++ b/test_tipc/configs/det_res18_vd_v2_0/train_infer_python.txt @@ -0,0 +1,56 @@ +===========================train_params=========================== +model_name:det_r18_db_v2_0 +python:python3.7 +gpu_list:0|0,1 +Global.use_gpu:True|True +Global.auto_cast:null +Global.epoch_num:lite_train_lite_infer=2|whole_train_whole_infer=300 +Global.save_model_dir:./output/ +Train.loader.batch_size_per_card:lite_train_lite_infer=2|whole_train_lite_infer=4 +Global.pretrained_model:null +train_model_name:latest +train_infer_img_dir:./train_data/icdar2015/text_localization/ch4_test_images/ +null:null +## +trainer:norm_train +norm_train:tools/train.py -c configs/det/det_res18_db_v2.0.yml -o +quant_export:null +fpgm_export:null +distill_train:null +null:null +null:null +## +===========================eval_params=========================== +eval:null +null:null +## +===========================infer_params=========================== +Global.save_inference_dir:./output/ +Global.checkpoints: +norm_export:null +quant_export:null +fpgm_export:null +distill_export:null +export1:null +export2:null +## +train_model:null +infer_export:null +infer_quant:False +inference:tools/infer/predict_det.py +--use_gpu:True|False +--enable_mkldnn:True|False +--cpu_threads:1|6 +--rec_batch_num:1 +--use_tensorrt:False|True +--precision:fp32|fp16|int8 +--det_model_dir: +--image_dir:./inference/ch_det_data_50/all-sum-510/ +--save_log_path:null +--benchmark:True +null:null +===========================train_benchmark_params========================== +batch_size:8|16 +fp_items:fp32|fp16 +epoch:2 +--profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile From 2fb88e66be3186a71c152cb5d0cccb3a920d7e53 Mon Sep 17 00:00:00 2001 From: LDOUBLEV Date: Thu, 10 Feb 2022 10:26:31 +0800 Subject: [PATCH 5/6] add db r18 --- .../{det_res18_vd_v2_0 => det_r18_vd_v2_0}/train_infer_python.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test_tipc/configs/{det_res18_vd_v2_0 => det_r18_vd_v2_0}/train_infer_python.txt (100%) diff --git a/test_tipc/configs/det_res18_vd_v2_0/train_infer_python.txt b/test_tipc/configs/det_r18_vd_v2_0/train_infer_python.txt similarity index 100% rename from test_tipc/configs/det_res18_vd_v2_0/train_infer_python.txt rename to test_tipc/configs/det_r18_vd_v2_0/train_infer_python.txt From 64edd41c277c60c672388be6d5764be85c1de43a Mon Sep 17 00:00:00 2001 From: LDOUBLEV Date: Thu, 10 Feb 2022 10:58:26 +0800 Subject: [PATCH 6/6] add benchmark to prepare.sh --- test_tipc/prepare.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_tipc/prepare.sh b/test_tipc/prepare.sh index 06f4d03b1..158b8cb8b 100644 --- a/test_tipc/prepare.sh +++ b/test_tipc/prepare.sh @@ -22,7 +22,7 @@ trainer_list=$(func_parser_value "${lines[14]}") if [ ${MODE} = "benchmark_train" ];then pip install -r requirements.txt - if [[ ${model_name} =~ "det_mv3_db_v2_0" ]];then + if [[ ${model_name} =~ "det_mv3_db_v2_0" || ${model_name} =~ "det_r50_vd_east_v2_0" || ${model_name} =~ "det_r50_vd_pse_v2_0" || ${model_name} =~ "det_r18_db_v2_0" ]];then rm -rf ./train_data/icdar2015 wget -nc -P ./pretrain_models/ https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/MobileNetV3_large_x0_5_pretrained.pdparams --no-check-certificate wget -nc -P ./train_data/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/icdar2015.tar --no-check-certificate