-
系统环境/System Environment:Ubuntu
-
版本号/Version:Paddle v2.5: PaddleOCR: 问题相关组件/Related components: ppocr/modeling/necks/db_fpn.py
-
运行指令/Command Code:python tools/train.py -c ./ch_PP-OCRv4_det_cml.yml
-
使用ch_PP-OCRv4_det訓連模型進行fintune時,將 ch_PP-OCRv4_det_cml.yml 中的 Backbone name: PPLCNetNew 找不到對應模型,如果改成PPLCNetNewV3則會報錯 for i in range(len(in_channels)):TypeError: object of type 'int' has no len() 可以麻煩請教一下原因嗎?謝謝。
-
完整报错/Complete Error Message:
-
Traceback (most recent call last): File "/home/cjwang/cjwang/PaddleOCR-release-2.7/tools/train.py", line 227, in
main(config, device, logger, vdl_writer) File "/home/cjwang/cjwang/PaddleOCR-release-2.7/tools/train.py", line 135, in main model = build_model(config['Architecture']) File "/home/cjwang/cjwang/PaddleOCR-release-2.7/ppocr/modeling/architectures/init.py", line 34, in build_model arch = getattr(mod, name)(config) File "/home/cjwang/cjwang/PaddleOCR-release-2.7/ppocr/modeling/architectures/distillation_model.py", line 47, in init model = BaseModel(model_config) File "/home/cjwang/cjwang/PaddleOCR-release-2.7/ppocr/modeling/architectures/base_model.py", line 67, in init self.neck = build_neck(config['Neck']) File "/home/cjwang/cjwang/PaddleOCR-release-2.7/ppocr/modeling/necks/init.py", line 42, in build_neck module_class = eval(module_name)(**config) File "/home/cjwang/cjwang/PaddleOCR-release-2.7/ppocr/modeling/necks/db_fpn.py", line 240, in init for i in range(len(in_channels)): TypeError: object of type 'int' has no len()
[PaddlePaddle/PaddleOCR]PPLCNetNew找不到對應模型
回答
不是“PPLCNetNewV3”而是“PPLCNetV3”
不是“PPLCNetNewV3”而是“PPLCNetV3”
PPLCNetV3 我改成了这个,但是也是一样的报错。
把PPLCNetNew改成PPLCNetV3,在添加一行det: true
添加det: true后, 训练会遇到另外报错
Traceback (most recent call last):
File "/mnt/home/sp/projects/PaddleOCR/tools/train.py", line 228, in <module>
main(config, device, logger, vdl_writer)
File "/mnt/home/sp/projects/PaddleOCR/tools/train.py", line 199, in main
program.train(config, train_dataloader, valid_dataloader, device, model,
File "/mnt/home/sp/projects/PaddleOCR/tools/program.py", line 334, in train
post_result = post_process_class(preds, batch[1])
File "/mnt/home/sp/projects/PaddleOCR/ppocr/postprocess/db_postprocess.py", line 275, in __call__
results[k] = self.post_process(predicts[k], shape_list=shape_list)
File "/mnt/home/sp/projects/PaddleOCR/ppocr/postprocess/db_postprocess.py", line 229, in __call__
src_h, src_w, ratio_h, ratio_w = shape_list[batch_index]
ValueError: too many values to unpack (expected 4)
I1013 19:03:27.982057 679392 tcp_store.cc:273] receive shutdown event and so quit from MasterDaemon run loop
调试进入
ppocr/postprocess/db_postprocess.py
文件中229lines
for batch_index in range(pred.shape[0]):
src_h, src_w, ratio_h, ratio_w = shape_list[batch_index]
if self.dilation_kernel is not None:
mask = cv2.dilate(
np.array(segmentation[batch_index]).astype(np.uint8),
self.dilation_kernel)
发现shappe_list是一个 batch_size 640(height) 640(width) 的数组, 显然下标访问后取值无法返回src_h, src_w, ratio_h, ratio_w
Traceback (most recent call last):
File "tools/train.py", line 227, in
an'zh按照这个改了还是报错
加上 det: true 直接
把PPLCNetNew改成PPLCNetV3,在添加一行det: true
这个是正解
只有设定了det: true,才能走输出序列这个条件分支。后面RSEFPN解析in_channels时,按序列来解,才不会报错。
添加det: true后, 训练会遇到另外报错
Traceback (most recent call last): File "/mnt/home/sp/projects/PaddleOCR/tools/train.py", line 228, in <module> main(config, device, logger, vdl_writer) File "/mnt/home/sp/projects/PaddleOCR/tools/train.py", line 199, in main program.train(config, train_dataloader, valid_dataloader, device, model, File "/mnt/home/sp/projects/PaddleOCR/tools/program.py", line 334, in train post_result = post_process_class(preds, batch[1]) File "/mnt/home/sp/projects/PaddleOCR/ppocr/postprocess/db_postprocess.py", line 275, in __call__ results[k] = self.post_process(predicts[k], shape_list=shape_list) File "/mnt/home/sp/projects/PaddleOCR/ppocr/postprocess/db_postprocess.py", line 229, in __call__ src_h, src_w, ratio_h, ratio_w = shape_list[batch_index] ValueError: too many values to unpack (expected 4) I1013 19:03:27.982057 679392 tcp_store.cc:273] receive shutdown event and so quit from MasterDaemon run loop
调试进入
ppocr/postprocess/db_postprocess.py
文件中229linesfor batch_index in range(pred.shape[0]): src_h, src_w, ratio_h, ratio_w = shape_list[batch_index] if self.dilation_kernel is not None: mask = cv2.dilate( np.array(segmentation[batch_index]).astype(np.uint8), self.dilation_kernel)
发现shappe_list是一个 batch_size 640(height) 640(width) 的数组, 显然下标访问后取值无法返回src_h, src_w, ratio_h, ratio_w
我也遇到了跟你一样的问题,请问你解决了吗?
@KongXCai just set: cal_metric_during_train: false
把PPLCNetNew改成PPLCNetV3,在添加一行det: true
这个student1和student2都要做修改么,我两个都修改了以后,有非常多层的参数无法加载不到模型中
把PPLCNetNew改成PPLCNetV3,在添加一行det: true
这个student1和student2都要做修改么,我两个都修改了以后,有非常多层的参数无法加载不到模型中
解决了么?我也是PPLCNetNew改成PPLCNetV3之后,student1和student2都加了 det: true,也试过单独加 student1,结果还是报错