소스 검색

新增SLANeXt、SLANeXt_wireless、SLANet、SLANet_plus及SLANet_plus_paddleocr配置文件,包含数据集路径、训练参数及模型导出设置

zhch158_admin 3 달 전
부모
커밋
0f44d964eb

+ 39 - 0
zhch/table_structure_recognition/SLANeXt_wired.yaml

@@ -0,0 +1,39 @@
+Global:
+  model: SLANeXt_wired
+  mode: check_dataset # check_dataset/train/evaluate/predict
+  dataset_dir: "/paddle/dataset/paddlex/table_rec/table_rec_dataset_examples"
+  device: gpu:0,1,2,3
+  output: "output"
+
+CheckDataset:
+  convert:
+    enable: False
+    src_dataset_type: null
+  split:
+    enable: False
+    train_percent: null
+    val_percent: null
+
+Train:
+  epochs_iters: 10
+  batch_size: 16
+  learning_rate: 0.001
+  pretrain_weight_path: "https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/SLANeXt_wired_pretrained.pdparams"
+  resume_path: null
+  log_interval: 20
+  eval_interval: 1
+  save_interval: 1
+
+Evaluate:
+  weight_path: "output/best_accuracy/best_accuracy.pdparams"
+  log_interval: 1
+
+Export:
+  weight_path: "https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/SLANeXt_wired_pretrained.pdparams"
+
+Predict:
+  batch_size: 1
+  model_dir: "output/best_accuracy/inference"
+  input: "https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/table_recognition.jpg"
+  kernel_option:
+    run_mode: paddle

+ 39 - 0
zhch/table_structure_recognition/SLANeXt_wireless.yaml

@@ -0,0 +1,39 @@
+Global:
+  model: SLANeXt_wireless
+  mode: check_dataset # check_dataset/train/evaluate/predict
+  dataset_dir: "/paddle/dataset/paddlex/table_rec/table_rec_dataset_examples"
+  device: gpu:0,1,2,3
+  output: "output"
+
+CheckDataset:
+  convert:
+    enable: False
+    src_dataset_type: null
+  split:
+    enable: False
+    train_percent: null
+    val_percent: null
+
+Train:
+  epochs_iters: 10
+  batch_size: 16
+  learning_rate: 0.001
+  pretrain_weight_path: "https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/SLANeXt_wireless_pretrained.pdparams"
+  resume_path: null
+  log_interval: 20
+  eval_interval: 1
+  save_interval: 1
+
+Evaluate:
+  weight_path: "output/best_accuracy/best_accuracy.pdparams"
+  log_interval: 1
+
+Export:
+  weight_path: "https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/SLANeXt_wireless_pretrained.pdparams"
+
+Predict:
+  batch_size: 1
+  model_dir: "output/best_accuracy/inference"
+  input: "https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/table_recognition.jpg"
+  kernel_option:
+    run_mode: paddle

+ 39 - 0
zhch/table_structure_recognition/SLANet.yaml

@@ -0,0 +1,39 @@
+Global:
+  model: SLANet
+  mode: check_dataset # check_dataset/train/evaluate/predict
+  dataset_dir: "/paddle/dataset/paddlex/table_rec/table_rec_dataset_examples"
+  device: gpu:0,1,2,3
+  output: "output"
+
+CheckDataset:
+  convert:
+    enable: False
+    src_dataset_type: null
+  split:
+    enable: False
+    train_percent: null
+    val_percent: null
+
+Train:
+  epochs_iters: 10
+  batch_size: 48
+  learning_rate: 0.001
+  pretrain_weight_path: https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/SLANet_pretrained.pdparams
+  resume_path: null
+  log_interval: 20
+  eval_interval: 1
+  save_interval: 1
+
+Evaluate:
+  weight_path: "output/best_accuracy/best_accuracy.pdparams"
+  log_interval: 1
+
+Export:
+  weight_path: https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/SLANet_pretrained.pdparams
+
+Predict:
+  batch_size: 1
+  model_dir: "output/best_accuracy/inference"
+  input: "https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/table_recognition.jpg"
+  kernel_option:
+    run_mode: paddle

+ 32 - 0
zhch/table_structure_recognition/SLANet_plus.yaml

@@ -0,0 +1,32 @@
+Global:
+  model: SLANet_plus
+  mode: check_dataset # check_dataset/train/evaluate/predict
+  dataset_dir: "/Users/zhch158/workspace/repository.git/PaddleX/dataset/table_rec_dataset_examples"
+  device: cpu
+  output: "/Users/zhch158/workspace/repository.git/PaddleX/zhch/table_structure_recognition/output"
+  use_sync_bn: False  # 移动到这里!
+  distributed: False  # 也添加这个确保不使用分布式
+
+CheckDataset:
+  convert:
+    enable: False
+    src_dataset_type: null
+  split:
+    enable: False
+    train_percent: null
+    val_percent: null
+
+Train:
+  epochs_iters: 10
+  batch_size: 8  # 减少batch_size,CPU训练建议使用较小值
+  learning_rate: 0.001
+  pretrain_weight_path: https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/SLANet_plus_pretrained.pdparams
+  resume_path: null
+  log_interval: 20
+  eval_interval: 1
+  save_interval: 1
+
+Evaluate:
+  # weight_path: "output/best_accuracy/best_accuracy.pdparams"
+  weight_path: "/Users/zhch158/.paddleocr/models/SLANet_plus_pretrained.pdparams"
+  log_interval: 1

+ 143 - 0
zhch/table_structure_recognition/SLANet_plus_paddleocr.yml

@@ -0,0 +1,143 @@
+Global:
+  model_name: SLANet_plus # To use static model for inference.
+  use_gpu: False          # 使用CPU
+  epoch_num: 8              # 可适当增加训练轮数
+  log_smooth_window: 10   # 日志平滑窗口
+  print_batch_step: 10    # 每10个batch打印一次日志
+  save_model_dir: ./output/SLANet_plus
+  save_epoch_step: 2      # 每2个epoch保存一次模型
+  # evaluation is run every 331 iterations after the 0th iteration
+  eval_batch_step: [0, 50]  # 更频繁评估
+  cal_metric_during_train: True
+  pretrained_model: "https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/SLANet_plus_pretrained.pdparams"
+  checkpoints: 
+  save_inference_dir: ./output/SLANet_plus/infer
+  use_visualdl: False
+  infer_img: paddlex/repo_manager/repos/PaddleOCR/ppstructure/docs/table/table.jpg
+  # for data or label process
+  character_dict_path: paddlex/repo_manager/repos/PaddleOCR/ppocr/utils/dict/table_structure_dict_ch.txt
+  character_type: en
+  max_text_length: &max_text_length 500
+  box_format: &box_format xyxyxyxy # 'xywh', 'xyxy', 'xyxyxyxy'
+  infer_mode: False
+  use_sync_bn: False      # 是否使用同步BN, Mac必须关闭
+  save_res_path: output/infer
+  d2s_train_image_shape: [3, 488, 488]
+
+Optimizer:
+  name: Adam
+  beta1: 0.9
+  beta2: 0.999
+  clip_norm: 5.0
+  lr:
+    learning_rate: 0.0008    # 微调学习率
+  regularizer:
+    name: 'L2'
+    factor: 0.00000
+
+Architecture:
+  model_type: table
+  algorithm: SLANet
+  Backbone:
+    name: PPLCNet
+    scale: 1.0
+    pretrained: True
+    use_ssld: True
+  Neck:
+    name: CSPPAN
+    out_channels: 96
+  Head:
+    name: SLAHead
+    hidden_size: 256
+    max_text_length: *max_text_length
+    loc_reg_num: &loc_reg_num 8
+
+Loss:
+  name: SLALoss
+  structure_weight: 1.0
+  loc_weight: 2.0
+  loc_loss: smooth_l1
+
+PostProcess:
+  name: TableLabelDecode
+  merge_no_span_structure: &merge_no_span_structure True
+
+Metric:
+  name: TableMetric
+  main_indicator: acc
+  compute_bbox_metric: False
+  loc_reg_num: *loc_reg_num
+  box_format: *box_format
+  del_thead_tbody: True
+
+Train:
+  dataset:
+    name: PubTabDataSet
+    data_dir: dataset/table_rec_dataset_examples/          # ✅ 正确路径
+    label_file_list: [dataset/table_rec_dataset_examples/train.txt]  # ✅ 正确文件
+    transforms:
+      - DecodeImage:
+          img_mode: BGR
+          channel_first: False
+      - TableLabelEncode:
+          learn_empty_box: False
+          merge_no_span_structure: *merge_no_span_structure
+          replace_empty_cell_token: False
+          loc_reg_num: *loc_reg_num
+          max_text_length: *max_text_length
+      - TableBoxEncode:
+          in_box_format: *box_format
+          out_box_format: *box_format
+      - ResizeTableImage:
+          max_len: 488
+      - NormalizeImage:
+          scale: 1./255.
+          mean: [0.485, 0.456, 0.406]
+          std: [0.229, 0.224, 0.225]
+          order: 'hwc'
+      - PaddingTableImage:
+          size: [488, 488]
+      - ToCHWImage:
+      - KeepKeys:
+          keep_keys: ['image', 'structure', 'bboxes', 'bbox_masks', 'length', 'shape']
+  loader:
+    shuffle: True
+    batch_size_per_card: 32            # 减小batch_size提高稳定性
+    drop_last: True                    # 丢弃不完整的最后一个batch
+    num_workers: 2                     # 减少worker数量,避免CPU负载过高
+
+Eval:
+  dataset:
+    name: PubTabDataSet
+    data_dir: dataset/table_rec_dataset_examples/          # ✅ 正确路径
+    label_file_list: [dataset/table_rec_dataset_examples/val.txt]    # ✅ 正确文件
+    transforms:
+      - DecodeImage:
+          img_mode: BGR
+          channel_first: False
+      - TableLabelEncode:
+          learn_empty_box: False
+          merge_no_span_structure: *merge_no_span_structure
+          replace_empty_cell_token: False
+          loc_reg_num: *loc_reg_num
+          max_text_length: *max_text_length
+      - TableBoxEncode:
+          in_box_format: *box_format
+          out_box_format: *box_format
+      - ResizeTableImage:
+          max_len: 488
+      - NormalizeImage:
+          scale: 1./255.
+          mean: [0.485, 0.456, 0.406]
+          std: [0.229, 0.224, 0.225]
+          order: 'hwc'
+      - PaddingTableImage:
+          size: [488, 488]
+      - ToCHWImage:
+      - KeepKeys:
+          keep_keys: ['image', 'structure', 'bboxes', 'bbox_masks', 'length', 'shape']
+  loader:
+    shuffle: False
+    drop_last: False
+    batch_size_per_card: 48
+    num_workers: 1