re_vi_layoutxlm_xfund_zh.yml 3.4 KB
Newer Older
1 2
Global:
  use_gpu: True
littletomatodonkey's avatar
littletomatodonkey 已提交
3
  epoch_num: &epoch_num 130
4 5
  log_smooth_window: 10
  print_batch_step: 10
littletomatodonkey's avatar
littletomatodonkey 已提交
6
  save_model_dir: ./output/re_vi_layoutxlm_xfund_zh
7 8
  save_epoch_step: 2000
  # evaluation is run every 10 iterations after the 0th iteration
文幕地方's avatar
文幕地方 已提交
9
  eval_batch_step: [ 0, 19 ]
10 11 12
  cal_metric_during_train: False
  save_inference_dir:
  use_visualdl: False
文幕地方's avatar
文幕地方 已提交
13
  seed: 2022
14
  infer_img: ppstructure/docs/kie/input/zh_val_21.jpg
littletomatodonkey's avatar
littletomatodonkey 已提交
15
  save_res_path: ./output/re/xfund_zh/with_gt
16 17
  kie_rec_model_dir: 
  kie_det_model_dir:
18 19

Architecture:
20
  model_type: kie
21 22 23 24
  algorithm: &algorithm "LayoutXLM"
  Transform:
  Backbone:
    name: LayoutXLMForRe
文幕地方's avatar
文幕地方 已提交
25
    pretrained: True
littletomatodonkey's avatar
littletomatodonkey 已提交
26
    mode: vi
文幕地方's avatar
文幕地方 已提交
27
    checkpoints:
28 29 30 31 32 33 34 35 36 37 38 39

Loss:
  name: LossFromOutput
  key: loss
  reduction: mean

Optimizer:
  name: AdamW
  beta1: 0.9
  beta2: 0.999
  clip_norm: 10
  lr:
文幕地方's avatar
文幕地方 已提交
40 41
    learning_rate: 0.00005
    warmup_epoch: 10
42
  regularizer:
文幕地方's avatar
文幕地方 已提交
43
    name: L2
44 45 46 47 48 49 50 51 52 53 54 55 56 57
    factor: 0.00000
    
PostProcess:
  name: VQAReTokenLayoutLMPostProcess

Metric:
  name: VQAReTokenMetric
  main_indicator: hmean

Train:
  dataset:
    name: SimpleDataSet
    data_dir: train_data/XFUND/zh_train/image
    label_file_list: 
58
      - train_data/XFUND/zh_train/train.json
59 60 61 62 63 64 65 66
    ratio_list: [ 1.0 ]
    transforms:
      - DecodeImage: # load image
          img_mode: RGB
          channel_first: False
      - VQATokenLabelEncode: # Class handling label
          contains_re: True
          algorithm: *algorithm
67
          class_path: &class_path train_data/XFUND/class_list_xfun.txt
littletomatodonkey's avatar
littletomatodonkey 已提交
68 69
          use_textline_bbox_info: &use_textline_bbox_info True
          order_method: &order_method "tb-yx"
70 71 72 73 74 75
      - VQATokenPad:
          max_seq_len: &max_seq_len 512
          return_attention_mask: True
      - VQAReTokenRelation:
      - VQAReTokenChunk:
          max_seq_len: *max_seq_len
文幕地方's avatar
文幕地方 已提交
76
      - TensorizeEntitiesRelations:
77 78 79 80 81 82 83 84 85
      - Resize:
          size: [224,224]
      - NormalizeImage:
          scale: 1
          mean: [ 123.675, 116.28, 103.53 ]
          std: [ 58.395, 57.12, 57.375 ]
          order: 'hwc'
      - ToCHWImage:
      - KeepKeys:
文幕地方's avatar
fix bug  
文幕地方 已提交
86
          keep_keys: [ 'input_ids', 'bbox','attention_mask', 'token_type_ids', 'entities', 'relations'] # dataloader will return list in this order
87 88 89
  loader:
    shuffle: True
    drop_last: False
littletomatodonkey's avatar
littletomatodonkey 已提交
90 91
    batch_size_per_card: 2
    num_workers: 4
92 93 94 95 96 97

Eval:
  dataset:
    name: SimpleDataSet
    data_dir: train_data/XFUND/zh_val/image
    label_file_list:
98
      - train_data/XFUND/zh_val/val.json
99 100 101 102 103 104 105 106
    transforms:
      - DecodeImage: # load image
          img_mode: RGB
          channel_first: False
      - VQATokenLabelEncode: # Class handling label
          contains_re: True
          algorithm: *algorithm
          class_path: *class_path
littletomatodonkey's avatar
littletomatodonkey 已提交
107 108
          use_textline_bbox_info: *use_textline_bbox_info
          order_method: *order_method
109 110 111 112 113 114
      - VQATokenPad:
          max_seq_len: *max_seq_len
          return_attention_mask: True
      - VQAReTokenRelation:
      - VQAReTokenChunk:
          max_seq_len: *max_seq_len
文幕地方's avatar
文幕地方 已提交
115
      - TensorizeEntitiesRelations:
116 117 118 119 120 121 122 123 124
      - Resize:
          size: [224,224]
      - NormalizeImage:
          scale: 1
          mean: [ 123.675, 116.28, 103.53 ]
          std: [ 58.395, 57.12, 57.375 ]
          order: 'hwc'
      - ToCHWImage:
      - KeepKeys:
文幕地方's avatar
fix bug  
文幕地方 已提交
125
          keep_keys: [ 'input_ids', 'bbox', 'attention_mask', 'token_type_ids', 'entities', 'relations'] # dataloader will return list in this order
126 127 128 129
  loader:
    shuffle: False
    drop_last: False
    batch_size_per_card: 8
文幕地方's avatar
文幕地方 已提交
130
    num_workers: 8