PaddlePaddle / PaddleOCR

Awesome multilingual OCR toolkits based on PaddlePaddle (practical ultra lightweight OCR system, support 80+ languages recognition, provide data annotation and synthesis tools, support training and deployment among server, mobile, embedded and IoT devices)
https://paddlepaddle.github.io/PaddleOCR/
Apache License 2.0
44.37k stars 7.83k forks source link

Error in exporting custom trained RE model #8273

Closed Tanmay98 closed 2 years ago

Tanmay98 commented 2 years ago

I am able to produce evaluations using the best_model model files for my custom trained RE model but when I try to export it I get the following error. I have also attached the config .yml file for my RE model.

Traceback (most recent call last): File "tools/export_model.py", line 256, in main() File "tools/export_model.py", line 252, in main model, arch_config, save_path, logger, input_shape=input_shape) File "tools/export_model.py", line 172, in export_single_model paddle.jit.save(model, save_path) File "/usr/local/lib/python3.7/dist-packages/paddle/fluid/dygraph/jit.py", line 631, in wrapper func(layer, path, input_spec, configs) File "", line 2, in save File "/usr/local/lib/python3.7/dist-packages/paddle/fluid/wrapped_decorator.py", line 25, in impl return wrapped_func(*args, *kwargs) File "/usr/local/lib/python3.7/dist-packages/paddle/fluid/dygraph/base.py", line 51, in impl return func(args, kwargs) File "/usr/local/lib/python3.7/dist-packages/paddle/fluid/dygraph/jit.py", line 861, in save inner_input_spec, with_hook=with_hook) File "/usr/local/lib/python3.7/dist-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 528, in concrete_program_specify_input_spec *desired_input_spec, with_hook=with_hook) File "/usr/local/lib/python3.7/dist-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 436, in get_concrete_program concrete_program, partial_program_layer = self._program_cache[cache_key] File "/usr/local/lib/python3.7/dist-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 801, in getitem self._caches[item_id] = self._build_once(item) File "/usr/local/lib/python3.7/dist-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 790, in _build_once cache_key.kwargs) File "", line 2, in from_func_spec File "/usr/local/lib/python3.7/dist-packages/paddle/fluid/wrapped_decorator.py", line 25, in impl return wrapped_func(*args, *kwargs) File "/usr/local/lib/python3.7/dist-packages/paddle/fluid/dygraph/base.py", line 51, in impl return func(args, kwargs) File "/usr/local/lib/python3.7/dist-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 740, in from_func_spec error_data.raise_new_exception() File "/usr/local/lib/python3.7/dist-packages/paddle/fluid/dygraph/dygraph_to_static/error.py", line 336, in raise_newexception six.exec("raise new_exception from None") File "", line 1, in IndexError: In transformed code:

File "/content/drive/MyDrive/PaddleOCR/ppocr/modeling/architectures/base_model.py", line 86, in forward
x = self.backbone(x)
File "/content/drive/MyDrive/PaddleOCR/ppocr/modeling/backbones/vqa_layoutlm.py", line 234, in forward
        head_mask=None,
        labels=None,
        entities=x[5],
        ~~~~~~~~~~~~~~ <--- HERE
        relations=x[6])
    return x

IndexError: list index out of range

Global: use_gpu: True epoch_num: &epoch_num 130 log_smooth_window: 10 print_batch_step: 10 save_model_dir: ./output/re_vi_layoutxlm_mca save_epoch_step: 2000

evaluation is run every 10 iterations after the 0th iteration

eval_batch_step: [ 0, 19 ] cal_metric_during_train: False save_inference_dir: use_visualdl: False seed: 2022 infer_img: ppstructure/docs/kie/input/temp.jpg save_res_path: ./output/re/mca/with_gt kie_rec_model_dir: kie_det_model_dir:

Architecture: model_type: kie algorithm: &algorithm "LayoutXLM" Transform: Backbone: name: LayoutXLMForRe pretrained: True mode: vi checkpoints:

Loss: name: LossFromOutput key: loss reduction: mean

Optimizer: name: AdamW beta1: 0.9 beta2: 0.999 clip_norm: 10 lr: learning_rate: 0.00005 warmup_epoch: 10 regularizer: name: L2 factor: 0.00000

PostProcess: name: VQAReTokenLayoutLMPostProcess

Metric: name: VQAReTokenMetric main_indicator: hmean

Train: dataset: name: SimpleDataSet data_dir: train_data/mca/mca_train/image label_file_list:

Eval: dataset: name: SimpleDataSet data_dir: train_data/mca/mca_val/image label_file_list:

Tanmay98 commented 2 years ago

Also, just to mention,

littletomatodonkey commented 2 years ago

hi , you need to upgrade paddlenlp to 2.4.1

pip install paddlenlp==2.4.1
Tanmay98 commented 2 years ago

Thanks @littletomatodonkey !, both of the above issues were resolved by updating paddlenlp to 2.4.1 from 2.3 version