PaddleOCR icon indicating copy to clipboard operation
PaddleOCR copied to clipboard

Error when training the KIE model vi_layoutxlm unexpected keyword argument 'num_classes' for LayoutXLMForTokenClassification.__init__()

Open andreaIskanderBelkhir opened this issue 1 year ago • 8 comments

请提供下述完整信息以便快速定位问题/Please provide the following information to quickly locate the problem:

I tryed to train a model using the config file present in the config like i did 2 month ago (the only thing that i changed is the folder for the dataset) but now give me this error, if i remove the keyword it give me a error where i miss the argument for LayoutXLMForSer.

  • 系统环境/System Environment:Colab
  • 版本号/Version:Paddle:2.5.2 PaddleOCR: 问题相关组件/Related components:
  • 运行指令/Command Code:%run tools/train.py -c configs/kie/vi_layoutxlm/ser_vi_layoutxlm_xfund_zh.yml
  • 完整报错/Complete Error Message:TypeError: LayoutXLMForTokenClassification.init() got an unexpected keyword argument 'num_classes'

请尽量不要包含图片在问题中/Please try to not include the image in the issue.

andreaIskanderBelkhir avatar Sep 12 '23 09:09 andreaIskanderBelkhir

hi, bor 我也遇到了同样问题

HuiGitH avatar Sep 13 '23 14:09 HuiGitH

@andyjpaddle

应该和PaddleNLP的这次改动有关 "新增configuration 模型支持config"

https://github.com/PaddlePaddle/PaddleNLP/pull/5637/commits/27936b6b21298d306b254165baafbc285b7562ac#diff-2742b8e7477bc6c550f7ac3a94fe8bbe2f3726eef2b56cdac75d187e9f9a44fc paddlenlp/transformers/layoutxlm/modeling.py line 837 image

HuiGitH avatar Sep 13 '23 16:09 HuiGitH

我也遇到同样问题

  • 系统环境: ubuntu 20.04
  • 版本号: paddlepaddle 2.5.1 paddleocr 2.7.0.3 paddlenlp 2.6.1
  • 运行指令: python tools/train.py -c configs/kie/vi_layoutxlm/ser_vi_layoutxlm_xfund_zh.yml
  • 完整报错: envs/paddle_env/lib/python3.8/site-packages/paddlenlp/transformers/utils.py", line 253, in impl init_func(self, *args, **kwargs) TypeError: init() got an unexpected keyword argument 'num_classes'

pjh714332048 avatar Sep 25 '23 09:09 pjh714332048

我也遇到同样问题

  • 系统环境: Mac Pro
  • 版本号: paddlepaddle 2.5.1 paddleocr 2.7.0.3 paddlenlp 2.6.1
  • 运行指令: python tools/train.py -c configs/kie/vi_layoutxlm/ser_vi_layoutxlm_xfund_zh.yml
  • 完整报错: File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/paddlenlp/transformers/utils.py", line 253, in impl init_func(self, *args, **kwargs) TypeError: LayoutXLMForTokenClassification.init() got an unexpected keyword argument 'num_classes'

jinyichao avatar Nov 07 '23 08:11 jinyichao

把paddlenlp的版本退回到2.5.2可以暂时解决这个问题,让训练跑起来

jinyichao avatar Nov 07 '23 08:11 jinyichao

我也遇到同样问题

  • 系统环境: ubuntu 20.04
  • 版本号: paddlepaddle 2.5.1 paddleocr 2.7.0.3 paddlenlp 2.6.1
  • 运行指令: python tools/train.py -c configs/kie/vi_layoutxlm/ser_vi_layoutxlm_xfund_zh.yml
  • 完整报错: envs/paddle_env/lib/python3.8/site-packages/paddlenlp/transformers/utils.py", line 253, in impl init_func(self, *args, **kwargs) TypeError: init() got an unexpected keyword argument 'num_classes'

Have you fix this ? I am facing the sam issue

L-Q-K avatar Feb 29 '24 03:02 L-Q-K

这个问题有动静么? 我也遇到了。

caohrong avatar Mar 27 '24 10:03 caohrong

PaddleOCR和PaddleNLP版本问题,目前发现可行的版本匹配方案: 1、PaddleOCR<=2.7.0 + PaddleNLP==2.5.2 2、PaddleOCR>=2.7.1 + PaddleNLP>=2.6.0

huanghao128 avatar Apr 18 '24 02:04 huanghao128