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
42.48k stars 7.66k forks source link

RE任务训练报错,The shape of tensor assigned value must match the shape of target shape: [512, 3], but now shape is [513, 3]. #8664

Closed ThinkSYR closed 7 months ago

ThinkSYR commented 1 year ago
KingBoomBoom commented 1 year ago

解决了吗

ThinkSYR commented 1 year ago

解决了吗

还没有

KingBoomBoom commented 1 year ago

https://paddleocr.bj.bcebos.com/ppstructure/whl/paddlenlp-2.3.0.dev0-py3-none-any.whl 有试过更新一下paddlenlp吗

ThinkSYR commented 1 year ago

https://paddleocr.bj.bcebos.com/ppstructure/whl/paddlenlp-2.3.0.dev0-py3-none-any.whl 有试过更新一下paddlenlp吗

有,我直接把paddlenlp更新到最新的2.4.5了,但还是不行

chowkamlee81 commented 1 year ago

Facing the same issue when iam mixing all the languages of XFUND dataset and training Relation extraction module.

KingBoomBoom commented 1 year ago

nlp 版本 改到2.3试过吗

ChidanandKumarVimaan commented 1 year ago

@KingBoomBoom ,

Played with different versions, problem still remains the same

ThinkSYR commented 1 year ago

@KingBoomBoom ,

Played with different versions, problem still remains the same

Facing the same issue when iam mixing all the languages of XFUND dataset and training Relation extraction module.

I have a deduction that there is still a bug in paddlenlp, but I cannot solve it. However, I have temporarily solved the problem from the data perspective. I noticed that this may be due to the length limit (max_seq_length=512) of the model input, which leads to the truncation of the content on the text. The result of the truncation is that some entity data (question or answer) is not input into the network. The total entity data is too small and paddlenlp does not handle it correctly, so the bug occurs. I think you may want to check whether there are some data in the dataset whose text length exceeds 512 or statistics the number of question or answer for each data and make the corresponding processing.

ChidanandKumarVimaan commented 1 year ago

@ThinkSYR , @KingBoomBoom I really feel in line:1235, interpreter gets inside the loop and allocates memory for (512,3) but it is assigned to memory of (513,3). It can be solved temproarily by allocating memory of (513,3). This problem can be eliminated. But code crashes still occur when creating meshgrid in line:1249 when all_possible_relations1 or all_possible_relations2 is emplty and meshgrid exception occurs. Is there is any way to come out of this exception. KIndly help

ThinkSYR commented 1 year ago

I really feel in line:1235, interpreter gets inside the loop and allocates memory for (512,3) but it is assigned to memory of (513,3). It can be solved temproarily by allocating memory of (513,3). This problem can be eliminated. But code crashes still occur when creating meshgrid in line:1249 when all_possible_relations1 or all_possible_relations2 is emplty and meshgrid exception occurs. Is there is any way to come out of this exception. KIndly help

Like you, I've done a lot of processing here but haven't been able to solve this bug. To solve this problem, it will probably be necessary to read this code more deeply. I think this is difficult, so I haven't started from this code to solve it. I hope paddlenlp can solve it.

ChidanandKumarVimaan commented 1 year ago

@ThinkSYR @KingBoomBoom Code is too buggy, it seems it works only on the dataset mentioned either with chinese data or simple data. I don't know how they have put results on paper saying "Multilingual training i.e Multi-task training acciuracy improves Relation extraction by more than 10%". I really feel that base code itself is not working Untill and unless from paddle team doesn't solve this issue, this KIE module is completely pathetic and too buggy.

ChidanandKumarVimaan commented 1 year ago

@ThinkSYR @KingBoomBoom

Code crashes because of https://github.com/PaddlePaddle/PaddleNLP/blob/2583b5ab68393545db68fd9631429de206bab270/paddlenlp/transformers/layoutxlm/modeling.py#L1248
all_possible_relations1.shape=0 and all_possible_relations2.shape=0 creating a meshgrid with size(0,0) raise an exception in paddle.meshgrid https://github.com/PaddlePaddle/PaddleNLP/blob/2583b5ab68393545db68fd9631429de206bab270/paddlenlp/transformers/layoutxlm/modeling.py#L1248

resulting in "Floating point exception(segmentation dumped)"

KingBoomBoom commented 1 year ago

how to solve

ChidanandKumarVimaan commented 1 year ago

This happens in the XFUND dataset of "IT" and "PT" language dataset.

KingBoomBoom commented 1 year ago

Own datasets are not compatible with XFUND's properties?

ChidanandKumarVimaan commented 1 year ago

Even i have used my own data, but this was not a serious issue. But i found this issue when i tried to mix all the languages of XFUND dataset. Particulatrly crashes happen because of "IT" and "PT" language datasets. But for my custom dataset, it worked well

binwang672012 commented 1 year ago

我用的自己的数据集,跑 SER没问题,但跑RE 遇到这个问题,跳过有异常的数据批次,最终eval 也很差。仔细排查数据的异常,把多对多,一对多,多对1的情况都剔除,只保留1对1的简单情况,但还是有这样的问题,现在还不确定是哪里的问题,心累,感觉要弃坑了。

Lz020316 commented 1 year ago

@ThinkSYR 请问您解决了这个问题了吗? 我也遇到了同样的问题

Tantao122200 commented 1 year ago

how ro solve this issue

github-actions[bot] commented 8 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

Tantao122200 commented 2 months ago

Env(环境) Paddle_TT(环境配置) python 3.8 paddlepaddle-gpu 2.5.1.post117 paddleocr 2.6.1.2

PPOCRLaber(打标签) 在本地windows中安装 安装命令如下: pip install paddlepaddle -i https://mirror.baidu.com/pypi/simple pip install ppocrlabel -i https://mirror.baidu.com/pypi/simple 在PPOCRLabel --lang ch --kie true中对需要检测的区域进行打标签,并导出识别和标记结果

det(文本检测) 下载pretrain_models, 为ch_PP-OCRv3_det_distill_train 进入configs配置 configs/det/ch_PP-OCRv3/ch_PP-OCRv3_det_student.yml(尤其注意size) 训练检测模型 python tools/train.py -c configs/det/ch_PP-OCRv3/ch_PP-OCRv3_det_student.yml (-o Global.checkpoints=model/det_result_v3/best_accuracy) 评估检测模型 python tools/infer_det.py -c configs/det/ch_PP-OCRv3/ch_PP-OCRv3_det_student.yml -o Global.pretrained_model=model/det_result_v3/best_accuracy.pdparams Global.infer_img=train_data/norm/tt/tt_02.jpg 变为推理模型 python tools/export_model.py -c configs/det/ch_PP-OCRv3/ch_PP-OCRv3_det_student.yml -o Global.pretrained_model=model/det_result_v3/best_accuracy.pdparams Global.save_inference_dir=model/det_inference 推理模型验证 python tools/infer/predict_det.py --det_model_dir=model/det_inference/ --image_dir=train_data/norm/tt/tt_02.jpg

rec(文本检测) 下载pretrain_models, 为ch_PP-OCRv3_rec_train 进入configs配置 configs/rec/PP-OCRv3/ch_PP-OCRv3_rec_distillation.yml 训练识别模型 python tools/train.py -c configs/rec/PP-OCRv3/ch_PP-OCRv3_rec_distillation.yml (-o Global.checkpoints=model/rec_result_v3/best_accuracy) 评估检测模型 python tools/infer_rec.py -c configs/rec/PP-OCRv3/ch_PP-OCRv3_rec_distillation.yml -o Global.pretrained_model=model/rec_result_v3/best_accuracy.pdparams Global.infer_img=train_data/norm/crop_img/tt2-01_crop_0.jpg 变为推理模型 python tools/export_model.py -c configs/rec/PP-OCRv3/ch_PP-OCRv3_rec_distillation.yml -o Global.pretrained_model=model/rec_result_v3/best_accuracy.pdparams Global.save_inference_dir=model/rec_inference 推理模型验证 python tools/infer/predict_rec.py --rec_model_dir=model/rec_inference/Student --image_dir=train_data/norm/crop_img/tt2-01_crop_0.jpg

det(文本检测) + rec(文本识别) 检测模型和文本模型验证 python tools/infer/predict_system.py --image_dir=train_data/norm/tt/tt_02.jpg --det_model_dir=model/det_inference/ --rec_model_dir=model/rec_inference/Student

SER(语义识别识别) 进入configs配置 configs/kie/vi_layoutxlm/ser_vi_layoutxlm_xfund_zh.yml 训练语义模型 python3 tools/train.py -c configs/kie/vi_layoutxlm/ser_vi_layoutxlm_xfund_zh.yml (-o Architecture.Backbone.checkpoints=model/ser_result/best_accuracy) 评估语义模型 python3 tools/infer_kie_token_ser.py -c configs/kie/vi_layoutxlm/ser_vi_layoutxlm_xfund_zh.yml -o Architecture.Backbone.checkpoints=model/ser_result/best_accuracy Global.infer_img=train_data/norm/tt/tt_02.jpg (Global.infer_img=train_data/norm/Label.txt Global.infer_mode=False) 变为推理模型 python3 tools/export_model.py -c configs/kie/vi_layoutxlm/ser_vi_layoutxlm_xfund_zh.yml -o Architecture.Backbone.checkpoints=model/ser_result/best_accuracy Global.save_inference_dir=model/ser_inference 推理模型验证 cd ppstructure python3 kie/predict_kie_token_ser.py --kie_algorithm=LayoutXLM --ser_model_dir=../model/ser_inference --image_dir=../train_data/norm/tt/tt_02.jpg --ser_dict_path=../ppocr/utils/dict/kie_dict/xfund_class_list.txt --vis_font_path=../doc/fonts/simfang.ttf --ocr_order_method="tb-yx" --det_model_dir=../model/det_inference --rec_model_dir=../model/rec_inference/Student

RE(关系提取) 进入configs配置 configs/kie/vi_layoutxlm/re_vi_layoutxlm_xfund_zh.yml 训练关系模型 python3 tools/train.py -c configs/kie/vi_layoutxlm/re_vi_layoutxlm_xfund_zh.yml (-o Architecture.Backbone.checkpoints=model/re_result/best_accuracy) 评估关系模型 python3 tools/infer_kie_token_ser_re.py -c configs/kie/vi_layoutxlm/re_vi_layoutxlm_xfund_zh.yml -o Architecture.Backbone.checkpoints=model/re_result/best_accuracy/ Global.infer_img=train_data/norm/tt/tt_02.jpg (Global.infer_img=train_data/norm/Label.txt Global.infer_mode=False) -c_ser configs/kie/vi_layoutxlm/ser_vi_layoutxlm_xfund_zh.yml -o_ser Architecture.Backbone.checkpoints=model/ser_result/best_accuracy 变为推理模型 python3 tools/export_model.py -c configs/kie/vi_layoutxlm/re_vi_layoutxlm_xfund_zh.yml -o Architecture.Backbone.checkpoints=model/re_result/best_accuracy Global.save_inference_dir=model/re_inference 推理模型验证 cd ppstructure python3 kie/predict_kie_token_ser_re.py --kie_algorithm=LayoutXLM --re_model_dir=../model/re_inference --ser_model_dir=../model/ser_inference --use_visual_backbone=false --image_dir=../train_data/norm/tt/tt_02.jpg --ser_dict_path=../ppocr/utils/dict/kie_dict/xfund_class_list.txt --vis_font_path=../doc/fonts/simfang.ttf --ocr_order_method="tb-yx" --det_model_dir=../model/det_inference --rec_model_dir=../model/rec_inference/Student

KIE(关键信息提取):SER(语义识别识别) + RE(关系提取) cd ppstructure python3 predict_system.py --kie_algorithm=LayoutXLM --re_model_dir=../model/re_inference --ser_model_dir=../model/ser_inference --use_visual_backbone=false --image_dir=../train_data/norm/tt/tt_02.jpg --ser_dict_path=../ppocr/utils/dict/kie_dict/xfund_class_list.txt --vis_font_path=../doc/fonts/simfang.ttf --ocr_order_method="tb-yx" --mode=kie --det_model_dir=../model/det_inference --rec_model_dir=../model/rec_inference/Student

谭涛 @.***

 

------------------ 原始邮件 ------------------ 发件人: "PaddlePaddle/PaddleOCR" @.>; 发送时间: 2024年6月20日(星期四) 下午4:44 @.>; @.**@.>; 主题: Re: [PaddlePaddle/PaddleOCR] RE任务训练报错,The shape of tensor assigned value must match the shape of target shape: [512, 3], but now shape is [513, 3]. (Issue #8664)

系统环境/System Environment:ubuntu

版本号/Version:paddlenlp: 2.4.5 paddlepaddle-gpu: 2.3.2.post101 PaddleOCR: latest

数据:自定义的数据,检查过了是没问题的,可视化也正确,链接: https://pan.baidu.com/s/1xdDQofFGe-SZkm3GJ8bikA 提取码: y5fa

运行指令/Command Code: nohup python tools/train.py -c configs/kie/exp/re_vi_layoutxlm_datazh.yml > exp/logs/re_data1_gen.log 2>&1 &
完整报错/Complete Error Message: [2022/12/19 20:40:45] ppocr INFO: Architecture : [2022/12/19 20:40:45] ppocr INFO: Backbone : [2022/12/19 20:40:45] ppocr INFO: checkpoints : None [2022/12/19 20:40:45] ppocr INFO: mode : vi [2022/12/19 20:40:45] ppocr INFO: name : LayoutXLMForRe [2022/12/19 20:40:45] ppocr INFO: pretrained : True [2022/12/19 20:40:45] ppocr INFO: Transform : None [2022/12/19 20:40:45] ppocr INFO: algorithm : LayoutXLM [2022/12/19 20:40:45] ppocr INFO: model_type : kie [2022/12/19 20:40:45] ppocr INFO: Eval : [2022/12/19 20:40:45] ppocr INFO: dataset : [2022/12/19 20:40:45] ppocr INFO: data_dir : train_data/data1/valid/image [2022/12/19 20:40:45] ppocr INFO: label_file_list : ['train_data/data1/valid/valid.json'] [2022/12/19 20:40:45] ppocr INFO: name : SimpleDataSet [2022/12/19 20:40:45] ppocr INFO: transforms : [2022/12/19 20:40:45] ppocr INFO: DecodeImage : [2022/12/19 20:40:45] ppocr INFO: channel_first : False [2022/12/19 20:40:45] ppocr INFO: img_mode : RGB [2022/12/19 20:40:45] ppocr INFO: VQATokenLabelEncode : [2022/12/19 20:40:45] ppocr INFO: algorithm : LayoutXLM [2022/12/19 20:40:45] ppocr INFO: class_path : train_data/XFUND/class_list_xfun.txt [2022/12/19 20:40:45] ppocr INFO: contains_re : True [2022/12/19 20:40:45] ppocr INFO: order_method : tb-yx [2022/12/19 20:40:45] ppocr INFO: use_textline_bbox_info : True [2022/12/19 20:40:45] ppocr INFO: VQATokenPad : [2022/12/19 20:40:45] ppocr INFO: max_seq_len : 512 [2022/12/19 20:40:45] ppocr INFO: return_attention_mask : True [2022/12/19 20:40:45] ppocr INFO: VQAReTokenRelation : None [2022/12/19 20:40:45] ppocr INFO: VQAReTokenChunk : [2022/12/19 20:40:45] ppocr INFO: max_seq_len : 512 [2022/12/19 20:40:45] ppocr INFO: TensorizeEntitiesRelations : None [2022/12/19 20:40:45] ppocr INFO: Resize : [2022/12/19 20:40:45] ppocr INFO: size : [224, 224] [2022/12/19 20:40:45] ppocr INFO: NormalizeImage : [2022/12/19 20:40:45] ppocr INFO: mean : [123.675, 116.28, 103.53] [2022/12/19 20:40:45] ppocr INFO: order : hwc [2022/12/19 20:40:45] ppocr INFO: scale : 1 [2022/12/19 20:40:45] ppocr INFO: std : [58.395, 57.12, 57.375] [2022/12/19 20:40:45] ppocr INFO: ToCHWImage : None [2022/12/19 20:40:45] ppocr INFO: KeepKeys : [2022/12/19 20:40:45] ppocr INFO: keep_keys : ['input_ids', 'bbox', 'attention_mask', 'token_type_ids', 'entities', 'relations'] [2022/12/19 20:40:45] ppocr INFO: loader : [2022/12/19 20:40:45] ppocr INFO: batch_size_per_card : 1 [2022/12/19 20:40:45] ppocr INFO: drop_last : False [2022/12/19 20:40:45] ppocr INFO: num_workers : 2 [2022/12/19 20:40:45] ppocr INFO: shuffle : False [2022/12/19 20:40:45] ppocr INFO: Global : [2022/12/19 20:40:45] ppocr INFO: cal_metric_during_train : False [2022/12/19 20:40:45] ppocr INFO: distributed : False [2022/12/19 20:40:45] ppocr INFO: epoch_num : 130 [2022/12/19 20:40:45] ppocr INFO: eval_batch_step : [0, 19] [2022/12/19 20:40:45] ppocr INFO: infer_img : ppstructure/docs/kie/input/zh_val_21.jpg [2022/12/19 20:40:45] ppocr INFO: kie_det_model_dir : None [2022/12/19 20:40:45] ppocr INFO: kie_rec_model_dir : None [2022/12/19 20:40:45] ppocr INFO: log_smooth_window : 10 [2022/12/19 20:40:45] ppocr INFO: print_batch_step : 10 [2022/12/19 20:40:45] ppocr INFO: save_epoch_step : 2000 [2022/12/19 20:40:45] ppocr INFO: save_inference_dir : None [2022/12/19 20:40:45] ppocr INFO: save_model_dir : ./output/re_vixlm_gen [2022/12/19 20:40:45] ppocr INFO: save_res_path : ./output/re/xfund_zh/with_gt [2022/12/19 20:40:45] ppocr INFO: seed : 2022 [2022/12/19 20:40:45] ppocr INFO: use_gpu : True [2022/12/19 20:40:45] ppocr INFO: use_visualdl : False [2022/12/19 20:40:45] ppocr INFO: Loss : [2022/12/19 20:40:45] ppocr INFO: key : loss [2022/12/19 20:40:45] ppocr INFO: name : LossFromOutput [2022/12/19 20:40:45] ppocr INFO: reduction : mean [2022/12/19 20:40:45] ppocr INFO: Metric : [2022/12/19 20:40:45] ppocr INFO: main_indicator : hmean [2022/12/19 20:40:45] ppocr INFO: name : VQAReTokenMetric [2022/12/19 20:40:45] ppocr INFO: Optimizer : [2022/12/19 20:40:45] ppocr INFO: beta1 : 0.9 [2022/12/19 20:40:45] ppocr INFO: beta2 : 0.999 [2022/12/19 20:40:45] ppocr INFO: clip_norm : 10 [2022/12/19 20:40:45] ppocr INFO: lr : [2022/12/19 20:40:45] ppocr INFO: learning_rate : 5e-05 [2022/12/19 20:40:45] ppocr INFO: warmup_epoch : 10 [2022/12/19 20:40:45] ppocr INFO: name : AdamW [2022/12/19 20:40:45] ppocr INFO: regularizer : [2022/12/19 20:40:45] ppocr INFO: factor : 0.0 [2022/12/19 20:40:45] ppocr INFO: name : L2 [2022/12/19 20:40:45] ppocr INFO: PostProcess : [2022/12/19 20:40:45] ppocr INFO: name : VQAReTokenLayoutLMPostProcess [2022/12/19 20:40:45] ppocr INFO: Train : [2022/12/19 20:40:45] ppocr INFO: dataset : [2022/12/19 20:40:45] ppocr INFO: data_dir : train_data/data1/train/image [2022/12/19 20:40:45] ppocr INFO: label_file_list : ['train_data/data1/train/train.json'] [2022/12/19 20:40:45] ppocr INFO: name : SimpleDataSet [2022/12/19 20:40:45] ppocr INFO: ratio_list : [1.0] [2022/12/19 20:40:45] ppocr INFO: transforms : [2022/12/19 20:40:45] ppocr INFO: DecodeImage : [2022/12/19 20:40:45] ppocr INFO: channel_first : False [2022/12/19 20:40:45] ppocr INFO: img_mode : RGB [2022/12/19 20:40:45] ppocr INFO: VQATokenLabelEncode : [2022/12/19 20:40:45] ppocr INFO: algorithm : LayoutXLM [2022/12/19 20:40:45] ppocr INFO: class_path : train_data/XFUND/class_list_xfun.txt [2022/12/19 20:40:45] ppocr INFO: contains_re : True [2022/12/19 20:40:45] ppocr INFO: order_method : tb-yx [2022/12/19 20:40:45] ppocr INFO: use_textline_bbox_info : True [2022/12/19 20:40:45] ppocr INFO: VQATokenPad : [2022/12/19 20:40:45] ppocr INFO: max_seq_len : 512 [2022/12/19 20:40:45] ppocr INFO: return_attention_mask : True [2022/12/19 20:40:45] ppocr INFO: VQAReTokenRelation : None [2022/12/19 20:40:45] ppocr INFO: VQAReTokenChunk : [2022/12/19 20:40:45] ppocr INFO: max_seq_len : 512 [2022/12/19 20:40:45] ppocr INFO: TensorizeEntitiesRelations : None [2022/12/19 20:40:45] ppocr INFO: Resize : [2022/12/19 20:40:45] ppocr INFO: size : [224, 224] [2022/12/19 20:40:45] ppocr INFO: NormalizeImage : [2022/12/19 20:40:45] ppocr INFO: mean : [123.675, 116.28, 103.53] [2022/12/19 20:40:45] ppocr INFO: order : hwc [2022/12/19 20:40:45] ppocr INFO: scale : 1 [2022/12/19 20:40:45] ppocr INFO: std : [58.395, 57.12, 57.375] [2022/12/19 20:40:45] ppocr INFO: ToCHWImage : None [2022/12/19 20:40:45] ppocr INFO: KeepKeys : [2022/12/19 20:40:45] ppocr INFO: keep_keys : ['input_ids', 'bbox', 'attention_mask', 'token_type_ids', 'entities', 'relations'] [2022/12/19 20:40:45] ppocr INFO: loader : [2022/12/19 20:40:45] ppocr INFO: batch_size_per_card : 1 [2022/12/19 20:40:45] ppocr INFO: drop_last : False [2022/12/19 20:40:45] ppocr INFO: num_workers : 4 [2022/12/19 20:40:45] ppocr INFO: shuffle : True [2022/12/19 20:40:45] ppocr INFO: profiler_options : None [2022/12/19 20:40:45] ppocr INFO: train with paddle 2.3.2 and device Place(gpu:0) [2022/12/19 20:40:45] ppocr INFO: Initialize indexs of datasets:['train_data/data1/train/train.json'] [2022-12-19 20:40:45,874] [ INFO] - Already cached /home/imcs/.paddlenlp/models/layoutxlm-base-uncased/sentencepiece.bpe.model [2022-12-19 20:40:46,227] [ INFO] - tokenizer config file saved in /home/imcs/.paddlenlp/models/layoutxlm-base-uncased/tokenizer_config.json [2022-12-19 20:40:46,228] [ INFO] - Special tokens file saved in /home/imcs/.paddlenlp/models/layoutxlm-base-uncased/special_tokens_map.json [2022/12/19 20:40:46] ppocr INFO: Initialize indexs of datasets:['train_data/data1/valid/valid.json'] [2022-12-19 20:40:46,229] [ INFO] - Already cached /home/imcs/.paddlenlp/models/layoutxlm-base-uncased/sentencepiece.bpe.model [2022-12-19 20:40:46,577] [ INFO] - tokenizer config file saved in /home/imcs/.paddlenlp/models/layoutxlm-base-uncased/tokenizer_config.json [2022-12-19 20:40:46,577] [ INFO] - Special tokens file saved in /home/imcs/.paddlenlp/models/layoutxlm-base-uncased/special_tokens_map.json [2022-12-19 20:40:46,578] [ INFO] - Already cached /home/imcs/.paddlenlp/models/vi-layoutxlm-base-uncased/model_state.pdparams W1219 20:40:46.579461 839 gpu_resources.cc:61] Please NOTE: device: 0, GPU Compute Capability: 7.5, Driver API Version: 10.1, Runtime API Version: 10.1 W1219 20:40:46.581184 839 gpu_resources.cc:91] device: 0, cuDNN Version: 7.6. [2022/12/19 20:40:48] ppocr INFO: train dataloader has 40 iters [2022/12/19 20:40:48] ppocr INFO: valid dataloader has 20 iters [2022/12/19 20:40:48] ppocr INFO: During the training process, after the 0th iteration, an evaluation is run every 19 iterations [2022/12/19 20:40:54] ppocr INFO: epoch: [1/130], global_step: 10, lr: 0.000001, loss: 0.836779, avg_reader_cost: 0.01602 s, avg_batch_cost: 0.61701 s, avg_samples: 1.0, ips: 1.62071 samples/s, eta: 0:53:22 eval model:: 20%|███████████████████▊ | 4/20 Traceback (most recent call last): File "/data/hsy/PPOCREXP/PaddleOCR/tools/train.py", line 208, in <module> main(config, device, logger, vdl_writer) File "/data/hsy/PPOCREXP/PaddleOCR/tools/train.py", line 180, in main program.train(config, train_dataloader, valid_dataloader, device, model, File "/data/hsy/PPOCREXP/PaddleOCR/tools/program.py", line 376, in train cur_metric = eval( File "/data/hsy/PPOCREXP/PaddleOCR/tools/program.py", line 519, in eval preds = model(batch) File "/data/xyd/miniconda3/envs/paddle23/lib/python3.8/site-packages/paddle/fluid/dygraph/layers.py", line 930, in call return self._dygraph_call_func(*inputs, kwargs) File "/data/xyd/miniconda3/envs/paddle23/lib/python3.8/site-packages/paddle/fluid/dygraph/layers.py", line 915, in _dygraph_call_func outputs = self.forward(*inputs, *kwargs) File "/data/hsy/PPOCREXP/PaddleOCR/ppocr/modeling/architectures/base_model.py", line 86, in forward x = self.backbone(x) File "/data/xyd/miniconda3/envs/paddle23/lib/python3.8/site-packages/paddle/fluid/dygraph/layers.py", line 930, in call return self._dygraph_call_func(inputs, kwargs) File "/data/xyd/miniconda3/envs/paddle23/lib/python3.8/site-packages/paddle/fluid/dygraph/layers.py", line 915, in _dygraph_call_func outputs = self.forward(*inputs, kwargs) File "/data/hsy/PPOCREXP/PaddleOCR/ppocr/modeling/backbones/vqa_layoutlm.py", line 228, in forward x = self.model( File "/data/xyd/miniconda3/envs/paddle23/lib/python3.8/site-packages/paddle/fluid/dygraph/layers.py", line 930, in call return self._dygraph_call_func(*inputs, *kwargs) File "/data/xyd/miniconda3/envs/paddle23/lib/python3.8/site-packages/paddle/fluid/dygraph/layers.py", line 915, in _dygraph_call_func outputs = self.forward(inputs, kwargs) File "/data/xyd/miniconda3/envs/paddle23/lib/python3.8/site-packages/paddlenlp/transformers/layoutxlm/modeling.py", line 1412, in forward loss, pred_relations = self.extractor(sequence_output, entities, relations) File "/data/xyd/miniconda3/envs/paddle23/lib/python3.8/site-packages/paddle/fluid/dygraph/layers.py", line 930, in call return self._dygraph_call_func(*inputs, *kwargs) File "/data/xyd/miniconda3/envs/paddle23/lib/python3.8/site-packages/paddle/fluid/dygraph/layers.py", line 915, in _dygraph_call_func outputs = self.forward(inputs, **kwargs) File "/data/xyd/miniconda3/envs/paddle23/lib/python3.8/site-packages/paddlenlp/transformers/layoutxlm/modeling.py", line 1304, in forward relations, entities = self.build_relation(relations, entities) File "/data/xyd/miniconda3/envs/paddle23/lib/python3.8/site-packages/paddlenlp/transformers/layoutxlm/modeling.py", line 1241, in build_relation entities[b] = entitie_new File "/data/xyd/miniconda3/envs/paddle23/lib/python3.8/site-packages/paddle/fluid/dygraph/varbase_patch_methods.py", line 786, in setitem return self.__setitem_varbase__(item, value) ValueError: (InvalidArgument) The shape of tensor assigned value must match the shape of target shape: [512, 3], but now shape is [513, 3]. (at /paddle/paddle/phi/kernels/impl/set_value_kernel_impl.h:69) [operator < set_value > error] eval model:: 25%|████████████████████████▊ | 5/20 [00:00<00:01, 9.91it/s]
记录:我使用XFUND的数据训练是不会报错的,用自定义数据训练(数据在上面的网盘里)报了上面这个错,我debug了一下这两次训练,发现当我使用自定义数据的时候,应该是paddlenlp这里有个特殊处理报错了,但我怎么改都会报错,希望能帮忙看一下是什么问题

遇到一样的错误,请问大佬解决了吗?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

Royhuiy commented 2 months ago

@binwang672012 请问最后有解决这个bug吗?

Royhuiy commented 2 months ago

@ChidanandKumarVimaan i got same error, how did you resolve it?