Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

paddlelite转换基于SLaNet训练的表格模型报错 #10549

Open
1aqi opened this issue Aug 6, 2024 · 4 comments
Open

paddlelite转换基于SLaNet训练的表格模型报错 #10549

1aqi opened this issue Aug 6, 2024 · 4 comments
Assignees

Comments

@1aqi
Copy link

1aqi commented Aug 6, 2024

在paddlelite==2.13rc0版本能转换官方表格模型SLANet,但是基于SLANet作为预训练模型训练出来的推理模型无法转换(基于PaddlePadlle==3.0Beta-gpu版本 cuda环境为12.4环境进行训练的模型)

报错信息如下:
C:\Users\seatrend.conda\envs\Paddle-Lite\python.exe D:\Project\python\Paddle-Lite\convert_model.py
[libprotobuf ERROR C:\xiaowen01\x86_windows_py_wheel\py37\Paddle-Lite\third-party\protobuf-host\src\google\protobuf\message_lite.cc:119] Can't parse message of type "paddle.framework.proto.ProgramDesc" because it is missing req
uired fields: blocks[1].ops[41].attrs[13].type, blocks[1].ops[44].attrs[13].type, blocks[1].ops[47].attrs[13].type
Loading topology data from ./model/input/SLANet/inference.pdmodel
[libprotobuf ERROR C:\xiaowen01\x86_windows_py_wheel\py37\Paddle-Lite\third-party\protobuf-host\src\google\protobuf\message_lite.cc:119] Can't parse message of type "paddle.framework.proto.ProgramDesc" because it is missing req
uired fields: blocks[1].ops[41].attrs[13].type, blocks[1].ops[44].attrs[13].type, blocks[1].ops[47].attrs[13].type
Loading params data from ./model/input/SLANet/inference.pdiparams

Model is successfully loaded!
[F 8/ 5 15: 6:54.293 ...e-Lite\lite/core/model/general/op_desc.h:123 paddle::lite::general::OpDesc::GetAttr] Check failed: pair.second->second == OpDataTypeTrait::AT: required type is INTS not match the true type
进程已结束,退出代码为 -1073740791 (0xC0000409)

@ddchenhao66
Copy link
Collaborator

您好~请问可以提供下模型和推理代码吗?

@1aqi
Copy link
Author

1aqi commented Aug 6, 2024

好的,模型是
slanet.zip
推理代码如下:
import os
import cv2
from paddleocr import PPStructure, draw_structure_result, save_structure_res
from PIL import Image
table_engine = PPStructure(layout=False,
show_log=True,
use_angle_cls=True,
use_gpu=False,
det_model_dir="inference/ch_PP-OCRv4_det_infer",
rec_model_dir="inference/ch_PP-OCRv4_rec_infer",
table_model_dir="inference/slanet")

save_folder = './output'
img_path = 'ppocr_img/ppocr_img/imgs/img.png'
img = cv2.imread(img_path)
result = table_engine(img)
save_structure_res(result, save_folder, os.path.basename(img_path).split('.')[0])

for line in result:
line.pop('img')
print(line)

font_path = 'doc/fonts/simfang.ttf' # PaddleOCR下提供字体包
image = Image.open(img_path).convert('RGB')
im_show = draw_structure_result(image, result, font_path=font_path)
im_show = Image.fromarray(im_show)
im_show.save('result.jpg')

@ddchenhao66
Copy link
Collaborator

ddchenhao66 commented Aug 7, 2024

hi~查看了Paddle3.0发版代码,涉及framework.proto改动不多,应该不会影响你这个模型的加载,很大可能是模型文件本身存在问题,在Paddle主框架issue里发现了和你类似的问题PaddlePaddle/Paddle#31741 。此外,也可以尝试回退用老版本paddle训练模型。

@1aqi
Copy link
Author

1aqi commented Aug 7, 2024

基于官方训练流程下的模型https://aistudio.baidu.com/modelsdetail/277?modelId=277
推理模型导出后,可以使用paddlelite转换成nb模型但是仍然提示
C:\Users\seatrend.conda\envs\Paddle-Lite\python.exe D:\Project\python\Paddle-Lite\convert.py
[libprotobuf ERROR C:\xiaowen01\x86_windows_py_wheel\py37\Paddle-Lite\third-part
y\protobuf-host\src\google\protobuf\message_lite.cc:119] Can't parse message of
type "paddle.framework.proto.ProgramDesc" because it is missing required fields:
blocks[1].ops[42].attrs[13].type, blocks[1].ops[44].attrs[13].type
Loading topology data from ./model/input/table_recognition_module/inference.pdmo
del[libprotobuf ERROR C:\xiaowen01\x86_windows_py_wheel\py37\Paddle-Lite\third-part
y\protobuf-host\src\google\protobuf\message_lite.cc:119] Can't parse message of
type "paddle.framework.proto.ProgramDesc" because it is missing required fields:
blocks[1].ops[42].attrs[13].type, blocks[1].ops[44].attrs[13].type
Loading params data from ./model/input/table_recognition_module/inference.pdiparams

  1. Model is successfully loaded!
  2. Model is optimized and saved into ./model/output/table_recognition_module_opt.nb successfully
    进程已结束,退出代码为 0
    这边估计问题就是在paddle版本太高的问题。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants